Is it necessary for model enable an desable in training and testing?

Hi
suppose my model created with name is net.pth. Is is necessary to make it enable using net.train() before training and also before evaluation disable using net.eval() before evaluating.

Yes, this is necessary as model.eval() will set all modules to evaluation mode.
For example batch norm layers will use the running statistics to normalize the current sample instead of the batch statistics and also won’t update the running stats, while dropout layers will be disables during evaluation.

1 Like