使用运行统计数据训练 BatchNorm 层是个好主意吗?
据我所知,BatchNorm
将在 train
模式下使用批处理统计信息,但使用运行统计信息 (running_mean
/running_var) 在
eval
模式下。总是在 train
和 eval
模式下使用运行统计数据怎么样?
在我看来,我们毕竟在推理阶段使用了eval
模式。为什么我们不在训练阶段一开始就使用 eval
风格 BatchNorm
呢?
As far as I know, BatchNorm
will use batch stats in train
mode, but use running stats (running_mean
/running_var
) in eval
mode. How about just always use running stats in both train
and eval
mode?
In my opinion, we use eval
mode in inference phase after all. why don't we use eval
style BatchNorm
from the beginning in the training phase?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自 https://pytorch.org/docs/master/ generated/torch.nn.BatchNorm2d.html?highlight=batchnorm2d#torch.nn.BatchNorm2d
我想如果您从未将 BatchNorm 设置为训练,则不会存储任何值(或一些默认值),并且该层将不会针对您的数据进行优化。它类似于线性/卷积层。 “为什么我们不在训练阶段让它们进行评估呢?”嗯,因为我们希望各层能够学习可以在评估模式中使用的东西。
From https://pytorch.org/docs/master/generated/torch.nn.BatchNorm2d.html?highlight=batchnorm2d#torch.nn.BatchNorm2d
I imagine if you never set BatchNorm to train, then no values (or some default values) are stored and the layer will not be optimized for your data. It is similar to linear/conv layers. "Why don't we set them to eval in the training phase?" Well because we want the layers to learn something that we can use in evaluation mode.