第 20 章 · 深度学习为何有效
Understanding Deep Learning — Why does deep learning work?
This chapter differs from those that precede it. Instead of presenting established results, it poses questions about how and why deep learning works so well. These questions are rarely discussed in textbooks. However, it’s important to realize that (despite the title of this book) understanding of deep learning is still limited.
We argue that it is surprising that deep networks are easy to train and also surprising that they generalize. Then we consider each of these topics in turn. We enumerate the factors that influence training success and discuss what is known about loss functions for deep networks. Then we consider the factors that influence generalization. We conclude with a discussion of whether networks need to be overparameterized and deep.
本章与之前的章节有所不同。它没有介绍已有的成果,而是提出关于深度学习如何以及为何如此有效的问题。这些问题在教科书中很少被讨论。然而,重要的是要认识到(尽管本书的书名如此),对深度学习的理解仍然有限。
我们提出,深度网络易于训练令人惊讶,它们能够泛化同样令人惊讶。然后我们依次讨论这些主题。我们列举影响训练成功的因素,并讨论关于深度网络损失函数的已知内容。然后我们讨论影响泛化的因素。最后,我们讨论网络是否需要过度参数化并且足够深。
The MNIST-1D dataset (figure 8.1) has just forty input dimensions and ten output dimensions. With enough hidden units per layer, a two-layer fully connected network classifies 10000 MNIST-1D training data points perfectly and generalizes reasonably to unseen examples (figure 8.10a). Indeed, we now take it for granted that with sufficient hidden units, deep networks will classify almost any training set near-perfectly. We also take for granted that the fitted model will generalize to new data. However, it’s not at all obvious either that the training process should succeed or that the resulting model should generalize. This section argues that both these phenomena are surprising.
MNIST-1D 数据集(图 8.1)仅有四十个输入维度和十个输出维度。只要每层有足够的隐藏单元,一个两层全连接网络就能完美分类 10000 个 MNIST-1D 训练数据点,并对未见样本有合理的泛化(图 8.10a)。事实上,我们现在已经理所当然地认为,只要有足够的隐藏单元,深度网络就能近乎完美地对几乎任何训练集进行分类。我们也理所当然地认为,拟合后的模型会泛化到新数据。然而,训练过程应当成功,或者所得模型应当泛化,这两点都根本不显然。本节论证这两种现象都令人惊讶。
Performance of a two-layer fully connected network on 10000 MNIST-1D training examples is perfect once there are 43 hidden units per layer or ∼4000 parameters (figure 8.10). However, finding the global minimum of an arbitrary non-convex function is NP-hard (Murty & Kabadi, 1987), and this is also true for certain neural network loss functions (Blum & Rivest, 1992). It’s remarkable that the fitting algorithm doesn’t get trapped in local minima or stuck near saddle points and that it can efficiently recruit spare model
在 10000 个 MNIST-1D 训练样本上,一个两层全连接神经网络的性能一旦每层有 43 个隐藏单元或 ∼4000 个参数时就达到完美(图 8.10)。然而,寻找任意非凸函数的全局最小值是 NP-hard 的(Murty & Kabadi, 1987),对于某些神经网络损失函数也是如此(Blum & Rivest, 1992)。令人惊讶的是,拟合算法没有陷入局部极小值或卡在鞍点附近,并且能够有效招募空闲模型
容量,以拟合无论位于何处的未解释训练数据。
capacity to fit unexplained training data wherever they lie.
Perhaps this success is less surprising when there are far more parameters than training data. However, it’s debatable whether this is generally the case. AlexNet had ∼ 60 million parameters and was trained with ∼ 1 million data points. However, to complicate matters, each training example was augmented with 2048 transformations. GPT-3 had 175 billion parameters and was trained with 300 billion tokens. There is not a clear-cut case that either model was overparameterized, and yet they were successfully trained.
In short, it’s surprising that we can fit deep networks reliably and efficiently. Either the data, the models, the training algorithms, or some combination of all three must have some special properties that make this possible.
当参数远多于训练数据时,这种成功或许并不那么令人惊讶。然而,这是否是普遍情况仍有争议。 AlexNet 拥有 ∼ 60 百万个参数,并用 ∼ 1 百万个数据点进行训练。然而,使问题更复杂的是,每个训练样本都通过 2048 种变换进行了增强。 GPT-3 拥有 1750 亿个参数,并用 3000 亿个词元进行训练。没有明确证据表明这两个模型中的任何一个被过参数化,但它们都成功完成了训练。
简而言之,我们能够可靠且高效地拟合深度网络,这令人惊讶。数据、模型、训练算法,或三者的某种组合,必定具有使这成为可能的特殊性质。
If the efficient fitting of neural networks is startling, their generalization to new data is dumbfounding. First, it’s not obvious a priori that typical datasets are sufficient to characterize the input/output mapping. The curse of dimensionality implies that the training dataset is tiny compared to the possible inputs; if each of the 40 inputs of the MNIST-1D data were quantized into 10 possible values, there would be 1040 possible inputs, which is a factor of 1036 more than the number of training examples.
Second, deep networks describe very complicated functions. For example, a fully connected network for MNIST-1D with two hidden layers of width 400 can create mappings with up to 1042 linear regions. That’s roughly 1038 regions per training example, so very few of these regions contain data at any stage during training; regardless, those regions that do encounter data points constrain the remaining regions to behave reasonably.
如果说神经网络的高效拟合令人震惊,那么它们对新数据的泛化则令人瞠目结舌。首先,先验地来看,典型数据集足以刻画输入 / 输出映射这一点并不显然。维度灾难意味着,与可能的输入相比,训练数据集非常小;如果将 MNIST-1D 数据的 40 个输入中的每一个量化为 10 个可能值,那么就会有 1040 个可能的输入,比训练样本数量多出 1036 倍。
第二,深度网络描述非常复杂的函数。例如,一个用于 MNIST-1D 的、具有两个宽度为 400 的隐藏层的全连接网络,可以创建具有最多 1042 个线性区域的映射。这大约相当于每个训练样本 1038 个区域,因此在训练的任何阶段,这些区域中很少有区域包含数据;无论如何,那些确实遇到数据点的区域会约束其余区域,使其表现合理。
Third, generalization gets better with more parameters (figure 8.10). The model in the previous paragraph has 177,201 parameters. Assuming it can fit one training example per parameter, it has 167,201 spare degrees of freedom. This surfeit gives the model latitude to do almost anything between the training data, and yet it behaves sensibly.
第三,随着参数增多,泛化变得更好(图 8.10)。上一段中的模型有 177,201 个参数。假设每个参数可以拟合一个训练样本,那么它还有 167,201 个剩余自由度。这种过剩使模型在训练数据之间几乎任何事都可以做,但它仍然表现合理。
To summarize, it’s neither obvious that we should be able to fit deep networks nor that they should generalize. A priori, deep learning shouldn’t work. And yet it does. This chapter investigates why. Sections 20.2–20.3 describe what we know about fitting deep networks and their loss functions. Sections 20.4–20.6 examine generalization.
总之,我们能否拟合深度网络以及它们能否泛化,都不是显而易见的。先验地,深度学习不应该有效。但它确实有效。本章研究其原因。第 20.2–20.3 节介绍我们对拟合深度网络及其损失函数的了解。第 20.4–20.6 节考察泛化。
Figure 6.4 showed that loss functions for nonlinear models can have both local minima and saddle points. However, we can reliably fit deep networks to complex training sets. For example, figure 8.10 shows perfect training performance on MNIST-1D, MNIST, and CIFAR-100. This section considers factors that might resolve this contradiction.
图 6.4 显示,非线性模型的损失函数可能同时具有局部极小值和鞍点。然而,我们可以可靠地在复杂训练集上拟合深度网络。例如,图 8.10 显示了在 MNIST-1D、 MNIST 和 CIFAR-100 上完美的训练表现。本节考虑可能解决这一矛盾的因素。

