Skip to content

Different output when changing last few samples of input #589

Answered by EliasLum
EliasLum asked this question in Q&A
Discussion options

You must be logged in to vote

No problem.
As mentioned above the model contains batch normalization. At the evaluation stage it is important to set batch normalization and dropout to evaluation-mode as mentioned in the pytorch documentation:

Remember that you must call model.eval() to set dropout and batch normalization layers to evaluation mode before running inference. Failing to do this will yield inconsistent inference results.

The two things that model.eval() or the equivalent model.train(False) automatically take care of are:

  • normalization layers use running statistics (e.g. running averages).
  • dropout layers are de-activated

So in my case, where I missed to set the model to evaluation-mode the normalization …

Replies: 5 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@mpariente
Comment options

Answer selected by EliasLum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants