学习资料 理解深度学习 第 3 章 · 浅层神经网络
学 习 资 料 · 中 英 对 照

第 3 章 · 浅层神经网络

Understanding Deep Learning — Shallow neural networks

浅层神经网络
Shallow neural networks

Chapter 2 introduced supervised learning using 1D linear regression. However, this model can only describe the input/output relationship as a line. This chapter introduces shallow neural networks. These describe piecewise linear functions and are expressive enough to approximate arbitrarily complex relationships between multi-dimensional inputs and outputs.

第 2 章介绍了使用一维线性回归的监督学习。然而,该模型只能将输入 / 输出关系描述为一条直线。本章介绍浅层神经网络。这些神经网络描述分段线性函数,并且具有足够的表达能力,可以近似多维输入与输出之间任意复杂的关系。

3.1 神经网络示例
3.1 Neural network example

Shallow neural networks are functions y = f[ x , ϕ] with parameters ϕ that map multivariate inputs x to multivariate outputs y. We defer a full definition until section 3.4 and introduce the main ideas using an example network f[x, ϕ] that maps a scalar input x to a scalar output y and has ten parameters ϕ = {ϕ0, ϕ1, ϕ2, ϕ3, θ10, θ11, θ20, θ21, θ30, θ31}:

We can break down this calculation into three parts: first, we compute three linear functions of the input data (θ10 + θ11x, θ20 + θ21x, and θ30 + θ31x). Second, we pass the three results through an activationfunction a[•]. Finally, we weight the three resulting activations with ϕ1, ϕ2, and ϕ3, sum them, and add an offset ϕ0.

浅层神经网络是函数 y = f[ x ϕ],具有参数 ϕ,可将多元输入 x 映射到多元输出 y。我们将完整定义推迟到 3.4 节,并使用一个示例网络 f[x, ϕ] 来介绍主要思想,该网络将标量输

我们可以将此计算拆分为三个部分:首先,计算输入数据的三个线性函数(θ10 + θ11x、 θ20 + θ21x 和 θ30 + θ31x)。其次,将三个结果通过一个激活函数 a[•]。最后,我们使用权重 ϕ1, ϕ2 和 ϕ3 对三个所得激活值进行加权,求和,并加上一个偏置 ϕ0。

To complete the description, we must define the activation function a[•]. There are many possibilities, but the most common choice is the rectified linear unit or ReLU:

This returns the input when it is positive and zero otherwise (figure 3.1). It is probably not obvious which family of input/output relations is represented by equation 3.1. Nonetheless, the ideas from the previous chapter are all applicable. Equation 3.1 represents a family of functions where the particular member of the family

depends on the ten parameters in ϕ. If we know these parameters, we can perform inference (predict y) by evaluating the equation for a given input x. Given a training dataset{xi, yi}I

它会在输入为正时回报输入,否则回报零(图 3.1)。公式 3.1 所表示的是哪一族输入 / 输出关系可能并不显而易见。尽管如此,前一章中的思想都仍然适用。公式 3.1 表示一个函数族,而该函数族中的具体成员取决于 ϕ 中的十个参数。如果已知这些参数,我们可以通过对给定输入 x 计算该方程来执行推断(预测 y)。给定训练数据集 {xi, yi}I

图 3.2 由公式 3.1 定义的函数族。 a–c)为十个参数 ϕ 的三种不同选择所对应的函数。在每种情况下,输入 / 输出关系都是分段线性的。然而,转折点的位
图 3.2 由公式 3.1 定义的函数族。 a–c)为十个参数 ϕ 的三种不同选择所对应的函数。在每种情况下,输入 / 输出关系都是分段线性的。然而,转折点的位置、它们之间线性区域的斜率以及整体高度各不相同。Figure 3.2 Family of functions defined by equation 3.1. a–c) Functions for three different choices of the ten parameters ϕ. In each case, the input/output relation is piecewise linear. However, the positions of the joints, the slopes of the linear regions between them, and the overall height vary.

i=1, we can define a least squares loss function L[ϕ] and use this to measure how effectively the model describes this dataset for any given parameter values ϕ. To train the model, we search for the values ˆϕ that minimize this loss.