It’s important to realize that we can’t learn any function. Consider a completely random mapping from every possible 28 × 28 binary image to one of ten categories. Since there is no structure to this function, the only recourse is to memorize the 2784 assignments. However, it’s easy to train a model on the MNIST dataset (figures 8.10 and 15.15), which contains 60,000 examples of 28 × 28 images labeled with one of ten categories. One explanation for this contradiction could be that it is easy to find global minima because the real-world functions that we approximate are relatively simple. 1 This hypothesis was investigated by Zhang et al. (2017a), who trained AlexNet on the CIFAR-10 image classification dataset (which has 50,000 examples of 32 × 32 × 3
重要的是要认识到,我们无法学习任何函数。考虑从每一种可能的 28 × 28 二值图像到十个类别之一的完全随机映射。由于这个函数没有结构,唯一可行的办法是记住这些 2784 分配。然而,在 MNIST 数据集(图 8.10 和图 15.15)上训练模型却很容易,该数据集包含 60,000 个 28 × 28 图像样本,每个图像都带有十个类别之一的标签。对这一矛盾的一种解释可能是:由于我们近似的现实世界函数相对简单,因此很容易找到全局极小值。 1这一假设由 Zhang 等人(2017a)进行了研究,他们训练 AlexNet 于CIFAR-10 图像分类数据集(该数据集包含 50,000 个带有 10 个类别之一标签的 32 × 32 × 3
images labeled with one of 10 classes) when (i) each image was replaced with Gaussian noise and (ii) the labels of the ten classes were randomly permuted (figure 20.1). These changes slowed down learning, but the network could still fit this finite dataset well.
This suggests that the properties of the dataset aren’t critical.
图像样本),当 (i) 每幅图像被替换为高斯噪声,且 (ii) 十个类别的标签被随机排列时(图 20.1)。这些变化减缓了学习速度,但网络仍能很好地拟合这个有限数据集。
这表明数据集的性质并不关键。
Another possible explanation for the ease with which models are trained is that some regularization methods like L2 regularization (weight decay) make the loss surface flatter and more convex. However, Zhang et al. (2017a) found that neither L2 regularization nor Dropout was required to fit random data. This does not eliminate implicit regularization due to the finite step size of the fitting algorithms (section 9.2). However, this effect increases with the learning rate (equation 9.9), and model-fitting does not get easier with larger learning rates.
对于模型训练如此容易的另一种可能解释是,一些正则化方法,如 L2 正则化(权重衰减),会使损失面更平坦、更凸。然而, Zhang 等人(2017a)发现,拟合随机数据既不需要 L2 正则化,也不需要随机失活。这并不能排除由于拟合算法的有限步长导致的隐式正则化(第 9.2 节)。然而,这种效应随学习率增大而增强(公式 9.9),但更大的学习率并不会使模型拟合变得更容易。
Chapter 6 argued that the SGD algorithm potentially allows the optimization trajectory to move between “valleys” during training. However, Keskar et al. (2017) show that
第 6 章认为, SGD 算法可能使优化轨迹在训练期间在“山谷”之间移动。然而, Keskar 等人(2017)表明
several models (including fully connected and convolutional networks) can be fit to many datasets (including CIFAR-100 and MNIST) almost perfectly with very large batches of 5000-6000 images. This eliminates most of the randomness but training still succeeds.
Figure 20.2 shows training results for four fully connected models fitted to 4000 MNIST-1D examples with randomized labels using full-batch (i.e., non-stochastic) gradient descent. There was no explicit regularization, and the learning rate was set to a small constant value of 0.0025 to minimize implicit regularization. Here, the true mapping from data to labels has no structure, the training is deterministic, and there is no regularization, and yet the training error still decreases to zero. This suggests that these loss functions may genuinely have no local minima.
若干模型(包括全连接网络和卷积网络)可以使用 5000-6000 张图像的极大批次,几乎完美地拟合许多数据集(包括 CIFAR-100 和 MNIST)。这消除了大部分随机性,但训练仍然成功。图 20.2 显示了四个全连接模型拟合 4000 个带有随机标签的 MNIST-1D 示例,使用全批量(即非随机)梯度下降。没有显式正则化,并且学习率设置为一个很小的常数值 0.0025,以最小化隐式正则化。这里,真实映射 -
从数据到标签的映射没有结构,训练是确定性的,也没有正则化,然而训练误差仍然降至零。这表明这些损失函数可能确实没有局部极小值。

Overparameterization almost certainly is an important factor that contributes to ease of training. It implies that there is a large family of degenerate solutions, so there may always be a direction in which the parameters can be modified to decrease the loss. Sejnowski (2020) suggests that “... the degeneracy of solutions changes the nature of the problem from finding a needle in a haystack to a haystack of needles.”
In practice, networks are frequently overparameterized by one or two orders of magnitude (figure 20.3).
However, data augmentation makes it difficult to make precise statements. Augmentation may increase the data by several orders of magnitude, but these are manipulations of existing examples rather than independent new data points. Moreover, figure 8.10 shows that neural networks can sometimes fit the training data well when there are the same number or fewer parameters than data points. This is presumably due to redundancy in training examples from the same underlying function.
过参数化几乎肯定是使训练更容易的重要因素。这意味着存在一大族退化解,因此可能总存在一个方向,可以修改参数以降低损失。 Sejnowski (2020) 提出:“... 解的退化性将问题的性质从在干草堆中寻找一根针变为在满是针的干草堆中寻找针。”
在实践中,网络经常被过参数化一到两个数量级(图 20.3)。然而,数据增强使得很难做出精确陈述。增强可能会将数据量增加几个数量级,但这些只是对现有样本的操作,而不是独立的新数据点。此外,图 8.10 显示,当参数数量与数据点数量相同或更少时,神经网络有时也能很好地拟合训练数据。这大概是由于来自同一底层函数的训练样本存在冗余。
Several theoretical convergence results show that, under certain circumstances, SGD converges to a global minimum when the network is sufficiently overparameterized. For example, Du et al. (2019b) show that randomly initialized SGD converges to a global minimum for shallow fully connected ReLU networks with a least squares loss with enough hidden units. Similarly, Du et al. (2019a) consider deep, residual, and convolutional networks when the activation function is smooth and Lipschitz. Zou et al. (2020) analyzed the convergence of gradient descent on deep, fully connected networks using a hinge loss. Allen-Zhu et al. (2019) considered deep networks with ReLU functions.
若干理论收敛结果表明,在某些情况下,当神经网络具有足够多的参数(过度参数化)时, SGD 会收敛到全局最小值。例如, Du 等人(2019b)表明,对于具有足够隐藏单元、采用最小二乘损失的浅层全连接 ReLU 神经网络,随机初始化的 SGD 会收敛到全局最小值。类似地, Du 等人(2019a)考虑了当激活函数平滑且满足 Lipschitz 条件时的深层、残差和卷积神经网络。 Zou 等人(2020)分析了梯度下降在采用铰链损失的深层全连接神经网络上的收敛性。 Allen-Zhu 等人(2019)考虑了带有 ReLU 函数的深层神经网络。

