model.train 和 model.eval

model.train() :啓用 BatchNormalization 和 Dropout

model.eval() :不啓用 BatchNormalization 和 Dropout

固化權重,防止在測試的時候改變

sets the module in evaluation mode.

This has any effect only on certain modules. See documentations of particular modules for details of their behaviors in training/evaluation mode, if they are affected, e.g. DropoutBatchNorm, etc.

This is equivalent with self.train(False)

https://pytorch.org/docs/stable/nn.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章