Batch Normalization

Batch normalization in Neural Networks
Deeplearning.ai: Why Does Batch Norm Work? (C2W3L06)

Fitting Batch Norm into a Neural Network

对每个隐层的输入 z(l),a(l) z ( l ) , a ( l ) 做归一化(减去均值除以标准差),再用 β,γ β , γ 进行重缩放:
这里写图片描述
这里写图片描述
这里写图片描述

为什么BN?

Covariate shift

To explain covariance shift, let’s have a deep network on cat detection. We train our data on only black cats’ images. So, if we now try to apply this network to data with colored cats, it is obvious; we’re not going to do well. The training set and the prediction set are both cats’ images but they differ a little bit. In other words, If an algorithm learned some X to Y mapping, and if the distribution of X changes, then we might need to retrain the learning algorithm by trying to align the distribution of X with the distribution of Y. This is true even when the ground truth function mapping from X to Y remains unchanged.
针对检测图像中的猫的任务,如果我们的训练集中只有黑猫的图片,训练出来的神经网络运用到彩色猫的图片上时显然不会表现很好。训练集和测试集尽管都是猫的图片,但是他们又有所区别。换句话说,如果一个算法学习了X到Y的映射,当X的分布改变时,我们可能需要重新进行训练来适应这种输入分布的改变,即使真实的映射函数没有改变。
这里写图片描述

batch normalization allows each layer of a network to learn by itself a little bit more independently of other layers.
Batch normalization使得神经网络每层的学习能够相对的独立于其他层。

Why Batch Norm Works?

现在我们以 w(3),b(3) w ( 3 ) , b ( 3 ) 的学习为例:
这里写图片描述
这里写图片描述

这里写图片描述
当前面层网络的参数改变时,会改变 a(3) a ( 3 )

w(3),b(3) w ( 3 ) , b ( 3 ) 是为了从 a(3) a ( 3 ) 估计 y y 而学习的参数,因此w(3),b(3)也需要随之改变。
这里写图片描述

这里写图片描述

这里写图片描述
因此会有严重的covariate shift问题。

BN减少了隐藏层变化的幅度。
这里写图片描述

无论每层的输出怎么变,他们的均值和方差不会变(由 β β , γ γ 控制)。

这里写图片描述
这里写图片描述
这里写图片描述
BN算法削弱了前层参数和后面参数的耦合,允许网络的每一层独立学习,提升整个网络的训练速度。

由于前面层输出的均值和方差被限制了,他们的变化不会那么的大,后面的学习变得更加简单。

BN as regularization

此外BN还有轻微正则化作用:均值方差是在每个mini-batch上得到的,因此均值和标准差的估值存在噪声;normalize过程也有噪声。
这里写图片描述
这里写图片描述
给隐藏层增加噪声,使得downstream units不至于过分依赖前面的单元。


这里写图片描述

BN at test time

在测试时可能需要逐一测试样本,没有足够的样本去计算 μ μ σ2 σ 2

解决办法:
利用训练集估算,估算的方法有很多种:记住训练时每个mini batch见到的 μ μ σ2 σ 2 ,然后用指数加权平均来估算mu和sigma2。
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述

利用指数加权平均
这里写图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值