Batch Norm、Layer Norm、Weight Norm与SELU
加速网络收敛——BN、LN、WN与selu
自Batch Norm出现之后,Layer Norm和Weight Norm作为Batch Norm的变体相继出现。最近又出来一个很”简单”的激活函数Selu,能够实现automatic rescale and shift。这些结构都是为了保证网络能够堆叠的更深的基本条件之一。除了这四种,还有highway network与resnet。
Batch Norm
BN对某一层激活值做batch维度的归一化,也就是对于每个batch,该层相应的output位置归一化所使用的mean和variance都是一样的。
- BN的学习参数包含rescale和shift两个参数;训练的时候不断更新这两个参数和moving average mean and variance
- BN在单独的层级之间使用比较方便,比如CNN
- 像RNN这样unroll之后层数不定,直接用BN不太方便,需要对每一层(每个time step)做BN,并保留每一层的mean和variance。不过由于RNN输入不定长(time step长度不定),可能会有validation或test的time step比train set里面的任何数据都长,因此会造成mean和variance不存在的情况。针对这个情况,需要对每个time step独立做统计。在BN-LSTM中是这么做的:Generalizing the model to sequences longer than those seen during training is straightforward thanks to the rapid convergence of the activations to their steady-state distributions (cf. Figure 5). For our experiments we estimate the population statistics separately for each timestep 1, . . . , Tmax where Tmax is the length of the longest training sequence. When at test time we need to generalize beyond Tmax, we use the population statistic of time Tmax for all time steps beyond it. During training we estimate the statistics across the minibatch, independently for each timestep. At test time we use estimates obtained by averaging the minibatch estimates over the training set.当然,也可以只对输入-隐层进行BN,或者stack RNN中同一个time step的不同层之间做BN
- BN会引入噪声(因为是mini batch而不是整个training set),所以对于噪声敏感的方法(如RL)不太适用
BN算法思路如下(注意training和inference时候的区别)。
Layer Norm
LN也是对输出归一化的。LN也是为了消除各层的covariate shift,加快收敛速度。LN相对于BN就简单多了。
- 它在training和inference时没有区别,只需要对当前隐藏层计算mean and variance就行
- 不需要保存每层的moving average mean and variance
- 不受batch size的限制,可以通过online learning的方式一条一条的输入训练数据
- LN可以方便的在RNN中使用
- LN增加了gain和bias作为学习的参数,μ和σ分别是该layer的隐层维度的均值和方差
Weight Norm
WN是使用参数重写(reparameterization weight normalization)的方法来做归一化的。哪里有weight,哪里就可以用WN来归一化。WN也是用来加速收敛的。通过对weight进行normalization,可以保证在梯度回传的时候,如果梯度越noisy(梯度越大),v的norm就越大,那么g/||v||就越小,从而就会抑制梯度。做到了梯度的自稳定(self-stabilize)。
与LN稍不一样,WN只有gain这一个学习参数
前向传播时,BN就是简单的normalization
- 梯度回传的时候,会对梯度做自稳定
- 论文里提到了WN能够让learning rate自适应/自稳定
If the learning rate is too large, the norm of the unnormalized weights grows quickly until an appropriate effective learning rate is reached. Once the norm of the weights has grown large with respect to the norm of the updates, the effective learning rate stabilizes.
- WN与BN一样,只不过BN直接从输出角度出发,WN从weight角度出发
- 注意WN的初始化,需要用第一个minibatch的均值和方差来初始化g和b。
- Mean-only BN
考虑到BN并不能保证参数v的协方差矩阵为单位矩阵,也就是BN不能保证激活值与v独立。而WN能做到,因此可以结合WN与BN,此时的BN经过修改,只进行去均值操作。
selu
最理想的结果就是让每一层输出的激活值为零均值、单位方差,从而能够使得张量在传播的过程当中,不会出现covariant shift,保证回传梯度的稳定性,不会有梯度爆炸或弥散的问题。selu能够很好的实现automatically shift and rescale neuron activations towards zero mean and unit variance without explicit normalization like what batch normalization technique does.
并且可以参考References中的Selus与Leaky Relu以及Relu之间的对比。selu 推荐用在大训练样本的数据集上。
References
Weight Normalization: A Simple Reparameterization to Accelerate Training of Deep Neural Networks
Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift
RECURRENT BATCH NORMALIZATION
Layer Normalization
深度学习加速策略BN、WN和LN的联系与区别,各自的优缺点和适用的场景?
SELUs (scaled exponential linear units) - Visualized and Histogramed Comparisons among ReLU and Leaky ReLU
引爆机器学习圈:「自归一化神经网络」提出新型激活函数SELU
来源: http://skyhigh233.com/blog/2017/07/21/norm/
Batch Norm、Layer Norm、Weight Norm与SELU的更多相关文章
- 【算法】Normalization
Normalization(归一化) 写这一篇的原因是以前只知道一个Batch Normalization,自以为懂了.结果最近看文章,又发现一个Layer Normalization,一下就懵逼了. ...
- A Brief Overview of Deep Learning
A Brief Overview of Deep Learning (This is a guest post by Ilya Sutskever on the intuition behind de ...
- Batch Norm 与 Layer Norm 比较
一.结论 Batch Norm一般用于CV领域,而Layer Norm一般用于NLP领域 Batch Norm需要计算全局平均,而Layer Norm不需要计算全局平均 二.Batch Norm Ba ...
- norm函数的作用,matlab
格式:n=norm(A,p)功能:norm函数可计算几种不同类型的返回A中最大一列和,即max(sum(abs(A))) 2 返回A的最大奇异值,和n=norm(A)用法一样 inf 返回A中最大一行 ...
- MATLAB 中NORM运用
格式:n=norm(A,p)功能:norm函数可计算几种不同类型的矩阵范数,根据p的不同可得到不同的范数 以下是Matlab中help norm 的解释 NORM Matrix or vector ...
- (转)几种范数的解释 l0-Norm, l1-Norm, l2-Norm, … , l-infinity Norm
几种范数的解释 l0-Norm, l1-Norm, l2-Norm, - , l-infinity Norm from Rorasa's blog l0-Norm, l1-Norm, l2-Norm, ...
- matlab norm的使用
格式:n=norm(A,p)功能:norm函数可计算几种不同类型的矩阵范数,根据p的不同可得到不同的范数 以下是Matlab中help norm 的解释 NORM Matrix or vector n ...
- matlab norm 范式
格式:n=norm(A,p) 功能:norm函数可计算几种不同类型的矩阵范数,根据p的不同可得到不同的范数 p 返回值 1 返回A中最大一列和,即max(sum(abs(A))) 2 返回A的 ...
- Matlab norm 用法小记
Matlab norm 用法小记 matlab norm (a) 用法以及实例 norm(A,p)当A是向量时norm(A,p) Returns sum(abs(A).^p)^(1/p), for ...
随机推荐
- Opencv --- 图像像素遍历的各种方法
#include <opencv2/core.hpp> #include <opencv2/imgcodecs.hpp> #include <opencv2/highgu ...
- django 的ajax 请求,使用form的验证机制。
所有的form都需要在后台验证,前台验证是不可靠的,django的验证是后台验证,前台提示错误信息. js验证是在前台的,无需发送消息给后台,但安全性不可靠,强调的是用户体验. 要求,使用弹出框,弹出 ...
- 剑指offer六十一之序列化二叉树(待补充)
一.题目 请实现两个函数,分别用来序列化和反序列化二叉树二.思路 三.代码 --------------------------------------------- 参考链接:
- 【java排序】冒泡排序、快速排序
冒泡排序 冒泡排序是一种简单的排序算法.它重复地走访过要排序的数列,一次比较两个元素,如果他们的顺序错误就把他们交换过来.走访数列的工作是重复地 进行直到没有再需要交换,也就是说该数列已经排序完成.这 ...
- javac之BridgeMethod及泛型擦除重写
When compiling a class or interface that extends a parameterized class or implements a parameterized ...
- C语言初学
输出控制符 输出控制符 含义 %d int 整型数 %ld long int %c char 一个字符 %f float 浮点数,整数/整数=整数,整数/小数=小数 %lf double %x %X ...
- 11-hdfs-NameNode-HA-wtihQJM解决单点故障问题
在hdfs中, NN只有一个, 但其中保存的数据尤其重要, 所以需要将元数据保存, 其中源数据有2个形式, fsimage 和 edit文件, 最简单的解决方法就是复制fsimage, 并在文件修改时 ...
- null,“”,empty的区别
public class Test { public static void main(String[] args) { // TODO Auto-generated method stub /** ...
- linux下c的网络编程---转载
1.tcp协议
- ruby中数组的常用函数
在程序中定义一个数组 在程序中定义一个数组,因为我们在下面说明. fruits = ["apple", "orange", "lemon"] ...