i=1,我们可以定义最小二乘损失函数 L[ϕ],并使用它来衡量对于任意给定的参数值 ϕ,模型描述该数据集的有效性。 ˆ 为了训练模型,我们搜索使该损失最小化的值 ϕ。

3.1.1 神经网络直觉
3.1.1 Neural network intuition

In fact, equation 3.1 represents a family of continuous piecewise linear functions (figure 3.2) with up to four linear regions. We now break down equation 3.1 and show why it describes this family. To make this easier to understand, we split the function into two parts. First, we introduce the intermediate quantities: where we refer to h1, h2, and h3 as hiddenunits. Second, we compute the output by combining these hidden units with a linear function: 1

事实上,公式 3.1 表示一族连续的分段线性函数(图 3.2),最多包含四个线性区域。我们现在拆解公式 3.1,并说明为什么它描述了这一族函数。为了便于理解,我们将函数拆分为两部分。首先,我们引入中间量:其中,我们将 h1、 h2 和 h3 称为隐藏单元。其次,我们通过将这些隐藏单元与一个线性函数相结合来计算输出: 1

Figure 3.3 shows the flow of computation that creates the function in figure 3.2a. Each hidden unit contains a linear function θ•0+ θ•1x of the input, and that line is clipped by the ReLU function a[•] below zero. The positions where the three lines cross zero become the three “joints” in the final output. The three clipped lines are then weighted by ϕ1, ϕ2, and ϕ3, respectively. Finally, the offset ϕ0 is added, which controls the overall height of the final function.

图 3.3 展示了生成图 3.2a 中函数的计算流程。每个隐藏单元包含一个关于输入的线性函数 θ•0+ θ•1x,该直线会被 ReLU 函数 a[•] 在零以下截断。三条直线与零相交的位置成为最终输出中的三个“关节”。这三条截断后的直线随后分别以权重 ϕ1、 ϕ2 和 ϕ3 进行加权。最后加上偏移量 ϕ0,它控制最终函数的整体高度。

Each linear region in figure 3.3j corresponds to a different activation pattern in the hidden units. When a unit is clipped, we refer to it as inactive, and when it is not clipped, we refer to it as active. For example, the shaded region receives contributions from h1 and h3 (which are active) but not from h2 (which is inactive). The slope of each linear region is determined by the original slopes θ•1 of the active inputs for this region and the weights ϕ• that were subsequently applied. For example, the slope in the shaded region (see problem 3.3) is θ11ϕ1 + θ31ϕ3, where the first term is the slope in panel (g) and the second term is the slope in panel (i).

Each hidden unit contributes one “joint” to the function, so with three hidden units, there can be four linear regions. However, only three of the slopes of these regions are independent; the fourth is either zero (if all the hidden units are inactive in this region) or is a sum of slopes from the other regions.

图 3.3j 中的每个线性区域都对应隐藏单元中一种不同的激活模式。当一个单元被截断时,我们称其为不活跃;当它未被截断时,我们称其为活跃。例如,阴影区域接收来自 h1 和 h3 (它们是活跃的)的贡献,但不接收来自 h2 (它是不活跃的)的贡献。每个线性区域的斜率由该区域中活跃输入的原始斜率 θ•1 以及随后施加的权重 ϕ• 决定。例如,阴影区域的斜率(见习题 3.3)为 θ11ϕ1 + θ31ϕ3,其中第一项是面板 (g) 中的斜率,第二项是面板 (i) 中的斜率。每个隐藏单元为该函数贡献一个“关节”,因此有三个隐藏单元时,

或者是其他区域斜率的总和。

3.1.2 描绘神经网络
3.1.2 Depicting neural networks

We have been discussing a neural network with one input, one output, and three hidden units. We visualize this network in figure 3.4a. The input is on the left, the hidden units are in the middle, and the output is on the right. Each connection represents one of the ten parameters. To simplify this representation, we do not typically draw the intercept parameters, so this network is usually depicted as in figure 3.4b.

