Models are by the default in train mode, so I don’t think that’s the issue.
How large is your training and testing database? 2000 is not that much, but depending on the data, you’ll need matching sized database. Is the accuracy exactly 0 or near random (0.0005)?
The code seems good to me on the first glance.