Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the meaning of function eval() in torch.nn module

Tags:

pytorch

Official comment shows that "This has any effect only on modules such as Dropout or BatchNorm." But I don't understand its implementation.

like image 968
闫伯元 Avatar asked Jan 08 '18 08:01

闫伯元


1 Answers

Dropout and BatchNorm (and maybe some custom modules) behave differently during training and evaluation. You must let the model know when to switch to eval mode by calling .eval() on the model.

This sets self.training to False for every module in the model. If you are implementing your own module that must behave differently during training and evaluation, you can check the value of self.training while doing so.

like image 162
litesaber Avatar answered Nov 24 '22 01:11

litesaber