我们一直在讨论一个具有一个输入、一个输出和三个隐藏单元的神经网络。我们在图 3.4a 中对该网络进行可视化。输入在左侧,隐藏单元在中间,输出在右侧。每条连接代表十个参数中的一个。为简化表示,我们通常不绘制截距参数,因此该网络通常如图 3.4b 所示。

图 3.3 图 3.2a 中函数的计算过程。 a–c) 输入 x 经过三个线性函数,每个函数具有不同的 y 轴截距  θ•0 和斜率  θ•1。 d–f) 每条
图 3.3 图 3.2a 中函数的计算过程。 a–c) 输入 x 经过三个线性函数,每个函数具有不同的 y 轴截距 θ•0 和斜率 θ•1。 d–f) 每条线都经过 ReLU 激活函数,该函数将负值裁剪为零。 g–i) 然后分别用权重 ϕ1、 ϕ2 和 ϕ3 对三条裁剪后的线进行加权(缩放)。 j) 最后,将裁剪并加权后的函数相加,并添加一个控制高度的偏移量 ϕ0。四个线性区域中的每一个都对应隐藏单元中不同的激活模式。在阴影区域中, h2 处于非激活状态(被裁剪),但 h1 和 h3 均处于激活状态。(交互式图)Figure 3.3 Computation for function in figure 3.2a. a–c) The input x is passed through three linear functions, each with a different y-intercept θ•0 and slope θ•1. d–f) Each line is passed through the ReLU activation function, which clips negative values to zero. g–i) The three clipped lines are then weighted (scaled) by ϕ1, ϕ2, and ϕ3, respectively. j) Finally, the clipped and weighted functions are summed, and an offset ϕ0 that controls the height is added. Each of the four linear regions corresponds to a different activation pattern in the hidden units. In the shaded region, h2 is inactive (clipped), but h1 and h3 are both active. (Interactive figure)
图 3.4 神经网络图示。 a) 输入 x 位于左侧,隐藏单元 h1, h2 和 h3 位于中间,输出 y 位于右侧。计算从左向右流动。输入用于计算隐藏单元,隐
图 3.4 神经网络图示。 a) 输入 x 位于左侧,隐藏单元 h1, h2 和 h3 位于中间,输出 y 位于右侧。计算从左向右流动。输入用于计算隐藏单元,隐藏单元再组合成输出。十条箭头中的每一条都代表一个参数(截距为橙色,斜率为黑色)。每个参数乘以其源节点,并将结果加到目标节点。例如,将参数 ϕ1 乘以源 h1,并加到 y。我们引入包含 1 的额外节点(橙色圆圈),以将偏置纳入此方案,因此将 ϕ0 乘以 1 (没有影响)并加到 y。在隐藏单元处应用 ReLU 函数。 b) 更典型的是,省略截距、 ReLU 函数和参数名称;这种更简洁的图示表示相同的网络。Figure 3.4 Depicting neural networks. a) The input x is on the left, the hidden units h1, h2, and h3 in the center, and the output y on the right. Computation flows from left to right. The input is used to compute the hidden units, which are combined to create the output. Each of the ten arrows represents a parameter (intercepts in orange and slopes in black). Each parameter multiplies its source and adds the result to its target. For example, we multiply the parameter ϕ1 by source h1 and add it to y. We introduce additional nodes containing ones (orange circles) to incorporate the offsets into this scheme, so we multiply ϕ0 by one (with no effect) and add it to y. ReLU functions are applied at the hidden units. b) More typically, the intercepts, ReLU functions, and parameter names are omitted; this simpler depiction represents the same network.
3.2 万能逼近定理
3.2 Universal approximation theorem

In the previous section, we introduced an example neural network with one input, one output, ReLU activation functions, and three hidden units. Let’s now generalize this slightly and consider the case with D hidden units where the dth hidden unit is:

and these are combined linearly to create the output:

The number of hidden units in a shallow network is a measure of the network capacity. With ReLU activation functions, the output of a network with D hidden units has at most D joints and so is a piecewise linear function with at most D + 1 linear regions. As we add more hidden units, the model can approximate more complex functions.