If a neural network is sufficiently overparameterized so that it can memorize any dataset of a fixed size, then all stationary points become global minima (Livni et al., 2014; Nguyen & Hein, 2017, 2018).
Other results show that if the network is wide enough, local minima where the loss is higher than the global minimum are rare (see Choromanska et al., 2015; Pascanu et al., 2014; Pennington & Bahri, 2017). Kawaguchi et al. (2019) prove that as a network becomes deeper, wider, or both, the loss at local minima becomes closer to that at the global minimum for squared loss functions.
These theoretical results are intriguing but usually make unrealistic assumptions about the network structure. For example, Du et al. (2019a) show that residual networks converge to zero training loss when the width of the network D (i.e., the number of hidden units) is Ω[I4K2] where I is the amount of training data, and K is the depth of the network. Similarly, Nguyen & Hein (2017) assume that the network’s width is larger than the dataset size, which is unrealistic in most practical scenarios. Overparameterization seems to be important, but theory cannot yet explain empirical fitting performance.
如果神经网络具有足够多的参数(过度参数化),以至于能够记忆任意固定大小的数据集,那么所有驻点都会变成全局最小值(Livni 等人, 2014; Nguyen 和 Hein, 2017, 2018)。其他结果表明,如果网络足够宽,损失高于全局最小值的局部最小值很少见(参见 Choromanska 等人, 2015; Pascanu 等人, 2014; Pennington 和 Bahri, 2017)。 Kawaguchi 等人(2019)证明,随着网络变得更深层、更宽,或两者兼有,对于平方损失函数,局部最小值处的损失会趋近于全局最小值处的损失。
这些理论结果引人入胜,但通常会对网络结构做出不切实际的假设。例如, Du 等人(2019a)证明,当网络宽度 D (即隐藏单元数量)为 Ω[I4K2],其中 I 是训练数据量, K 是网络深度时,残差网络会收敛到零训练损失。类似地, Nguyen 和 Hein (2017)假设网络宽度大于数据集大小,这在大多数实际场景中并不现实。过参数化似乎很重要,但理论尚无法解释经验拟合性能。
The activation function is also known to affect training difficulty. Networks where the activation only changes over a small part of the input range are harder to fit than ReLUs (which vary over half the input range) or Leaky ReLUs (which vary over the full range); For example, sigmoid and tanh nonlinearities (figure 3.13a) have shallow gradients in their tails; where the activation function is near-constant, the training gradient is nearzero, so the mechanism to improve the model is extremely weak.
激活函数也会影响训练难度。激活函数仅在输入范围的一小部分内发生变化的网络,比 ReLU (在输入范围的一半内变化)或 Leaky ReLU (在整个输入范围内变化)更难拟合;例如, sigmoid 和 tanh 非线性函数(图 3.13a)在其尾部梯度较平缓;当激活函数几乎恒定时,训练梯度接近零,因此改进模型的机制极其微弱。
Another potential explanation is that Xavier/He initialization sets the parameters to values that are easy to optimize. Of course, for deeper networks, such initialization is necessary to avoid exploding and vanishing gradients, so in a trivial sense, initialization is critical to training success. However, for shallower networks, the initial variance of the
另一种可能的解释是, Xavier/He 初始化将参数设置为易于优化的值。当然,对于更深的网络,这种初始化对于避免梯度爆炸和梯度消失是必要的,因此从一种平凡的意义上说,初始化对训练成功至关重要。然而,对于更浅的网络,初始方差
weights is less important. Liu et al. (2023c) trained a 3-layer fully connected network with 200 hidden units per layer on 1000 MNIST data points. They found that more iterations were required to fit the training data as the variance increased from that proposed by He (figure 20.4), but this did not ultimately impede fitting. Hence, initialization doesn’t shed much light on why fitting neural networks is easy, although exploding/vanishing gradients do reveal initializations that make training difficult with finite precision arithmetic.
权重不那么重要。 Liu 等人(2023c)在 1000 个 MNIST 数据点上训练了一个每层有 200 个隐藏单元的 3 层全连接网络。他们发现,随着方差从 He 提出的值增大(图 20.4),需要更多迭代次数来拟合训练数据,但这最终并未阻碍拟合。因此,初始化并不能很好地解释为什么拟合神经网络很容易,尽管梯度爆炸 / 梯度消失确实揭示了在有限精度算术下会使训练变得困难的初始化。

