pytorch 模型的train模式与eval模式
原因
对于一些含有batch normalization或者是Dropout层的模型来说,训练时的froward和验证时的forward有计算上是不同的,因此在前向传递过程中需要指定模型是在训练还是在验证。
源代码
[docs] def train(self, mode=True):
r"""Sets the module in training mode.
...
原创
2019-04-08 09:52:52 ·
5271 阅读 ·
0 评论