Indeed, with enough capacity (hidden units), a shallow network can describe any continuous 1D function defined on a compact subset of the real line to arbitrary precision. To see this, consider that every time we add a hidden unit, we add another linear region to the function. As these regions become more numerous, they represent smaller sections of the function, which are increasingly well approximated by a line (figure 3.5). The universal approximation theorem proves that for any continuous function, there exists a shallow network that can approximate this function to any specified precision.

这些单元通过线性组合生成输出:

事实上,只要具有足够的容量(隐藏单元),浅层网络就能以任意精度描述定义在实数轴紧致子集上的任意连续一维函数。为了理解这一点,可以考虑每增加一个隐藏单元,就会为函数增加另一个线性区域。随着这些区域数量增多,它们表示函数的更小片段,而这些片段越来越能被直线很好地近似(图 3.5)。该通用近似定理证明,对于任意连续函数,都存在一个浅层网络,能够以任意指定精度近似该函数。

图 3.5 分段线性模型对一维函数(虚线)的逼近。 a–c)随着区域数量增加,模型越来越接近连续函数。具有标量输入的神经网络每个隐藏单元会额外创建一个线性区域。
图 3.5 分段线性模型对一维函数(虚线)的逼近。 a–c)随着区域数量增加,模型越来越接近连续函数。具有标量输入的神经网络每个隐藏单元会额外创建一个线性区域。这一思想可推广到 Di 维函数。通用近似定理证明,只要隐藏单元足够多,就存在一个浅层神经网络,能够以任意精度描述定义在 RDi 的紧子集上的任意给定连续函数。Figure 3.5 Approximation of a 1D function (dashed line) by a piecewise linear model. a–c) As the number of regions increases, the model becomes closer and closer to the continuous function. A neural network with a scalar input creates one extra linear region per hidden unit. Di dimensions. The universal approximation theorem proves that, with enough hidden units, there exists a shallow neural network that can describe any given continuous function defined on a compact subset of RDi to arbitrary precision.
3.3 多变量输入和输出
3.3 Multivariate inputs and outputs

In the above example, the network has a single scalar input x and a single scalar output y. However, the universal approximation theorem also holds for the more general case where the network maps multivariate inputs x = [x1, x2,..., xDi]T to multivariate output predictions y =[y1, y2,..., yDo]T. We first explore how to extend the model to predict multivariate outputs. Then we consider multivariate inputs. Finally, in section 3.4, we present a general definition of a shallow neural network.

在上述示例中,网络具有一个标量输入 x 和一个标量输出 y。然而,通用近似定理也适用于更一般的情况,即网络将多元输入 x = [x1, x2,..., xDi]T 映射为多元输出预测 y =[y1, y2,..., yDo]T。我们首先探讨如何将模型扩展为预测多元输出。然后考虑多元输入。最后,在第 3.4 节中,我们给出浅层神经网络的一般定义。

3.3.1 多变量输出可视化
3.3.1 Visualizing multivariate outputs

To extend the network to multivariate outputs y, we simply use a different linear function of the hidden units for each output. So, a network with a scalar input x, four hidden units h1, h2, h3, and h4, and a 2D multivariate output y = [y1, y2]T would be defined as: and

and

图 3.6 具有一个输入、四个隐藏单元和两个输出的网络。 a) 网络结构可视化。 b) 该网络生成两个分段线性函数, y1[x] 和 y2[x]。由于它们共享相
图 3.6 具有一个输入、四个隐藏单元和两个输出的网络。 a) 网络结构可视化。 b) 该网络生成两个分段线性函数, y1[x] 和 y2[x]。由于它们共享相同的隐藏单元,这些函数的四个“拐点”(位于竖直虚线处)被约束在同一位置,但斜率和整体高度可能不同。Figure 3.6 Network with one input, four hidden units, and two outputs. Visualization of network structure. b) This network produces two piecewise linear functions, y1[x] and y2[x]. The four “joints” of these functions (at vertical dotted lines) are constrained to be in the same places since they share the same hidden units, but the slopes and overall height may differ.

The two outputs are two different linear functions of the hidden units.

