Say goodbye to standardization! MIT Google and others proposed a new residual learning method with amazing results

Background

In today's hot development of artificial intelligence applications, innovative network models and training techniques have become the core technology of artificial intelligence development. For example, after He Kaiming and his team proposed the residual learning structure of ResNet in 2016, most of the SOTA recognition systems were designed based on the addition of some normalization mechanisms to the structure of the convolutional network and the additive residual connection stacking. In addition to image classification, various types of normalization technologies play an important role in many other fields, such as machine translation and generative models.

The academic community has not yet reached a consensus on the reasons for the above-mentioned benefits of standardized technology. This paper studies the following aspects:  

  1. Can the deep residual network be trained reliably without normalization?

  2. Without normalization, can the deep residual network be trained with the same learning rate, can it converge at the same speed, and can obtain the same good generalization ability, or better?

Surprisingly, the researchers found that the answer to the above two questions is yes. At the same time, this paper also discusses the following issues (the following are all first-person compilations):  

  • Why standardization helps the training process. In the initialization process of the residual network, we studied a low-boundary gradient norm, which can explain why the use of standard initialization and normalization techniques is necessary for the deep residual network in the case of a large learning rate. of.

  • Train without using normalization . We propose Fixup technology-a method of scaling the standard initialization of residual branches by modifying the structure of the network. Fixup can use the maximum learning rate when training extremely deep residual networks without normalization.

  • Image classification. We use Fixup to replace the batch normalization process, and verify it on the benchmark database CIFAR-10 (Wide-ResNet) and ImageNet (ResNet) for image classification. The experimental results show that, after using proper regularization, the network trained using the Fixup method can achieve the same effect as the network trained using the normalized method.

  • machine translation. We used Fixup instead of the normalization layer, and trained on the machine translation benchmark database IWSLT and WMT using Transformer (a current best machine translation algorithm published in 2017 NeurIPS) model. It is found that this method can exceed the baseline and achieve the best results currently under the same framework.

Figure 1: Left: ResNet standard residual block, red indicates the batch normalization layer. Medium: A simple network block that can remain stable when stacked. Right: Fixup structure, which can better improve network stability by adding bias.

ResNet using standard initialization will cause gradients to explode

The standard initialization method is proposed to initialize the network parameters and prevent gradient disappearance or gradient explosion. However, when some standardized methods such as BatchNorm are not used, standard initialization cannot solve the problem of gradient explosion in residual connections. In response to this problem, Balduzzi proposed a ReLU network. We use a positive definite homogeneous activation function to generalize the idea of ​​the ReLU network to the residual network. When the normalization layer is not used, the activation function of each residual block in the original ResNet can be expressed as:

In order to facilitate the analysis, we analyze the use of positive definite homogeneous functions, first introduce two definitions: 

Definition 1 (Positive definite activation function) A function, for any input sum, there is, this function f(·) is called a positive definite homogeneous function (ph).

Definition 2 (Positive Definite Homogeneous Set) assumes that it is the parameter set of the function, and there is. If there is for any, which represents, it will be called a positive definite homogenous set (ph set).

More intuitively, the parameter set that makes any fixed input and fixed parameter a ph function is called a ph set, and a function is called a ph function.

Examples of the ph function are abundant in neural networks. Including many unbiased linear operations, such as fully connected layer, convolutional layer, pooling layer, concatenation layer, dropout, etc., of course, also includes non-linear functions such as ReLU. In addition, we also introduced the following two propositions:

命题 1 由 p.h. 函数组成的复合函数仍是 p.h. 函数(证明部分可参考论文原文)一个包含 c 类的使用交叉熵损失的分类网络,交叉熵损为,其中对于每个样本, 表示其未归一化概率, 表示其真实类标的独热编码。由命题 1,我们可以得到以下两个猜想:  

  1. 猜想 1 一个使用交叉熵损失的分类网络 f 可以看成是一个若干个网络块组成的集合,其中每个网络块都是一个 p.h. 函数

  2. 猜想 2 FC 层的权重是从零均值对称分布中独立同分布采样得到的。

在一个使用了 ReLU 函数的残差网络中,如果我们移除了所有的规范化层,根据这些猜想可得到所有的偏置都被初始化为 0。

我们的结论可以总结为如下两条,证明过程在论文的附件中:

理论 1 对于第 i 个块的输入,基于假设1,可以得到:其中 是 softmax 概率, 表示香农熵。

由于 的上边界是(c 为类别数) 并且在靠后的块中 是比较小的值,因此在靠后的块中由于损失函数引起的梯度范数会被放大。我们的第二条李理论证明了对于网络中的 p.h. 集,其梯度范数存在下边界。

理论 2 基于理论 1,我们可以得到:

更进一步,结合理论 1 和理论 2,有:

在图 2 中,我们提供了不使用规范化时 ResNet 中的三种 p.h. 集合的例子。基于理论 2,如果未归一化概率值 z 在初始化的时候被放大了,这三个例子都有可能会遭遇梯度爆炸问题。而在 ResNet 中,如果不使用规范化,而使用传统方法初始化参数,上述情况是很有可能出现的。这就是我们提出一种新的初始化方法的动机。图 2:ResNet 中不使用规划范时 p.h. 集的例子。(1) 最大池化前的第一个卷积层;(2)softmax 层之前的全连接层;(3) 主干网络中的空间降采样层和与其相对应的残差分支中的卷积层。

