Batch Normalization
0. 总结
有意思的是,原始论文宣称BN对Internal Covariance Shift有改善作用,之后的论文却提出了反驳。但是,BN的作用确实存在。
参考Youtube介绍,BN的好处:
- 收敛更快(让代价曲线从椭圆变成园,有利于梯度下降)
- 对初值要求更低
- (一点点)带有regularization作用
有如下有用的参考资料:
- [1] 2015 paper that introduced Batch Normalization: https://arxiv.org/abs/1502.03167
- [2] The paper that claims Batch Norm does NOT reduce internal covariate shift as claimed in [1]: https://arxiv.org/abs/1805.11604
- [3] Using BN + Dropout: https://arxiv.org/abs/1905.05928
- [4] Andrew Ng on why normalization speeds up training: https://www.coursera.org/lecture/deep…
- [5] Ian Goodfellow on how Batch Normalization helps regularization: https://www.quora.com/Is-there-a-theory-for-why-batch-normalization-has-a-regularizing-effect
- [6] Code Batch Normalization from scratch: https://kratzert.github.io/2016/02/12/understanding-the-gradient-flow-through-the-batch-normalization-layer.html
下面的BN算法中,对每个activation进行element-wise的均值、方差计算,计算一个mini-batch里的均值方差,并进行element-wise的归一化。
归一化后,需要恢复原始分布,引入 γ , β \gamma, \beta γ,β两个被学习的变量,目标是将这两个变量学习收敛到数据集的真实均值、方差。这样就能真正恢复原始分布。
同时,
β
\beta
β还可以替代
W
u
+
b
Wu+b
Wu+b中的bias
b
b
b。
对于卷积层,还需要normalization符合卷积特征:同一个feature map上不同位置的不同元素,都用相同的归一化方式。因此卷积层输出feature map的归一化,不是element-wise,而是针对mini-batch和一个feature map的所有元素一起进行。学到的 γ , β \gamma, \beta γ,β也是针对一个feature map的。
在这篇文章里,加入BN后,可以有其他加速或对之前方法的改进点:
- 提升learning rate。BN可以减缓梯度消失或爆炸问题
- 去掉Dropout。BN也有一部分regularization
- 训练集的重排更彻底
- 减弱L2权重regularization。
- 增大learning rate decay。因为BN可以加速收敛
- 去掉LRN (AlexNet)。因为加了BN后没啥必要。
- 减弱photometric distortion。因为收敛更快,一张图被训练的次数少,因此只需要更关注原始真实图像。