As we saw in figure 3.3, the “joints” in the piecewise functions depend on where the initial linear functions θ•0 + θ•1x are clipped by the ReLU functions a[•] at the hidden units. Since both outputs y1 and y2 are different linear functions of the same four hidden units, the four “joints” in each must be in the same places. However, the slopes of the linear regions and the overall vertical offset can differ (figure 3.6).

这两个输出是隐藏单元的两个不同线性函数。正如我们在图 3.3 中所见,分段函数中的“拐点”取决于初始线性函数 θ•0 + θ•1x 在隐藏单元处被 ReLU 函数 a[•] 截断的位置。由于两个输出 y1 和 y2 都是相同四个隐藏

3.3.2 可视化多元输入
3.3.2 Visualizing multivariate inputs

To cope with multivariate inputs x, we extend the linear relations between the input and the hidden units. So a network with two inputs x = [x1, x2]T and a scalar output y (figure 3.7) might have three hidden units defined by:

为了处理多元输入 x,我们扩展输入与隐藏单元之间的线性关系。因此,具有两个输入 x = [x1, x2]T 和一个标量输出 y (图 3.7)的网络可能有三个隐藏单元,定义如下:

图 3.8 具有两个输入的神经网络中的处理过程 x =[x1, x2]T,三个隐藏单元 h1, h2, h3,以及一个输出 y。 a–c) 每个隐藏单元的输入是
图 3.8 具有两个输入的神经网络中的处理过程 x =[x1, x2]T,三个隐藏单元 h1, h2, h3,以及一个输出 y。 a–c) 每个隐藏单元的输入是两个输入的线性函数,对应一个有向平面。亮度表示函数输出。例如,在面板 (a) 中,亮度表示 θ10 + θ11x1 + θ12x2。细线是等高线。 d–f) 每个平面都被 ReLU 激活函数裁剪(青色线相当于图 3.3d–f 中的“关节”)。 g-i) 然后对裁剪后的平面进行加权, j) 再与一个决定曲面整体高度的偏移量一起求和。结果是由凸的分段线性多边形区域组成的连续曲面。(交互式图)Figure 3.8 Processing in network with two inputs x =[x1, x2]T, three hidden units h1, h2, h3, and one output y. linear function of the two inputs, which corresponds to an oriented plane. Brightness indicates function output. For example, in panel (a), the brightness represents θ10 + θ11x1 + θ12x2. Thin lines are contours. d–f) Each plane is clipped by the ReLU activation function (cyan lines are equivalent to “joints” in figures 3.3df). g-i) The clipped planes are then weighted, and j) summed together with an offset that determines the overall height of the surface. The result is a continuous surface made up of convex piecewise linear polygonal regions. (Interactive figure) a–c) The input to each hidden unit is a

where there is now one slope parameter for each input. The hidden units are combined to form the output in the usual way: Figure 3.8 illustrates the processing of this network. Each hidden unit receives a linear combination of the two inputs, which forms an oriented plane in the 3D input/output space. The activation function clips the negative values of these planes to zero. The clipped planes are then recombined in a second linear function (equation 3.10) to create

a continuous piecewise linear surface consisting of convex polygonal regions (figure 3.8j). Each region corresponds to a different activation pattern. For example, in the central

现在每个输入都有一个斜率参数。隐藏单元按常规方式组合形成输出:图 3.8 展示了该网络的处理过程。每个隐藏单元接收一个线性两个输入的组合,这在三维输入 / 输出中形成一个有方向的平面

triangular region, the first and third hidden units are active, and the second is inactive.

When there are more than two inputs to the model, it becomes difficult to visualize. However, the interpretation is similar. The output will be a continuous piecewise linear function of the input, where the linear regions are now convex polytopes in the multidimensional input space. Note that as the input dimensions grow, the number of linear regions increases rapidly (figure 3.9). To get a feeling for how rapidly, consider that each hidden unit defines a hyperplane that delineates the part of space where this unit is active from the part where it is not (cyan lines in 3.8d–f). If we had the same number of hidden units as input dimensions Di, we could align each hyperplane with one of the coordinate axes