Neural networks are harder to fit when the depth becomes very large due to exploding and vanishing gradients (figure 7.7) and shattered gradients (figure 11.3).
However, these are (arguably) practical numerical issues.
There is no definitive evidence that the underlying loss function is fundamentally more or less convex as the network depth increases. Figure 20.2 does show that for MNIST data with randomized labels and He initialization, deeper networks train in fewer iterations. However, this might be because either (i) the gradients in deeper networks are steeper or (ii) He initialization just starts wider, shallower networks further away from the optimal parameters.
当深度变得非常大时,由于梯度爆炸和梯度消失(图 7.7)以及梯度破碎(图 11.3),神经网络更难拟合。然而,这些(可以说)是实际的数值问题。没有确凿证据表明,随着网络深度增加,底层损失函数从根本上变得更凸或更不凸。图 20.2 确实显示,对于带有随机化标签和 He 初始化的 MNIST 数据,更深的网络在更少的迭代次数内完成训练。然而,这可能是因为 (i) 更深网络中的梯度更陡峭,或者 (ii) He 初始化只是让更宽、更浅的网络从离最优参数更远的地方开始。
Frankle & Carbin (2019) show that for small networks like VGG, you can get the same or better performance if you (i) train the network, (ii) prune the weights with the smallest magnitudes and (iii) retrain from the same initial weights. This does not work if the weights are randomly re-initialized. They concluded that the original overparameterized network contains small trainable sub-networks, which are sufficient to provide the performance. They term this the lottery ticket hypothesis and denote the sub-networks as winning tickets. This suggests that the effective number of sub-networks may have a key role to play in fitting. This (perhaps) varies with the network depth for a fixed parameter count, but a precise characterization of this idea is lacking.
Frankle 和 Carbin (2019) 表明,对于像 VGG 这样的小型网络,如果你 (i) 训练网络, (ii) 剪去绝对值最小的权重,并 (iii) 从相同的初始权重重新训练,就可以获得相同或更好的性能。如果随机重新初始化权重,则此方法不起作用。他们得出结论,原始的过参数化网络包含小型可训练子网络,这些子网络足以提供性能。他们将此称为彩票假说,并将这些子网络称为中奖彩票。这表明,子网络的有效数量可能在拟合中发挥关键作用。在参数数量固定的情况下,这(或许)会随网络深度而变化,但缺乏对这一思想的精确刻画。
The previous section discussed factors that contribute to the ease with which neural networks can be trained. The number of parameters (degree of overparameterization) and
the choice of activation function are both important. Surprisingly, the choice of dataset, the randomness of the fitting algorithm, and the use of regularization don’t seem important. There is no definitive evidence that (for a fixed parameter count) the depth of the network matters (other than numerical problems due to exploding/vanishing/shattered gradients). This section tackles the same topic from a different angle by considering the empirical properties of loss functions. Most of this evidence comes from fully connected networks and CNNs; loss functions of transformer networks are less well understood.
上一节讨论了影响神经网络训练难易程度的因素。参数数量(过参数化程度)以及
激活函数的选择都很重要。令人惊讶的是,数据集的选择、拟合算法的随机性,以及正则化的使用似乎并不重要。没有确凿证据表明(在参数数量固定的情况下)网络深度很重要(除了由梯度爆炸 / 消失 / 破碎导致的数值问题)。本节从另一个角度探讨同一主题,考察损失函数的经验特性。大多数证据来自全连接网络和 CNN; Transformer 网络的损失函数尚不太清楚。
We expect loss functions for deep networks to have a large family of equivalent global minima. In fully connected networks, the hidden units at each layer and their associated weights can be permuted without changing the output. In convolutional networks, permuting the channels and convolution kernels appropriately doesn’t change the output. We can multiply the weight before any ReLU function and divide the weight after by a positive number without changing the output. Using BatchNorm induces another set of redundancies because the mean and variance of each hidden unit or channel are reset.
The above modifications all produce the same output for every input. However, the global minimum only depends on the output at the training data points. In overparameterized networks, there will also be families of solutions that behave identically at the data points but differently between them. All of these are also global minima.
我们预期深度网络的损失函数具有一大族等价的全局最小值。在全连接网络中,每一层的隐藏单元及其相关权重可以被置换而不改变输出。在卷积网络中,适当置换通道和卷积核不会改变输出。我们可以将任意 ReLU 函数之前的权重乘以某个正数,并将之后的权重除以该正数,而不改变输出。使用 BatchNorm 会引入另一组冗余,因为每个隐藏单元或通道的均值和方差会被重置。
上述修改对每个输入都产生相同的输出。然而,全局最小值仅取决于训练数据点处的输出。在过参数化网络中,还会存在在数据点处表现相同、但在数据点之间表现不同的解族。这些也都是全局最小值。
Goodfellow et al. (2015b) considered a straight line between the initial parameters and the final values.
They show that the loss function along this line usually decreases monotonically (except for a small bump near the start sometimes). This phenomenon is observed for several different types of networks and activation functions (figure 20.5a).
Goodfellow 等人(2015b)考虑了初始参数与最终值之间的直线。他们表明,损失函数沿这条线通常会单调下降(有时在起点附近有一个小的凸起)。这一现象在多种不同的网络和激活函数中均有观察到(图 20.5a)。
Of course, real optimization trajectories do not proceed in a straight line. However, Li et al. (2018b) find that they do lie in low-dimensional subspaces. They attribute this to the existence of large, nearly convex regions in the loss landscape that capture the trajectory early on and funnel it in a few important directions. Surprisingly, Li et al. (2018a) showed that networks still train well if optimization is constrained to lie in a random low-dimensional subspace (figure 20.6).
Li & Liang (2018) show that the relative change in the parameters during training decreases as network width increases; for larger widths, the parameters start at smaller values, change by a smaller proportion of those values, and converge in fewer steps.
当然,真实的优化轨迹并非沿直线进行。然而, Li 等(2018b)发现,它们确实位于低维子空间中。他们将此归因于损失景观中存在较大的近似凸区域,这些区域在早期捕获轨迹,并将其引导到少数重要方向。令人惊讶的是, Li 等(2018a)表明,即使优化被约束在随机低维子空间中,网络仍能很好地训练(图 20.6)。
Li 和 Liang (2018)表明,随着网络宽度增加,训练期间参数的相对变化减小;对于更大的宽度,参数从更小的值开始,变化量占这些值的比例更小,并在更少的步数内收敛。
Goodfellow et al. (2015b) examined the loss function along a straight line between two minima that were found independently. They saw a pronounced increase in the loss be-
Goodfellow 等人(2015b)考察了两个独立找到的极小值之间连线上的损失函数。他们观察到损失显著增加 ——

tween them (figure 20.5b); good minima are not generally linearly connected. However, Frankle et al. (2020) showed that this increase vanishes if the networks are identically trained initially and later allowed to diverge by using different SGD noise and augmentation. This suggests that the solution is constrained early in training and that some families of minima are linearly connected.
它们之间(图 20.5b);好的极小值通常不是线性连通的。然而, Frankle 等人(2020)表明,如果网络最初以相同方式训练,随后通过使用不同的 SGD 噪声和数据增强允许其发散,这种损失增加就会消失。这表明解在训练早期就受到约束,并且某些极小值族是线性连通的。

Draxler et al. (2018) found minima with good (but different) performance on the CIFAR-10 dataset. They then showed that it is possible to construct paths from one to the other, where the loss function remains low along this path. They conclude that there is a single connected manifold of low loss (figure 20.7). This seems to be increasingly true as the width and depth of the network increase. Garipov et al. (2018) and Fort & Jastrzębski (2019) present other schemes for connecting minima.
Draxler 等人(2018)在 CIFAR-10 数据集上发现了性能良好(但各不相同)的极小值。随后,他们证明可以构造从一个极小值到另一个极小值的路径,并且在这条路径上损失函数保持较低。他们得出结论:存在一个单一连通的低损失流形(图 20.7)。随着网络宽度和深度的增加,这一趋势似乎越来越明显。 Garipov 等人(2018)以及 Fort 与 Jastrzębski (2019)提出了其他连接极小值的方案。




Random Gaussian functions (in which points are jointly distributed with covariance given by a kernel function of their distance) have an interesting property: for points where the gradient is zero, the fraction of directions where the function curves down becomes smaller when these points occur at lower loss values (see Bahri et al., 2020). Dauphin et al. (2014) searched for saddle points in a neural network loss function and similarly found a correlation between the loss and the number of negative eigenvalues (figure 20.8). Baldi & Hornik (1989) analyzed the error surface of a shallow network and found that there were no local minima but only saddle points. These results suggest that there are few or no bad local minima.
Fort & Scherlis (2019) measured the curvature at random points on a neural network loss surface; they showed that the curvature of the surface is unusually positive when the ℓ2 norm of the weights lies within a certain range (figure 20.9), which they term the Goldilocks zone. He and Xavier initialization fall within this range.
随机高斯函数(其中各点联合分布,协方差由其距离的核函数给出)有一个有趣的性质:对于梯度为零的点,当这些点出现在较低的损失值处时,函数向下弯曲的方向所占比例会变小(参见 Bahri 等, 2020)。 Dauphin 等(2014)在神经网络损失函数中寻找鞍点,并同样发现损失与负特征值数量之间存在相关性(图 20.8)。 Baldi 和 Hornik (1989)分析了浅层网络的误差曲面,发现没有局部极小值而只有鞍点。这些结果表明,很少或没有不良局部极小值。
Fort 和 Scherlis (2019)测量了神经网络损失曲面上随机点的曲率;他们表明,当权重的 ℓ2 范数位于某个范围内时(图 20.9),该曲面的曲率异常为正,他们将其称为金发姑娘区间。 He 初始化和 Xavier 初始化均落在此范围内。
The last two sections considered factors that determine whether the network trains successfully and what is known about neural network loss functions. This section considers factors that determine how well the network generalizes. This complements the discussion of regularization (chapter 9), which explicitly aims to encourage generalization.
前两节探讨了决定网络能否成功训练的因素,以及关于神经网络损失函数的已有认识。本节探讨决定网络泛化能力的因素。这与第 9 章关于正则化的讨论形成补充,后者明确旨在促进泛化。
Since deep networks are usually overparameterized, the details of the training process determine which of the degenerate family of minima the algorithm converges to. Some of these details reliably improve generalization. LeCun et al. (2012) show that SGD generalizes better than full-batch gradient descent. It has been argued that SGD generalizes better than Adam (e.g., Wilson et al., 2017; Keskar & Socher, 2017), but more recent studies suggest that there is little dif-
由于深度网络通常是过参数化的,训练过程的细节决定了算法收敛到退化极小值族中的哪一个。其中一些细节能够可靠地改善泛化。

