知行编程网知行编程网  2022-05-31 11:00 知行编程网 隐藏边栏 |   抢沙发  23 
文章评分 0 次,平均分 0.0

为什么Batch Normalization那么有用?

来自 | 知乎   作者 | autocyz

链接 | https://zhuanlan.zhihu.com/p/52749286

编辑 | 深度学习这件小事

本文仅作学术分享,如有侵权,请联系后台删除


本文是arxiv文章

How Does Batch Normalization Help Optimization?

链接:https://arxiv.org/abs/1805.11604

的一篇阅读笔记。文章很好,通过对比实验帮助我们理解why BN work!
先上结论,再做分析:
  1. 没有证据表明BN的work,是因为减少了ICS(Interval Covariate Shift)

  2. BN work的根本原因,是因为在网络的训练阶段,其能够让优化空间(optimization landscape)变的平滑。

  3. 其他的normalization技术也能够像BN那样对于网络的训练起到作用。

   一、BN和ICS的关系

在文章Batch Normalization:Accelerating Deep Network Training by Reducing Internal Covariate Shift中,其对与ICS是这样解释的:由于前一层的参数更新,所以这一层的输入(前一层的输出)的分布会发生变化,这种现象被称之为ICS。同样,这篇文章的观点认为BN work的真正原因,在与其将数据的分布都归一化到均值为0,方差为1的分布上去。因此,每一层的输入(上一层输出经过BN后)分布的稳定性都提高了,故而整体减小了网络的ICS。
但是,本文作者就提出了两个疑问:
1、BN work的原因是否真的与ICS有关?
2、BN层是否真的能够稳定输入分布?

1.1 BN是否真的与ICS有关?
对比实验:

在训练阶段,使用一下三种训练方法进行训练

  • No BN

  • 标准的BN

  • noisy BN (在标准的BN层后,加上均值不为0,方差不为1的noisy,并且在每个训练step都改变noisy的分布,降低了输入分布的稳定性,使得网络的ICS变大)

为什么Batch Normalization那么有用?
观察上图左,可以发现加了noisy BN和标准的BN在training accuracy和收敛速度上几乎没有差异,并且都优于不加BN的方法。
结论:
没有证据表明BN的性能是因为提高了输入分布的稳定性。即BN与ICS无关。

1.2 BN是否能够减少ICS
对比实验:(具体参看文章section 2.2)
  • 训练一个(25-layer deep linear network, DLN),即去除网络中的所有非线性激活层,只保留线性层,这么做的目的是为了在统计ICS时,减少非线性激活层对数据分布的影响。

  • 最后发现,带BN层的DLN不像预想的那样减少了ICS,反而增大了ICS。

结论:
从优化的角度来看,通过使用BN来控制layer的输入分布并不能减少ICS

   二、Why does BN work?

Ioffe and Szegedy在文章中说,BN可以防止梯度爆炸或弥散、可以提高训练时模型对于不同超参(学习率、初始化)的鲁棒性、可以让大部分的激活函数能够远离其饱和区域。所有这些BN的性质,都可以帮助我们快速鲁棒的训练网络。但是该怎么解释呢?
2.1 BN的平滑影响
作者认为,BN能够work的真正原因在于BN重新改变了优化问题,使得优化空间变得非常平滑。
为什么Batch Normalization那么有用?
对于没有BN的神经网络,其loss函数是不仅非凸,并且还有很多flat regions、sharp minimal。这就使得那些基于梯度的优化方法变得不稳定,因为很容易出现过大或者过小的梯度值。
观察上图,可以发现,在使用了BN后,loss的变化变得更加稳定,不会出现过大的跳动;同样,梯度也变得更加平滑。

2.2 是否BN是最好或者唯一的方法来对优化空间进行平滑

对比实验:
  • 不使用BN

  • 使用标准BN

  • 使用L1 归一化方法

  • 使用L2归一化方法

  • 使用L  归一化方法

为什么Batch Normalization那么有用?
结论:
很多normalization的方法都可以达到BN的效果,甚至更好。
2.3 理论分析
文章理论分析部分做了很多定理和推论,这里就不做具体分析啦。