当模型有超过两个输入时,可视化变得困难。然而,解释类似。输出将是输入的连续分段线性函数,其中线性区域现在是多维输入空间中的凸多胞形。

(figure 3.10). For two input dimensions, this would divide the space into four quadrants. For three dimensions, this would create eight octants, and for Di dimensions, this would create 2Di orthants. Shallow neural networks usually have more hidden units than input dimensions, so they typically create more than 2Di linear regions.

它不成立的区域(3.8d–f 中的青色线条)。如果隐藏单元数与输入维度数 Di 相同,我们可以让每个超平面与其中一个坐标轴对齐(图 3.10)。对于两个输入维度,这会将空间划分为四个象限。对于三维,这会产生八个八分体,而对于 Di 维,这会产生 2Di 个卦限。浅层神经网络通常拥有比输入维度更多的隐藏单元,因此它们通常会产生多于 2Di 个线性区域。

3.4 浅层神经网络:一般情况
3.4 Shallow neural networks: general case

We have described several example shallow networks to help develop intuition about how they work. We now define a general equation for a shallow neural network y = f[ x , ϕ] that maps a multi-dimensional input x ∈RDi to a multi-dimensional output y ∈RDo using D hidden units. Each hidden unit is computed as:

我们已经描述了几个示例浅层网络,以帮助建立对其工作原理的直觉。我们现在定义一个浅层神经网络的一般方程 y = f[ x ϕ],它将多维输入 x ∈RDi 映射为多维输出 y ∈RDo,其中使用 D 个隐藏单元。每个隐藏单元的计算方式如下:

并且这些隐藏单元经线性组合生成输出:

and these are combined linearly to create the output:

图 3.9 线性区域与隐藏单元。 a) 最大可能区域数随隐藏单元数的变化,对应五种不同的输入维度单元。该神经网络具有参数,按现代标准会被认为非常小。
图 3.9 线性区域与隐藏单元。 a) 最大可能区域数随隐藏单元数的变化,对应五种不同的输入维度单元。该神经网络具有参数,按现代标准会被认为非常小。Figure 3.9 Linear regions vs. hidden units. a) Maximum possible regions as a function of the number of hidden units for five different input dimensions Di= {1, 5, 10, 50, 100}. The number of regions increases rapidly in high dimensions; with D=500 units and input size Di=100, there can be greater than 10107 regions (solid circle). b) The same data are plotted as a function of the number of parameters. The solid circle represents the same model as in panel (a) with D= 500 hidden units. This network has 51, 001 parameters and would be considered very small by modern standards.
图 3.10 线性区域数与输入维度。 a) 在单一输入维度下,具有一个隐藏单元的模型会创建一个拐点,将轴划分为两个线性区域。 b) 在两个输入维度下,具有两个隐
图 3.10 线性区域数与输入维度。 a) 在单一输入维度下,具有一个隐藏单元的模型会创建一个拐点,将轴划分为两个线性区域。 b) 在两个输入维度下,具有两个隐藏单元的模型可以使用两条线(此处与坐标轴对齐)划分输入空间,形成四个区域。 c) 在三个输入维度下,具有三个隐藏单元的模型可以使用三个平面(同样与坐标轴对齐)划分输入空间,形成八个区域。继续这一论证可知,具有 Di 个输入维度和 Di 个隐藏单元的模型可以使用 Di 个超平面划分输入空间,形成 2Di 个线性区域。Figure 3.10 Number of linear regions vs. input dimensions. a) With a single input dimension, a model with one hidden unit creates one joint, which divides the axis into two linear regions. b) With two input dimensions, a model with two hidden units can divide the input space using two lines (here aligned with axes) to create four regions. c) With three input dimensions, a model with three hidden units can divide the input space using three planes (again aligned with axes) to create eight regions. Continuing this argument, it follows that a model with Di input dimensions and Di hidden units can divide the input space with Di hyperplanes to create 2Di linear regions.

where a[•] is a nonlinear activation function. The model has parameters ϕ = {θ••, ϕ••}. Figure 3.11 shows an example with three inputs, three hidden units, and two outputs.