ference when the hyperparameter search is done carefully (Choi et al., 2019). Keskar et al. (2017) show that deep nets generalize better with smaller batch-size when no other form of regularization is used. It is also well-known that larger learning rates tend to generalize better (e.g., figure 9.5). Jastrzębski et al. (2018), Goyal et al. (2018), and He et al. (2019) argue that the batch size/learning rate ratio is important. He et al. (2019) show a significant correlation between this ratio and the degree of generalization and prove a generalization bound for neural networks, which has a positive correlation with this ratio (figure 20.10).
小,当超参数搜索仔细进行时(Choi 等人, 2019)。 Keskar 等人(2017)表明,在不使用其他形式的正则化时,深度神经网络在较小的批量大小下具有更好的泛化能力。人们也普遍知道,较大的学习率往往具有更好的泛化能力(例如,图 9.5)。 Jastrzębski 等人(2018)、 Goyal 等人(2018)和 He 等人(2019)认为,批量大小 / 学习率比值很重要。 He 等人(2019)表明,该比值与泛化程度之间存在显著相关性,并证明了神经网络的泛化界,该泛化界与该比值呈正相关(图 20.10)。
These observations are aligned with the discovery that SGD implicitly adds regularization terms to the loss function (section 9.2), and their magnitude depends on the learning rate. The trajectory of the parameters is changed by this regularization, and they converge to a part of the loss function that generalizes well.
这些观察结果与以下发现一致: SGD 会隐式地向损失函数添加正则化项(第 9.2 节),且这些项的大小取决于学习率。这种正则化会改变参数的轨迹,使其收敛到损失函数中泛化良好的部分。
There has been speculation dating at least to Hochreiter & Schmidhuber (1997a) that flat minima in the loss function generalize better than sharp minima (figure 20.11). Informally, if the minimum is flatter, then small errors in the estimated parameters are less important. This can also be motivated from various theoretical viewpoints. For example, minimum description length theory suggests models specified by fewer bits generalize better (Rissanen, 1983). For wide minima, the precision needed to store the weights is lower, so they should generalize better.
Flatness can be measured by (i) the size of the connected region around the minimum for which training loss is similar (Hochreiter & Schmidhuber, 1997a), (ii) the secondorder curvature around the minimum (Chaudhari et al., 2019), or (iii) the maximum loss within a neighborhood of the minimum (Keskar et al., 2017). However, caution is required; estimated flatness can be affected by trivial reparameterizations of the network due to the non-negative homogeneity property of the ReLU function (Dinh et al., 2017).
Nonetheless, Keskar et al. (2017) varied the batch size and learning rate and showed that flatness correlates with generalization. Izmailov et al. (2018) average together weights from multiple points in a learning trajectory. This both results in flatter test and training surfaces at the minimum and improves generalization. Other regularization techniques can also be viewed through this lens. For example, averaging model outputs (ensembling) may also make the test loss surface flatter. Kleinberg et al. (2018) showed
至少可以追溯到 Hochreiter & Schmidhuber (1997a) 的一种推测认为,损失函数中的平坦极小值比尖锐极小值泛化得更好(图 20.11)。非正式地说,如果极小值更平坦,则估计参数中的小误差就不那么重要。这也可以从多种理论视角加以支持。例如,最小描述长度理论表明,用更少比特指定的模型泛化能力更好(Rissanen, 1983)。对于宽极小值,存储权重所需的精度更低,因此它们应该泛化得更好。
平坦度可以通过以下方式衡量: (i) 最小值周围训练损失相似的连通区域的大小(Hochreiter & Schmidhuber, 1997a), (ii) 最小值周围的二阶曲率(Chaudhari et al., 2019),或 (iii) 最小值邻域内的最大损失(Keskar et al., 2017)。然而,需要谨慎;由于 ReLU 函数的非负齐次性,网络的平凡重参数化可能会影响估计的平坦度。然而, Keskar 等人(2017)改变了批量大小和学习率,并表明平坦性与泛化相关。 Izmailov 等人(2018)对学习轨迹中多个点的权重进行平均。这既使极小值处的测试和训练曲面更平坦,又改善泛化。其他正则化技术也可以通过这一视角来理解。例如,对模型输出进行平均(集成)也可能使测试损失曲面更平坦。 Kleinberg 等人(2018)表明
that large gradient variance during training helps avoid sharp regions. This may explain why reducing the batch size and adding noise helps generalization.
The above studies consider flatness for a single model and training set. However, sharpness alone is not a good criterion to predict generalization between datasets; when the labels in the CIFAR dataset are randomized (making generalization impossible), there is no commensurate sharpening of the minimum (Neyshabur et al., 2017).
训练期间较大的梯度方差有助于避开尖锐区域。这可能解释了为什么减小批量大小和添加噪声有助于泛化。
上述研究考虑的是单个模型和训练集的平坦度。然而,仅凭尖锐度并不是预测数据集之间泛化的好标准;当 CIFAR 数据集中的标签被随机化(使泛化变得不可能)时,极小值并没有出现相应的尖锐化(Neyshabur 等, 2017)。
The inductive bias of a network is determined by its architecture, and judicious choices of model can drastically improve generalization. Chapter 10 introduced convolutional networks, which are designed to process data on regular grids; they implicitly assume that the input statistics are the same across the input, so they share parameters across position. Similarly, transformers are suited for modeling data that is invariant to permutations, and graph neural networks are suited to data represented on irregular graphs. Matching the architecture to the properties of the data improves generalization over generic, fully connected architectures (see figure 10.8).
神经网络的归纳式偏差由其架构决定,而明智的模型选择可以显著提升泛化。第 10 章介绍了卷积网络,它们被设计用于处理规则网格上的数据;它们隐含地假设输入统计量在整个输入上相同,因此会跨位置共享参数。类似地, Transformer 模型适合建模对排列不变的数据,而图神经网络适合以不规则图表示的数据。使架构与数据属性相匹配,相比通用的全连接架构能够提升泛化(见图 10.8)。
Section 20.3.4 reviewed the finding of Fort & Scherlis (2019) that the curvature of the loss surface is unusually positive when the ℓ2 norm of the weights lies within a certain range. The same authors provided evidence that generalization is also good when the ℓ2 weight norm falls within this Goldilocks zone (figure 20.12). This is perhaps unsurprising. The norm of the weights is (indirectly) related to the Lipschitz constant of the model. If this norm is too small, then the model will not be able to change fast enough to capture the variation in the underlying function. If the norm is too large, then the model will be unnecessarily variable between training points and will not interpolate smoothly.
This finding was used by Liu et al. (2023c) to explain the phenomenon of grokking (Power et al., 2022), in which a sudden improvement in generalization can occur many epochs after the training error is already zero (figure 20.13). It is proposed that grokking occurs when the norm of the weights is initially too large; the training data fits well, but the variation of the model between the data points is large. Over time, implicit or explicit regularization decreases the norm of the weights until they reach the Goldilocks zone, and generalization suddenly improves.
20.3.4 节回顾了 Fort & Scherlis (2019) 的发现:当 ℓ2 权重范数处于某个范围内时,损失曲面的曲率异常为正。同一作者还提供了证据,表明当 ℓ2 权重范数落入这一“金发姑娘区间”(图 20.12)时,泛化也良好。这或许并不令人惊讶。权重范数与模型的 Lipschitz 常数(间接)相关。如果该范数过小,模型将无法足够快地变化以捕捉底层函数的变化。如果该范数过大,模型在训练点之间会产生不必要的波动,并且无法平滑插值。
这一发现被 Liu et al. (2023c) 用于解释顿悟现象(Power et al., 2022):在训练误差已经为零许多轮次之后,泛化可能出现突然改善(图 20.13)。有人提出,当权重范数最初过大时会发生顿悟;模型对训练数据的拟合很好,但在数据点之间的变化很大。随着时间推移,隐式或显式正则化会降低权重范数,直到其达到“金发姑娘区间”,泛化突然改善。
Figure 8.10 showed that generalization performance tends to improve with the degree of overparameterization. When combined with the bias/variance trade-off curve, this results in double descent. The putative explanation for this improvement is that the network has more latitude to become smoother between the training data points when
图 8.10 表明,泛化性能往往随着过参数化程度的提高而改善。将其与偏差 / 方差权衡曲线结合,便会产生双下降。对于这种改善,一种推测性的解释是,网络在训练数据点之间有更充分的余地变得更平滑,当