Fixup:在 SGD 的每一步更新残差网络

在这一部分,我们提出了一种由上至下的新的初始化方法。通过对标准初始化简单地放缩,可以保证在合适的范围更新网络函数。首先,我们假设学习率并设定我们的目标:

在对 初始化为 0 后,每一步 SGD 都对函数 更新为

即对于

从另一个角度讲,我们的目标是设计一种初始化方法,从而使 SGD 可以不依赖深度且以正确的比例对网络函数进行更新。

我们将捷径(Shortcut)定义为残差网络中从输入到输出的最短路径。捷径是一种典型的可训练的浅层网络。假设使用标准方法对捷径进行初始化,我们来分析一下残差分支的初始化情况。

残差分支同步更新网络。

最初,我们发现 SGD 在更新每个残差分支的时,会在高度相关的方向上改变网络的输出。这意味着,如果一个残差网络含有L个残差分支,那么每个残差分支在一次迭代中,应当对网络的输出平均改变从而达到对整个网路输出改变为。

对于标量分支的研究。

接着,我们研究了如何对包含 m 层的残差分支进行初始化,从而使该残差分支可以对网络输出影响为。假设m是一个小的正整数(如,2 或 3)。由于我们仅关心更新的比例,所以只研究标量的情况是非常高效的方法, 即:标准初始化的过程可以理解为:。与标准初始化不同的是,我们将 设为一个任意的正数而不是 1 来表示对于第 层使用 进行放缩。

最终我们可以得到,当且仅当满足以下条件时:

SGD 对 的更新为。

由上面这个公式可以得到一种新的初始化方法,即对于残差分支中的第 i 层,使用相关的标量 对其标准初始化过程进行放缩。在本文的实验部分,我们选择使用如下设置:

偏置和乘法器的影响。

通过对残差分支中权重的放缩,一个残差网络在 SGD 的每一步更新值为,到这里我们的目标已经达成了。然而,为了使训练性能与使用规范化时相匹配,我们还需要考虑偏置和乘法器的情况。

在全连接层和卷积层使用偏置是一种很通用的方法。在规范化方法中,偏置和缩放参数被用来重建特征经过规范化操作后的表征能力。因为权重层与激活层的输入 / 输出均值可能不同,因此在不使用规范化的残差网络中插入偏置项同样可以有助于训练网络。我们发现在每个权重层和非线性激活层前仅插入一个标量偏置可以显著地提高训练性能。

乘法器会对残差分支的输出进行放缩,这与批规范化中的放缩参数功能类似(批规范化中两个重要参数为:scale 和 shift,即放缩与滑动)。我们发现,在每个残差分支中插入一个标量乘法器可以模仿使用规范化的网络中权重模值动态变化的过程。最终,我们得到了训练不使用规范化方法的残差网络的完整方法:

Fixup 初始化  

  1. 将分类层和每个残差分支的最后一层初始化为 0。

  2. 使用标准方法对其他层进行初始化,仅对残差分支中的权重层使用放缩系数图片 进行放缩。

  3. 在每个残差分支中添加一个标量加法器(初始化为 1),在每个卷积层、线性层和元素级的激活层前添加一个标量偏置(初始化为 0)。

实    验

我们在 CIFAR-10 数据库上测试了第一轮迭代(即数据库中所有图像通过模型一次)结束后模型的测试准确率,发现对于多种深度的卷积神经网络,在学习率相同的情况下 Fixup 可以达到与 BatchNorm 相同的效果。实验结果如下图所示:

图片

图 1 CIFAR-10 数据库上各种方法的训练结果比较,值越大表示结果越好。

此外,我们还对比了使用 Fixup 训练不同深度的 ResNet 和其他方法在 ImageNet 数据库上的结果,实验结果如下表所示:

图片

可以看出 Fixup 与组规范化方法的性能不相上下,该实验中通过交叉验证得到了三种方法的最优偏置标量,对于批规范化、组规范化和 Fixup 分别为 0.2,0.1 和 0.7。

此外,在机器翻译的 SOTA 方法中我们同样使用 Fixup 代替规范化层进行了实验。我们惊奇地发现,当使用 Fixup 代替规范化层可以更好地防止模型过拟合,我们认为这要归功于 dropout 操作的正则化。在两个数据库上,使用 Fixup 都取得了目前最好的结果,实验结果如下表:

图片

结    论

Fixup 通过对标准初始化进行适当的放缩来解决训练过程中梯度爆炸和梯度消失的问题。在不使用规范化的情况下,使用 Fixup 训练的残差网络可以达到与使用规范化训练时相同的稳定性,甚至在网络层数达到了 10000 层时也可以不相上下。此外,在使用了合适正则化方法的情况下,通过 Fixup 训练的不使用规范化的残差网络在图像分类和机器翻译上达到了目前最好的水平。在理论和应用两方面,这篇工作都给出了一种新的尝试。在理论层面,去除规范化有利于更简便地分析残差网络。在应用层面,Fixup 对于发展正则化方法提供了可能,比如结合 ZeroInit 等。


Guess you like

Origin blog.51cto.com/15060462/2679167