The activation function permits the model to describe nonlinear relations between input and the output, and as such, it must be nonlinear itself; with no activation function, or a linear activation function, the overall mapping from input to output would be restricted to be linear. Many different activation functions have been tried (see figure 3.13), but the most common choice is the ReLU (figure 3.1), which has the merit of being easily interpretable.

With ReLU activations, the network divides the input space into convex polytopes defined by the intersections of hyperplanes computed by the “joints” in the ReLU functions. Each convex polytope contains a different linear function. The polytopes are the same for each output, but the linear functions they contain can differ.

其中 a[•] 是一个非线性激活函数。模型具有参数 ϕ = {θ••, ϕ••}。图 3.11 显示了一个具有三个输入、三个隐藏单元和两个输出的示例。

激活函数使模型能够描述输入与输出之间的非线性关系,因此它本身必须是非线性的;如果没有激活函数,或者使用线性激活函数,则从输入到输出的整体映射将被限制为线性的。人们尝试了许多不同的激活函数(见图 3.13),但最常见的选择是 ReLU (图 3.1),它具有优点易于解释。采用 ReLU 激活时,网络将输入空间划分为由 ReLU 函数中的“拐点”计算出的超平面交点所定义的凸多面体。每个凸多面体包含一个不同的线性函数。对于每个输出,这些多面体都是相同的,但它们包含的线性函数可以不同。

3.5 术语
3.5 Terminology

We conclude this chapter by introducing some terminology. Regrettably, neural networks have a lot of associated jargon. They are often referred to in terms of layers. The left of figure 3.12 is the input layer, the center is the hidden layer, and to the right is the output layer. We would say that the network in figure 3.12 has one hidden layer containing four hidden units. The hidden units themselves are sometimes referred to as neurons. When we pass data through the network, the values of the inputs to the hidden layer (i.e., before the ReLU functions are applied) are termed pre-activations. The values at the hidden layer (i.e., after the ReLU functions) are termed activations.

For historical reasons, any neural network with at least one hidden layer is also called a multi-layer perceptron, or MLP for short. Networks with one hidden layer (as described in this chapter) are sometimes referred to as shallow neural networks. Networks with multiple hidden layers (as described in the next chapter) are referred to as deep neural networks. Neural networks in which the connections form an acyclic graph (i.e., a graph with no loops, as in all the examples in this chapter) are referred to as feed-forward networks. If every element in one layer connects to every element in the next (as in all the examples in this chapter), the network is fully connected. These connections

我们通过引入一些术语来结束本章。遗憾的是,神经网络有很多相关行话。它们通常用层来描述。图 3.12 的左侧是输入层,中间是隐藏层,右侧是输出层。我们会说图 3.12 中的网络有一个包含四个隐藏单元的隐藏层。隐藏单元本身有时被称为神经元。当我们将数据通过网络传递时,输入到隐藏层的值(即在应用 ReLU 函数之前)被称为预激活。隐藏层的值(即在 ReLU 函数之后)被称为激活。由于历史原因,任何至少包含一个隐藏层的神经网络也被称为多层感知机,或简称 MLP。只有一个隐藏层的网络(如本章所述)有时被称为浅层神经网络。具有多个隐藏层的网络(如下一章所述)被称为深层神经网络。连接形成无环图(即没有环路的图,如本章所有示例)的神经网络被称为前馈网络。如果某一层的每个元素都与下一层的每个元素相连(如本章所有示例),则该网络是全连接的。这些连接

represent slope parameters in the underlying equations and are referred to as network weights. The offset parameters (not shown in figure 3.12) are called biases.

表示底层方程中的斜率参数,被称为网络权重。偏移参数(图 3.12 中未显示)称为偏差。