the model is overparameterized.
It follows that the norm of the weights can also be used to explain double descent. The norm of the weights increases when the number of parameters is similar to the number of data points (as the model contorts itself to fit these points exactly), causing generalization to reduce.
As the network becomes wider and the number of weights increases, the overall norm of these weights decreases; the weights are initialized with a variance that is inversely proportional to the width (i.e., with He or Glorot initialization), and the weights need not change as drastically to fit the data well.
模型过参数化。
由此可知,权重的范数也可以用来解释双下降。当参数数量与数据点数量相近时,权重的范数会增大(因为模型会扭曲自身以完全拟合这些数据点),从而导致泛化能力下降。随着网络变得更宽且权重数量增加,这些权重的整体范数会减小;权重以与宽度成反比的方差进行初始化(即采用 He 或 Glorot 初始化),并且权重不需要像之前那样剧烈变化就能很好地拟合数据。
Until this point, we have discussed how models generalize to new data that is drawn from the same distribution as the training data. This is a reasonable assumption for experimentation. However, systems deployed in the real world may encounter unexpected data due to noise, changes in the data statistics over time, or deliberate attacks. Of course, it is harder to make definite statements about this scenario, but D’Amour et al. (2020) show that the variability of identical models trained with different seeds on corrupted data can be enormous and unpredictable. Goodfellow et al. (2015a) showed that deep learning models are susceptible to adver- sarial attacks. Consider perturbing an image that is correctly classified by the network as “dog” so that the probability of the correct class decreases as fast as possible un-
到目前为止,我们讨论的是模型如何泛化到与训练数据来自相同分布的新数据。对于实验而言,这是一个合理的假设。然而,部署在现实世界中的系统可能会遇到意外数据,原因包括噪声、数据统计量随时间变化或蓄意攻击。当然,对于这种场景,很难给出明确的结论,但 D’Amour et al. (2020) 表明,使用不同种子在损坏数据上训练的相同模型,其变异性可能极大且不可预测。作为“狗”,使正确类别的概率尽可能快地下降,直 -

til the class flips. If this image is now classified as an airplane, you might expect the perturbed image to look like a cross between a dog and an airplane. However, in practice, the perturbed image looks almost indistinguishable from the original dog image (figure 20.14).
到类别翻转。如果这张图像现在被分类为飞机,你可能会预期扰动后的图像看起来像狗和飞机的混合体。然而,在实践中,扰动后的图像与原始狗图像几乎无法区分(图 20.14)。

The conclusion is that there are positions that are close to but not on the data manifold that are misclassified. These are known as adversarial examples. Their existence is surprising; how can such a small change to the network input make such a drastic change to the output? The best current explanation is that adversarial examples aren’t due to a lack of robustness to data from outside the training data manifold. Instead, they are exploiting a source of information that is in the training distribution but which has a small norm and is imperceptible to humans (Ilyas et al., 2019).
结论是,存在一些靠近但不在数据流形上的位置,它们会被错误分类。这些被称为对抗样本。它们的存在令人惊讶;对网络输入如此微小的变化,怎能导致输出如此剧烈的变化?目前最好的解释是,对抗样本并非由于对训练数据流形之外的数据缺乏鲁棒性。相反,它们利用的是训练分布中一种范数很小、人类无法察觉的信息源(Ilyas 等人, 2019)。
Section 20.4 argued that models generalize better when over-parameterized.
Indeed, there are almost no examples of state-of-the-art test performance on complex datasets where the model has significantly fewer parameters than there were training data points.
However, section 20.2 reviewed evidence that training becomes easier as the number of parameters increases. Hence, it’s not clear if some fundamental property of smaller models prevents them from performing as well or whether the training algorithms can’t find good solutions for small models. Pruning and distilling are two methods for reducing the size of trained models. This section examines whether these methods can produce underparameterized models which retain the performance of overparameterized ones.
第 20.4 节认为,模型在过参数化时泛化能力更强。事实上,在复杂数据集上取得最先进测试性能的例子中,几乎没有模型的参数数量显著少于训练数据点数量。
然而,第 20.2 节回顾了随着参数数量增加,训练会变得更轻松这一证据。因此,目前尚不清楚是小模型的某些根本性质使其无法表现同样好,还是训练算法无法为小模型找到好的解。剪枝和蒸馏是两种减小已训练模型规模的方法。本节考察这些方法能否产生保留过参数化模型性能的欠参数化模型。
Pruning trained models reduces their size and hence storage requirements (figure 20.15). The simplest approach is to remove individual weights. This can be done based on the second derivatives of the loss function (LeCun et al., 1990; Hassibi & Stork, 1993) or

