Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

9
  • 4
    is there a flag to detect if the model is in eval mode? e.g. mdl.is_eval()? Commented May 12, 2021 at 17:43
  • 10
    Use model.training flag. It is False, when in eval mode. Commented May 12, 2021 at 18:16
  • In the current documentation, I find this "model.train()" is no longer being used: pytorch.org/tutorials/beginner/basics/quickstart_tutorial.html I did a small test with a small 3 layer neural network model with batch norm and dropout and trained it on tabular dataset. I found adding model.train() actually prevented my model accuracy going above 70%. When I removed the line, the accuracy was 87%! Commented Aug 7, 2021 at 12:43
  • 1
    @Indrajit Did you check that was not in train model, i.e., model.training is False? I think by default it is true and that is why they omit model.train() call. As for your result, I cannot say much without knowing what the data was and if you measure test or train accuracy etc. Commented Aug 16, 2021 at 21:47
  • 2
    @UmangGupta- actually I figured out just now what was happening. My model.train() was actually impacting batchnorm and dropout layers - which in turn was impacting the model performance. Commented Aug 19, 2021 at 11:49