图 3.12 术语。浅层网络由输入层、隐藏层和输出层组成。每一层都通过前向连接(箭头)连接到下一层。因此,这些模型被称为前馈网络。当某一层的每个变量都与下一层的
图 3.12 术语。浅层网络由输入层、隐藏层和输出层组成。每一层都通过前向连接(箭头)连接到下一层。因此,这些模型被称为前馈网络。当某一层的每个变量都与下一层的每个变量相连时,我们称之为全连接网络。每个连接都代表底层方程中的一个斜率参数,这些参数被称为权重。隐藏层中的变量被称为神经元或隐藏单元。输入到隐藏单元的值被称为预激活值,而隐藏单元处的值(即应用 ReLU 函数后的值)被称为激活值。Figure 3.12 Terminology. A shallow network consists of an input layer, a hidden layer, and an output layer. Each layer is connected to the next by forward connections (arrows). For this reason, these models are referred to as feed-forward networks. When every variable in one layer connects to every variable in the next, we call this a fully connected network. Each connection represents a slope parameter in the underlying equation, and these parameters are termed weights. The variables in the hidden layer are termed neurons or hidden units. The values feeding into the hidden units are termed pre-activations, and the values at the hidden units (i.e., after the ReLU function is applied) are termed activations.
3.6 小结
3.6 Summary

Shallow neural networks have one hidden layer. They (i) compute several linear functions of the input, (ii) pass each result through an activation function, and then (iii) take a linear combination of these activations to form the outputs. Shallow neural networks make predictions y based on inputs x by dividing the input space into a continuous surface of piecewise linear regions. With enough hidden units (neurons), shallow neural networks can approximate any continuous function to arbitrary precision.

Chapter 4 discusses deep neural networks, which extend the models from this chapter by adding more hidden layers. Chapters 5–7 describe how to train these models.

浅层神经网络有一个隐藏层。它们(i)计算输入的若干线性函数,(ii)将每个结果送入激活函数,然后(iii)对这些激活值进行线性组合以形成输出。浅层神经网络生成预测 y,这些预测基于输入 x,方法是将输入空间划分为由分段线性区域构成的连续曲面。当隐藏单元(神经元)数量足够时,浅层神经网络可以以任意精度逼近任何连续函数。

第 4 章讨论深层神经网络,它通过增加更多隐藏层来扩展本章中的模型。第 5–7 章描述如何训练这些模型。

注释
Notes

“Neural” networks:

图 3.13 激活函数。 a) 逻辑 sigmoid 和 tanh 函数。 b) Leaky ReLU 和参数为 0.25 的参数化 ReLU。 c) Soft
图 3.13 激活函数。 a) 逻辑 sigmoid 和 tanh 函数。 b) Leaky ReLU 和参数为 0.25 的参数化 ReLU。 c) SoftPlus、高斯误差线性单元和 sigmoid 线性单元。 d) 参数为 0 4、 1 5 1 0、 0 1 4. 和. 的指数线性单元。 e) 缩放指数线性单元。 f) 参数为.. 0 和.. 的 Swish。Figure 3.13 Activation functions. Leaky ReLU and parametric ReLU with parameter 0.25. c) SoftPlus, Gaussian error linear unit, and sigmoid linear unit. d) Exponential linear unit with parameters 0.5 and 1.0, e) Scaled exponential linear unit. f) Swish with parameters 0.4, 1.0, and 1.4.

History of neural networks:

Activation functions:

Universal approximation theorem:

Number of linear regions:

公式

Linear, affine, and nonlinear functions:

线性函数、仿射函数和非线性函数:从技术上讲,线性变换 f[•] 是任何遵循叠加原理的函数,因

问题
Problems
图 3.14 问题 3.4 中具有一个输入、三个隐藏单元和一个输出的网络中的处理过程。 ac)每个隐藏单元的输入是各输入的线性函数。前两个与图 3.3 相同,但
图 3.14 问题 3.4 中具有一个输入、三个隐藏单元和一个输出的网络中的处理过程。 ac)每个隐藏单元的输入是各输入的线性函数。前两个与图 3.3 相同,但最后一个不同。问题 3.5 请证明 α ∈R+ 满足以下性质:这被称为 ReLU 函数的非负齐次性性质。Figure 3.14 Processing in network with one input, three hidden units, and one output for problem 3.4. a–c) The input to each hidden unit is a linear function of the inputs. The first two are the same as in figure 3.3, but the last one differs. Problem 3.5 Prove that the following property holds for α ∈R+: This is known as the non-negative homogeneity property of the ReLU function. Technically, a linear transformation f[•] is any