(more practically) based on the absolute value of the weight (Han et al., 2016, 2015). Other work prunes hidden units (Zhou et al., 2016a; Alvarez & Salzmann, 2016), channels in convolutional networks (Li et al., 2017a; Luo et al., 2017b; He et al., 2017; Liu et al., 2019a), or entire layers in residual nets (Huang & Wang, 2018). Often, the network is fine-tuned after pruning, and sometimes this process is repeated.
For example, Han et al. (2016) maintained good performance for the VGG network on ImageNet classification when 8% of the weights were retained.
This significantly decreases the model size but isn’t enough to show that overparameterization is not required; the VGG network has ∼ 100 times as many parameters as there are ImageNet training data (disregarding augmentation).
(更实用的做法是)基于权重的绝对值(Han 等, 2016, 2015)。其他工作会剪枝隐藏单元(Zhou 等, 2016a; Alvarez 与 Salzmann, 2016)、卷积网络中的通道(Li 等, 2017a; Luo 等, 2017b; He 等, 2017; Liu 等, 2019a),或残差网络中的整个层(Huang 与 Wang, 2018)。通常,剪枝后会对网络进行微调,有时还会重复这一过程。
例如, Han 等人(2016)在保留 8% 的权重时,仍使 VGG 网络在 ImageNet 分类上保持良好性能。这显著减小了模型大小,但不足以证明不需要过参数化; VGG 网络的参数数量是 ImageNet 训练数据的 ∼ 100 倍(不考虑数据增强)。
Pruning is a form of architecture search. In their work on lottery tickets (see section 20.2.7), Frankle & Carbin (2019) (i) trained a network, (ii) pruned the weights with the smallest magnitudes, and (iii) retrained the remaining network from the same initial weights. By iterating this procedure, they reduced the size of the VGG-19 network (originally 138 million parameters) by 98.5% on the CIFAR-10 database (60,000 examples) while maintaining good performance. For ResNet-50 (25.6 million parameters), they reduced the parameters by 80% without reducing the performance on ImageNet (1.28 million examples). These demonstrations are impressive but (disregarding data augmentation) these networks are still over-parameterized after pruning.
剪枝是一种架构搜索形式。在他们关于彩票假说的工作中(见 20.2.7 节), Frankle 和 Carbin (2019) (i) 训练了一个网络, (ii) 剪去了绝对值最小的权重,并且 (iii) 从相同的初始权重重新训练剩余网络。通过迭代这一过程,他们将 VGG-19 网络(最初有 1.38 亿个参数)的规模缩小了 98.5%,同时保持良好性能。对于 Res Net-50 (2560 万个参数),他们减少了 80% 的参数,而没有降低在 ImageNet (128 万个样本)上的性能。这些演示令人印象深刻,但(不考虑数据增强)这些网络在剪枝后仍然是过参数化的。
The parameters can also be reduced by training a smaller network (the student) to replicate the performance of a larger one (the teacher). This is known as knowledge distillation and dates back to at least Buciluǎ et al. (2006). Hinton et al. (2015) showed that the pattern of information across the output classes is important and trained a smaller network to approximate the pre-softmax logits of the larger one (figure 20.16).
参数数量也可以通过训练一个较小的网络(学生)来复制一个较大网络(教师)的性能而减少。这被称为知识蒸馏,至少可追溯到 Buciluǎ 等人(2006)。 Hinton 等人(2015)指出,输出类别之间的信息分布模式很重要,并训练了一个较小的网络来近似较大网络的 Softmax 前的逻辑值(图 20.16)。