<pre style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><p style="max-width: 100%;letter-spacing: 0.544px;white-space: normal;color: rgb(0, 0, 0);font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;widows: 1;line-height: 1.75em;box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;letter-spacing: 0.5px;font-size: 14px;box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong style="max-width: 100%;font-size: 16px;letter-spacing: 0.544px;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;letter-spacing: 0.5px;box-sizing: border-box !important;overflow-wrap: break-word !important;">—</span></strong>完<strong style="max-width: 100%;font-size: 16px;letter-spacing: 0.544px;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;letter-spacing: 0.5px;font-size: 14px;box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong style="max-width: 100%;font-size: 16px;letter-spacing: 0.544px;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;letter-spacing: 0.5px;box-sizing: border-box !important;overflow-wrap: break-word !important;">—</span></strong></span></strong></span></strong></p><section style="max-width: 100%;letter-spacing: 0.544px;white-space: normal;font-family: -apple-system-font, system-ui, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;widows: 1;box-sizing: border-box !important;overflow-wrap: break-word !important;"><section powered-by="xiumi.us" style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><section style="margin-top: 15px;margin-bottom: 25px;max-width: 100%;opacity: 0.8;box-sizing: border-box !important;overflow-wrap: break-word !important;"><section style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><section style="max-width: 100%;letter-spacing: 0.544px;box-sizing: border-box !important;overflow-wrap: break-word !important;"><section powered-by="xiumi.us" style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><section style="margin-top: 15px;margin-bottom: 25px;max-width: 100%;opacity: 0.8;box-sizing: border-box !important;overflow-wrap: break-word !important;"><section><p style="margin-bottom: 15px;padding-right: 0em;padding-left: 0em;max-width: 100%;color: rgb(127, 127, 127);font-size: 12px;font-family: sans-serif;line-height: 25.5938px;letter-spacing: 3px;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;color: rgb(0, 0, 0);box-sizing: border-box !important;overflow-wrap: break-word !important;"><strong style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;font-size: 16px;font-family: 微软雅黑;caret-color: red;box-sizing: border-box !important;overflow-wrap: break-word !important;">为您推荐</span></strong></span></p><p style="margin-top: 5px;margin-bottom: 5px;padding-right: 0em;padding-left: 0em;max-width: 100%;min-height: 1em;font-family: sans-serif;letter-spacing: 0px;opacity: 0.8;line-height: normal;box-sizing: border-box !important;overflow-wrap: break-word !important;">有你的学校吗?2020软科中国大学排名发布!</p><p style="margin-top: 5px;margin-bottom: 5px;padding-right: 0em;padding-left: 0em;max-width: 100%;min-height: 1em;font-family: sans-serif;letter-spacing: 0px;opacity: 0.8;line-height: normal;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="font-size: 14px;">GitHub重大更新:在线开发上线,是时候卸载IDE了</span></p><p style="margin-top: 5px;margin-bottom: 5px;padding-right: 0em;padding-left: 0em;max-width: 100%;min-height: 1em;font-family: sans-serif;letter-spacing: 0px;opacity: 0.8;line-height: normal;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;">「最全」实至名归,NumPy 官方早有中文教程</span><br style="max-width: 100%;box-sizing: border-box !important;overflow-wrap: break-word !important;"  /></p><p style="margin-top: 5px;margin-bottom: 5px;padding-right: 0em;padding-left: 0em;max-width: 100%;min-height: 1em;font-family: sans-serif;letter-spacing: 0px;opacity: 0.8;line-height: normal;box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="color: rgb(87, 107, 149);-webkit-tap-highlight-color: rgba(0, 0, 0, 0);cursor: pointer;max-width: 100%;font-size: 14px;box-sizing: border-box !important;overflow-wrap: break-word !important;">史上最烂的项目:苦撑12年,600多万行代码...</span></p><p style="margin-top: 5px;margin-bottom: 5px;padding-right: 0em;padding-left: 0em;max-width: 100%;min-height: 1em;font-family: sans-serif;letter-spacing: 0px;opacity: 0.8;line-height: normal;box-sizing: border-box !important;overflow-wrap: break-word !important;">一文概览2D人体姿态估计</p></section></section></section></section></section></section></section></section>
为什么Batch Normalization那么有用?

本篇文章来源于: 深度学习这件小事

本文为原创文章,版权归所有,欢迎分享本文,转载请保留出处!

知行编程网
知行编程网 关注:1    粉丝:1
这个人很懒,什么都没写

发表评论

表情 格式 链接 私密 签到
扫一扫二维码分享