Zagoruyko & Komodakis (2017) further encouraged the spatial maps of the activations of the student network to be similar to the teacher network at various points. They use this attention transfer method to approximate the performance of a 34-layer residual network (∼ 63 million parameters) with an 18-layer residual network (∼ 11 million parameters) on the ImageNet classification task. However, this is still larger than the number of training examples (∼ 1 million images). Modern methods (e.g. Chen et al., 2021a) can improve on this result, but distillation has not yet provided convincing evidence that under-parameterized models can perform well.
Zagoruyko 和 Komodakis (2017)进一步鼓励学生网络在不同位置处的激活值空间特征图与教师网络相似。他们使用这种注意力迁移方法,在 ImageNet 分类任务上,用 18 层残差网络(∼ 11 百万个参数)来逼近 34 层残差网络(∼ 63 百万个参数)的性能。然而,这仍然大于训练样本数量(∼ 1 百万张图像)。现代方法(例如 Chen 等人, 2021a)可以改进这一结果,但蒸馏尚未提供令人信服的证据,证明欠参数化模型能够表现良好。
Current evidence suggests that overparameterization is needed for generalization — at least for the size and complexity of datasets that are currently used.
There are no demonstrations of state-of-the-art performance on complex datasets where there are significantly fewer parameters than training examples. Attempts to reduce model size by pruning or distilling trained networks have not changed this picture. Moreover, recent theory shows that there is a trade-off between the model’s Lipschitz constant and overparameterization; Bubeck & Sellke (2021) proved that in D dimensions,
smooth interpolation requires D times more parameters than mere interpolation. They argue that current models for large datasets (e.g., ImageNet) aren’t overparameterized enough; increasing model capacity further may be key to improving performance.
现有证据表明,过参数化是泛化所必需的 —— 至少对于当前使用的数据集的规模和复杂度而言。目前尚无在复杂数据集上实现当前最佳性能且参数数量显著少于训练样本的实例。通过剪枝或蒸馏已训练网络来减小模型规模的尝试并未改变这一局面。此外,近期理论表明,模型的利普希茨常数与过参数化之间存在权衡; Bubeck 和 Sellke (2021)证明,在 D 维中,
Chapter 3 discussed the universal approximation theorem.
This states that shallow neural networks can approximate any function to arbitrary accuracy given enough hidden units. This raises the obvious question of whether networks need to be deep.
第 3 章讨论了通用近似定理。该定理指出,只要有足够多的隐藏单元,浅层神经网络就能以任意精度逼近任意函数。这引出了一个显而易见的问题:网络是否需要很深。
First, let’s consider the evidence that depth is required. Historically, there has been a definite correlation between performance and depth. For example, performance on the ImageNet benchmark initially improved as a function of network depth until training became difficult.
Subsequently, residual connections and batch normalization (chapter 11) allowed training of deeper networks with commensurate gains in performance. At the time of writing, almost all state-of-the-art applications, including image classification (e.g., the vision transformer), text generation (e.g., GPT3), and text-guided image synthesis (e.g., DALL · E-2), are based on deep networks with tens or hundreds of layers.
首先,让我们考虑深度确实必需的这一证据。历史上,性能与深度之间存在明确的相关性。例如,在 ImageNet 基准测试上,性能最初随网络深度的增加而提升,直到训练变得困难。随后,残差连接和批归一化(第 11 章)使得训练更深的网络成为可能,并带来了相应的性能提升。截至写作时,几乎所有最先进的应用,包括图像分类(例如视觉 Transformer)、文本生成(例如 GPT3)和文本引导的图像合成(例如 DALL · E-2),都基于拥有数十层或数百层的深度网络。
Despite this trend, there have been efforts to use shallower networks. Zagoruyko & Komodakis (2016) constructed shallower but wider residual neural networks and achieved similar performance to ResNet. More recently, Goyal et al. (2021) constructed a network that used parallel convolutional channels and achieved performance similar to deeper networks with only 12 layers. Furthermore, Veit et al. (2016) showed that it is predominantly shorter paths of 5–17 layers that drive performance in residual networks.
Nonetheless, the balance of evidence suggests that depth is critical; even the shallowest networks with good image classification performance require >10 layers. However, there is no definitive explanation for why. Three possible explanations are that (i) deep networks can represent more complex functions than shallow ones, (ii) deep networks are easier to train, and (iii) deep networks impose better inductive biases.
尽管有这一趋势,人们也在尝试使用更浅的网络。 Zagoruyko 与 Komodakis (2016)构建了更浅但更宽的残差神经网络,并取得了与 ResNet 相似的性能。最近, Goyal 等人(2021)构建了一种使用并行卷积通道的网络,仅用 12 层就取得了与更深网络相似的性能。此外, Veit 等人(2016)表明,在残差网络中,主要是 5–17 层的较短路径在驱动性能。
尽管如此,证据的总体倾向表明,深度至关重要;即便是具有良好图像分类性能的最浅网络也需要 >10 层。不过,对于其原因尚无定论。可能的解释有三点: (i) 深度网络能够表示比浅层网络更复杂的函数, (ii) 深度网络更容易训练,以及 (iii) 深度网络施加了更好的归纳式偏差。
Chapter 4 showed that deep networks make functions with many more linear regions than shallow ones for the same parameter count. We also saw that “pathological” functions have been identified that require exponentially more hidden units to model with a shallow network than a deep one (e.g., Eldan & Shamir, 2016; Telgarsky, 2016). Indeed Liang & Srikant (2016) found quite general families of functions that are more efficiently modeled by deep networks.
However, Nye & Saxe (2018) found that some of these functions cannot easily be fit by deep networks in practice. Moreover, there is little evidence that the real-world functions that we are approximating have these pathological properties.
第 4 章表明,在相同的参数数量下,深层网络能够构造出比浅层网络具有多得多的线性区域的函数。我们还看到,已有研究识别出一些“病态”函数,若用浅层网络而非深层网络对其进行建模,需要呈指数级更多的隐藏单元(例如, Eldan & Shamir, 2016; Telgarsky, 2016)。事实上, Liang & Srikant (2016)发现了一类相当通用的函数,这些函数由深层网络建模更为高效。然而, Nye & Saxe (2018)发现,这些函数中的一些在实践中并不能被深层网络轻松拟合。此外,几乎没有证据表明我们试图逼近的现实世界函数具有这些病态性质。
An alternative explanation is that shallow networks with a practical number of hidden units could support state-of-the-art performance, but it is just difficult to find a good solution that both fits the training data well and interpolates sensibly.
One way to show this is to distill successful deep networks into shallower (but wider) student models and see if performance can be maintained.
Urban et al. (2017) distilled an ensemble of 16 convolutional networks for image classification on the CIFAR-10 dataset into student models of varying depths. They found that shallow networks could not replicate the performance of the deeper teacher and that the student performance increased as a function of depth for a constant parameter budget.
另一种解释是,隐藏单元数量处于实际可行范围内的浅层网络也许能够支持最先进的性能,但只是很难找到一个既能很好地拟合训练数据、又能合理插值的良好解。
一种证明方法是将成功的深度网络蒸馏为更浅(但更宽)的学生模型,并观察性能是否能够保持。 Urban 等人(2017)将用于 CIFAR-10 数据集图像分类的 16 个卷积网络的集成蒸馏为不同深度的学生模型。他们发现,浅层网络无法复现更深层教师模型的性能,并且在参数预算恒定的情况下,学生模型的性能随深度增加而提升。
Most current models rely on convolutional blocks or transformers. These networks share parameters for local regions of the input data, and often they gradually integrate this information across the whole input.
These constraints mean that the functions that these networks can represent are not general. One explanation for the supremacy of deep networks, then, is that these constraints have a good inductive bias and that it is difficult to induce shallow networks to obey these constraints.
当前大多数模型依赖卷积块或 Transformer。这些网络在输入数据的局部区域共享参数,并常常逐步将信息整合到整个输入中。这些约束意味着这些网络所能表示的函数并不通用。因此,对深度网络优势的一种解释是,这些约束具有良好的归纳式偏差,而很难诱导浅层网络遵循这些约束。
Multi-layer convolutional architectures seem to be inherently helpful, even without training. Ulyanov et al. (2018) demonstrated that the structure of an untrained CNN can be used as a prior in low-level tasks such as denoising and super-resolution. Frankle et al. (2021) achieved good performance in image classification by initializing the kernels randomly, fixing their values, and just training the batch normalization offset and scaling factors. Zhang et al. (2017a) show that features from randomly initialized convolutional filters can support subsequent image classification using a kernel model.
Additional evidence that convolutional networks provide a useful inductive bias comes from Urban et al. (2017), who attempted to distill convolutional networks into shallower networks. They found that distilling into convolutional architectures systematically worked better than distilling into fully connected networks. This suggests that the convolutional architecture has some inherent advantages. Since the sequential local processing of convolutional networks cannot easily be replicated by shallower networks, this argues that depth is indeed important.
多层卷积架构似乎天生有帮助,即使不经过训练也是如此。 Ulyanov 等(2018)证明,未经训练的 CNN 的结构可以作为先验,用于去噪和超分辨率等低层任务。 Frankle 等(2021)通过将卷积核随机初始化、固定其值,并仅训练批归一化的偏移和缩放因子,在图像分类中取得了良好性能。 Zhang 等(2017a)表明,随机初始化的卷积滤波器所产生的特征可以借助核模型支持后续图像分类。
卷积网络能够提供有用的归纳式偏差的额外证据来自 Urban 等(2017),他们试图将卷积网络蒸馏为更浅的网络。他们发现,蒸馏到卷积架构比蒸馏到全连接网络更系统性地有效。这表明卷积架构具有一些固有优势。由于卷积网络的顺序局部处理难以被更浅的网络复制,因此这论证了深度确实重要。
This chapter has made the case that the success of deep learning is surprising. We discussed the challenges of optimizing high-dimensional loss functions and argued that overparameterization and the choice of activation function are the two most important factors that make this tractable in deep networks. We saw that, during training, the parameters move through a low-dimensional subspace to one of a family of connected
本章论证了深度学习的成功令人惊讶。我们讨论了优化高维损失函数的挑战,并认为过参数化和激活函数的选择是使这一问题在深度网络中变得可处理的两个最重要的因素。我们看到,在训练过程中,参数穿过一个低维子空间,移动到一族相互连通的
global minima and that local minima are not apparent.
Generalization of neural networks also improves with overparameterization, although other factors, such as the flatness of the minimum and the inductive bias of the architecture, are also important. It appears that both a large number of parameters and multiple network layers are required for good generalization, although we do not yet know why.
Many questions remain unanswered. We do not currently have any prescriptive theory that will allow us to predict the circumstances in which training and generalization will succeed or fail. We do not know the limits of learning in deep networks or whether much more efficient models are possible. We do not know if there are parameters that would generalize better within the same model. The study of deep learning is still driven by empirical demonstrations. These are undeniably impressive, but they are not yet matched by our understanding of deep learning mechanisms.
全局极小值,并且局部极小值并不明显。
神经网络的泛化也随着过参数化而改善,尽管其他因素也很重要,例如极小值的平坦度和架构的归纳式偏差。看起来,良好的泛化既需要大量参数,也需要多个网络层,尽管我们尚不知道原因。
许多问题仍未得到解答。我们目前尚无任何规范性理论,能够预测训练和泛化在何种情况下会成功或失败。我们不知道深度网络的学习极限,也不知道是否可能建立更高效的模型。我们不知道在同一模型中是否存在泛化更好的参数。深度学习的研究仍然由实证演示驱动。这些成果不可否认令人印象深刻,但我们对深度学习机制的理解尚未与之匹配。