Learning Representations by Back-propagating Errors
Learning representations by back-propagating errors
通过反向传播误差学习表征
We describe a new learning procedure, back-propagation, for networks of neurone-like units. The procedure repeatedly adjusts the weights of the connections in the network so as to minimize a measure of the difference between the actual output vector of the net and the desired output vector. As a result of the weight adjustments, internal ‘hidden’ units which are not part of the input or output come to represent important features of the task domain, and the regularities in the task are captured by the interactions of these units. The ability to create useful new features distinguishes back-propagation from earlier, simpler methods such as the perceptron-convergence procedure¹.
我们介绍一种用于类神经元单元网络的新学习过程:反向传播。这一过程反复调整网络中各连接的权重,使网络实际输出向量与期望输出向量之间的差异度量达到最小。权重调整的结果是,那些既不属于输入也不属于输出的内部“隐藏”单元,逐渐表示出任务领域中的重要特征,任务中的规律则由这些单元之间的相互作用来刻画。能够创造有用的新特征,是反向传播区别于感知机收敛过程¹等更早、更简单方法的地方。
There have been many attempts to design self-organizing neural networks. The aim is to find a powerful synaptic modification rule that will allow an arbitrarily connected neural network to develop an internal structure that is appropriate for a particular task domain. The task is specified by giving the desired state vector of the output units for each state vector of the input units. If the input units are directly connected to the output units it is relatively easy to find learning rules that iteratively adjust the relative strengths of the connections so as to progressively reduce the difference between the actual and desired output vectors². Learning becomes more interesting but more difficult when we introduce hidden units whose actual or desired states are not specified by the task. (In perceptrons, there are ‘feature analysers’ between the input and output that are not true hidden units because their input connections are fixed by hand, so their states are completely determined by the input vector: they do not learn representations.) The learning procedure must decide under what circumstances the hidden units should be active in order to help achieve the desired input-output behaviour. This amounts to deciding what these units should represent. We demonstrate that a general purpose and relatively simple procedure is powerful enough to construct appropriate internal representations.
设计自组织神经网络的尝试已有很多。目标是找到一条强有力的突触修改规则,让任意连接的神经网络都能发展出适合特定任务领域的内部结构。任务的给定方式是:对输入单元的每个状态向量,给出输出单元的期望状态向量。如果输入单元直接连到输出单元,找到迭代调整连接相对强度、逐步缩小实际输出与期望输出向量之差的学习规则并不太难²。一旦引入隐藏单元,问题就更有意思,也更难了,因为任务并没有规定这些单元的实际状态或期望状态。(感知机的输入和输出之间有“特征分析器”,但它们不是真正的隐藏单元:它们的输入连接是人工固定的,状态完全由输入向量决定,并不学习表征。)学习过程必须决定隐藏单元在什么情况下应该激活,才能帮助实现期望的输入—输出行为,这就相当于决定这些单元应该表示什么。我们将说明,一个通用且相对简单的过程,足以构造出合适的内部表征。
The simplest form of the learning procedure is for layered networks which have a layer of input units at the bottom; any number of intermediate layers; and a layer of output units at the top. Connections within a layer or from higher to lower layers are forbidden, but connections can skip intermediate layers. An input vector is presented to the network by setting the states of the input units. Then the states of the units in each layer are determined by applying equations (1) and (2) to the connections coming from lower layers. All units within a layer have their states set in parallel, but different layers have their states set sequentially, starting at the bottom and working upwards until the states of the output units are determined.
这一学习过程最简单的形式适用于分层网络:最底层是一层输入单元,中间可以有任意多层,最顶层是一层输出单元。同层之间的连接以及从高层到低层的连接都不允许,但连接可以跳过中间层。向网络呈现一个输入向量,就是设定输入单元的状态。随后,把式 (1) 和式 (2) 应用于来自较低层的连接,确定每一层单元的状态。同一层内的单元并行设定状态,不同层则依次设定:从底层开始逐层向上,直到确定输出单元的状态。
The total input, , to unit is a linear function of the outputs, , of the units that are connected to and of the weights, , on these connections
单元 的总输入 ,是与 相连的各单元输出 以及这些连接上权重 的线性函数:
Units can be given biases by introducing an extra input to each unit which always has a value of 1. The weight on this extra input is called the bias and is equivalent to a threshold of the opposite sign. It can be treated just like the other weights.
给每个单元加一条取值恒为 1 的额外输入,就可以为单元引入偏置。这条额外输入上的权重称为偏置,相当于符号相反的阈值,可以像其他权重一样处理。
A unit has a real-valued output, , which is a non-linear function of its total input
单元的输出 是实数值,它是总输入的非线性函数:
Fig. 1 A network that has learned to detect mirror symmetry in the input vector. The numbers on the arcs are weights and the numbers inside the nodes are biases. The learning required 1,425 sweeps through the set of 64 possible input vectors, with the weights being adjusted on the basis of the accumulated gradient after each sweep. The values of the parameters in equation (9) were and . The initial weights were random and were uniformly distributed between −0.3 and 0.3. The key property of this solution is that for a given hidden unit, weights that are symmetric about the middle of the input vector are equal in magnitude and opposite in sign. So if a symmetrical pattern is presented, both hidden units will receive a net input of 0 from the input units, and, because the hidden units have a negative bias, both will be off. In this case the output unit, having a positive bias, will be on. Note that the weights on each side of the midpoint are in the ratio 1:2:4. This ensures that each of the eight patterns that can occur above the midpoint sends a unique activation sum to each hidden unit, so the only pattern below the midpoint that can exactly balance this sum is the symmetrical one. For all non-symmetrical patterns, both hidden units will receive non-zero activations from the input units. The two hidden units have identical patterns of weights but with opposite signs, so for every non-symmetric pattern one hidden unit will come on and suppress the output unit.
图 1 一个学会检测输入向量镜像对称性的网络。连线上的数字是权重,节点内的数字是偏置。学习过程把全部 64 种可能的输入向量遍历了 1425 轮,每轮结束后根据累积梯度调整权重。式 (9) 中的参数取 、。初始权重随机取值,在 −0.3 到 0.3 之间均匀分布。这个解的关键性质是:对某个隐藏单元而言,关于输入向量中点对称的两条权重大小相等、符号相反。因此输入对称模式时,两个隐藏单元从输入单元得到的净输入都是 0;由于隐藏单元的偏置为负,两者都处于关闭状态。这时输出单元因偏置为正而开启。注意中点每一侧的权重之比为 1:2:4,这保证中点一侧可能出现的 8 种模式各自给每个隐藏单元送去不同的激活总和,于是另一侧唯一能恰好抵消这一总和的模式就是对称的那个。对所有非对称模式,两个隐藏单元从输入单元得到的激活都不为零。两个隐藏单元的权重模式相同而符号相反,所以每遇到一个非对称模式,总有一个隐藏单元开启并抑制输出单元。
It is not necessary to use exactly the functions given in equations (1) and (2). Any input-output function which has a bounded derivative will do. However, the use of a linear function for combining the inputs to a unit before applying the nonlinearity greatly simplifies the learning procedure.
并不一定要严格使用式 (1) 和式 (2) 给出的函数,任何导数有界的输入—输出函数都可以。不过,在施加非线性之前先用线性函数组合单元的各个输入,会让学习过程简单很多。
The aim is to find a set of weights that ensure that for each input vector the output vector produced by the network is the same as (or sufficiently close to) the desired output vector. If there is a fixed, finite set of input-output cases, the total error in the performance of the network with a particular set of weights can be computed by comparing the actual and desired output vectors for every case. The total error, , is defined as
目标是找到一组权重,使网络对每个输入向量产生的输出向量与期望输出向量相同(或足够接近)。如果输入—输出样例是一个固定的有限集合,那么对每个样例比较实际输出与期望输出,就能算出网络在某组权重下的总误差。总误差 定义为
where is an index over cases (input-output pairs), is an index over output units, is the actual state of an output unit and is its desired state. To minimize by gradient descent it is necessary to compute the partial derivative of with respect to each weight in the network. This is simply the sum of the partial derivatives for each of the input-output cases. For a given case, the partial derivatives of the error with respect to each weight are computed in two passes. We have already described the forward pass in which the units in each layer have their states determined by the input they receive from units in lower layers using equations (1) and (2). The backward pass which propagates derivatives from the top layer back to the bottom one is more complicated.
其中 是样例(输入—输出对)的下标, 是输出单元的下标, 是输出单元的实际状态, 是它的期望状态。要用梯度下降最小化 ,需要计算 对网络中每个权重的偏导数。它就是各个输入—输出样例上偏导数之和。对某一个样例,误差对各权重的偏导数分两遍计算。前向一遍前面已经讲过:每层单元根据从较低层单元收到的输入,用式 (1) 和式 (2) 确定自己的状态。把导数从顶层传回底层的反向一遍则要复杂一些。
Fig. 2 Two isomorphic family trees. The information can be expressed as a set of triples of the form ⟨person 1⟩⟨relationship⟩⟨person 2⟩, where the possible relationships are {father, mother, husband, wife, son, daughter, uncle, aunt, brother, sister, nephew, niece}. A layered net can be said to ‘know’ these triples if it can produce the third term of each triple when given the first two. The first two terms are encoded by activating two of the input units, and the network must then complete the proposition by activating the output unit that represents the third term.
图 2 两棵同构的家族谱系树。其中的信息可以表示为一组形如 ⟨人物 1⟩⟨关系⟩⟨人物 2⟩ 的三元组,可能的关系有 {父亲、母亲、丈夫、妻子、儿子、女儿、叔舅、姑姨、兄弟、姐妹、侄甥、侄甥女}。如果一个分层网络在给定前两项时能给出每个三元组的第三项,就可以说它“知道”这些三元组。前两项通过激活两个输入单元来编码,网络随后必须激活代表第三项的输出单元,把这个命题补全。
Fig. 3 Activity levels in a five-layer network after it has learned. The bottom layer has 24 input units on the left for representing ⟨person 1⟩ and 12 input units on the right for representing the relationship. The white squares inside these two groups show the activity levels of the units. There is one active unit in the first group representing Colin and one in the second group representing the relationship ‘has-aunt’. Each of the two input groups is totally connected to its own group of 6 units in the second layer. These groups learn to encode people and relationships as distributed patterns of activity. The second layer is totally connected to the central layer of 12 units, and these are connected to the penultimate layer of 6 units. The activity in the penultimate layer must activate the correct output units, each of which stands for a particular ⟨person 2⟩. In this case, there are two correct answers (marked by black dots) because Colin has two aunts. Both the input units and the output units are laid out spatially with the English people in one row and the isomorphic Italians immediately below.
图 3 一个五层网络学会之后的激活水平。底层左边有 24 个输入单元,用来表示 ⟨人物 1⟩;右边有 12 个输入单元,用来表示关系。两组中的白色方块表示各单元的激活水平。第一组中有一个激活单元代表 Colin,第二组中有一个激活单元代表关系“有姑姨”。两个输入组各自与第二层中属于自己的 6 个单元全连接,这两组单元学会把人物和关系编码为分布式的激活模式。第二层与中间 12 个单元的一层全连接,后者再连到倒数第二层的 6 个单元。倒数第二层的活动必须激活正确的输出单元,每个输出单元代表一个特定的 ⟨人物 2⟩。本例有两个正确答案(以黑点标出),因为 Colin 有两位姑姨。输入单元和输出单元都按空间排列:英国人物排一行,与之同构的意大利人物紧排在下方。
The backward pass starts by computing for each of the output units. Differentiating equation (3) for a particular case, , and suppressing the index gives
反向一遍从计算每个输出单元的 开始。对某个样例 求式 (3) 的导数,并省去下标 ,得到
We can then apply the chain rule to compute
接着可以用链式法则计算 :
Differentiating equation (2) to get the value of and substituting gives
对式 (2) 求导得到 ,代入后得到
This means that we know how a change in the total input to an output unit will affect the error. But this total input is just a linear function of the states of the lower level units and it is also a linear function of the weights on the connections, so it is easy to compute how the error will be affected by changing these states and weights. For a weight , from to the derivative is
这样我们就知道输出单元总输入 的变化会怎样影响误差。而这个总输入只是低层单元状态的线性函数,也是连接权重的线性函数,所以很容易算出改变这些状态和权重会怎样影响误差。对从 到 的权重 ,导数为
and for the output of the unit the contribution to resulting from the effect of on is simply
而对第 个单元的输出来说, 对 的影响给 带来的贡献就是
so taking into account all the connections emanating from unit we have
把从单元 发出的所有连接都考虑进来,得到
We have now seen how to compute for any unit in the penultimate layer when given for all units in the last layer. We can therefore repeat this procedure to compute this term for successively earlier layers, computing for the weights as we go.
至此我们已经看到,给定最后一层所有单元的 ,就能算出倒数第二层任一单元的 。因此可以重复这一过程,依次为更前面的各层计算这一项,同时一路算出各权重的 。
One way of using is to change the weights after every input-output case. This has the advantage that no separate memory is required for the derivatives. An alternative scheme, which we used in the research reported here, is to accumulate over all the input-output cases before changing the weights. The simplest version of gradient descent is to change each weight by an amount proportional to the accumulated
使用 的一种方式,是每处理一个输入—输出样例就改一次权重,好处是不需要单独存储导数。本文所报告的研究采用的是另一种方案:先在所有输入—输出样例上累加 ,再修改权重。梯度下降最简单的形式,是让每个权重的改变量与累加得到的 成正比:
This method does not converge as rapidly as methods which make use of the second derivatives, but it is much simpler and can easily be implemented by local computations in parallel hardware. It can be significantly improved, without sacrificing the simplicity and locality, by using an acceleration method in which the current gradient is used to modify the velocity of the point in weight space instead of its position
这种方法的收敛速度不如利用二阶导数的方法,但简单得多,也很容易在并行硬件上用局部计算实现。采用一种加速方法可以显著改进它,同时不牺牲简单性和局部性:用当前梯度去修改权重空间中那个点的速度,而不是直接修改它的位置:
where is incremented by 1 for each sweep through the whole set of input-output cases, and is an exponential decay factor between 0 and 1 that determines the relative contribution of the current gradient and earlier gradients to the weight change.
其中每把全部输入—输出样例遍历一轮, 就加 1; 是介于 0 和 1 之间的指数衰减因子,决定当前梯度与此前各次梯度对权重改变量的相对贡献。
To break symmetry we start with small random weights. Variants on the learning procedure have been discovered independently by David Parker (personal communication) and by Yann Le Cun³.
为了打破对称,我们从较小的随机权重开始。David Parker(私人通信)和 Yann Le Cun³ 也各自独立发现了这一学习过程的变体。
One simple task that cannot be done by just connecting the input units to the output units is the detection of symmetry. To detect whether the binary activity levels of a one-dimensional array of input units are symmetrical about the centre point, it is essential to use an intermediate layer because the activity in an individual input unit, considered alone, provides no evidence about the symmetry or non-symmetry of the whole input vector, so simply adding up the evidence from the individual input units is insufficient. (A more formal proof that intermediate units are required is given in ref. 2.) The learning procedure discovered an elegant solution using just two intermediate units, as shown in Fig. 1.
对称检测就是一个仅把输入单元连到输出单元无法完成的简单任务。要判断一维输入单元阵列的二值激活是否关于中心点对称,必须使用中间层:单看某一个输入单元的活动,得不到关于整个输入向量是否对称的任何证据,所以把各输入单元的证据简单相加是不够的。(需要中间单元的更正式证明见参考文献 2。)如图 1 所示,学习过程只用两个中间单元就找到了一个简洁的解。
Another interesting task is to store the information in the two family trees (Fig. 2). Figure 3 shows the network we used, and Fig. 4 shows the ‘receptive fields’ of some of the hidden units after the network was trained on 100 of the 104 possible triples.
另一个有意思的任务是存储两棵家族谱系树中的信息(图 2)。图 3 是我们使用的网络;图 4 展示的是网络在 104 个可能的三元组中的 100 个上训练之后,部分隐藏单元的“感受野”。
Fig. 4 The weights from the 24 input units that represent people to the 6 units in the second layer that learn distributed representations of people. White rectangles, excitatory weights; black rectangles, inhibitory weights; area of the rectangle encodes the magnitude of the weight. The weights from the 12 English people are in the top row of each unit. Unit 1 is primarily concerned with the distinction between English and Italian and most of the other units ignore this distinction. This means that the representation of an English person is very similar to the representation of their Italian equivalent. The network is making use of the isomorphism between the two family trees to allow it to share structure and it will therefore tend to generalize sensibly from one tree to the other. Unit 2 encodes which generation a person belongs to, and unit 6 encodes which branch of the family they come from. The features captured by the hidden units are not at all explicit in the input and output encodings, since these use a separate unit for each person. Because the hidden features capture the underlying structure of the task domain, the network generalizes correctly to the four triples on which it was not trained. We trained the network for 1500 sweeps, using and for the first 20 sweeps and and for the remaining sweeps. To make it easier to interpret the weights we introduced ‘weight-decay’ by decrementing every weight by 0.2% after each weight change. After prolonged learning, the decay was balanced by , so the final magnitude of each weight indicates its usefulness in reducing the error. To prevent the network needing large weights to drive the outputs to 1 or 0, the error was considered to be zero if output units that should be on had activities above 0.8 and output units that should be off had activities below 0.2.
图 4 从代表人物的 24 个输入单元,到第二层中学习人物分布式表征的 6 个单元之间的权重。白色矩形为兴奋性权重,黑色矩形为抑制性权重,矩形面积表示权重大小。每个单元的上面一行是来自 12 个英国人物的权重。单元 1 主要关注英国人与意大利人的区别,其他单元大多忽略这一区别。这意味着一个英国人物的表征与其对应的意大利人物非常相似:网络利用两棵谱系树之间的同构来共享结构,因而倾向于在两棵树之间合理地泛化。单元 2 编码人物属于哪一代,单元 6 编码人物来自家族的哪一支。隐藏单元捕捉到的这些特征在输入和输出编码中完全没有明示,因为输入输出为每个人物各用一个单独的单元。由于隐藏特征捕捉到了任务领域的内在结构,网络对没有训练过的 4 个三元组也作出了正确的泛化。网络共训练 1500 轮:前 20 轮取 、,其余各轮取 、。为了让权重更易解读,我们引入了“权重衰减”:每次修改权重后,把每个权重减小 0.2%。长时间学习之后,衰减与 达到平衡,于是每个权重的最终大小反映了它对降低误差的作用。为了避免网络需要很大的权重才能把输出推到 1 或 0,我们规定:应开启的输出单元激活高于 0.8、应关闭的输出单元激活低于 0.2 时,误差即记为零。
Fig. 5 A synchronous iterative net that is run for three iterations and the equivalent layered net. Each time-step in the recurrent net corresponds to a layer in the layered net. The learning procedure for layered nets can be mapped into a learning procedure for iterative nets. Two complications arise in performing this mapping: first, in a layered net the output levels of the units in the intermediate layers during the forward pass are required for performing the backward pass (see equations (5) and (6)). So in an iterative net it is necessary to store the history of output states of each unit. Second, for a layered net to be equivalent to an iterative net, corresponding weights between different layers must have the same value. To preserve this property, we average for all the weights in each set of corresponding weights and then change each weight in the set by an amount proportional to this average gradient. With these two provisos, the learning procedure can be applied directly to iterative nets. These nets can then either learn to perform iterative searches or learn sequential structures⁴.
图 5 一个运行三次迭代的同步迭代网络,以及与之等价的分层网络。循环网络中的每个时间步对应分层网络中的一层。分层网络的学习过程可以映射为迭代网络的学习过程,但映射时有两处复杂之处。第一,在分层网络中,执行反向一遍需要用到前向一遍时各中间层单元的输出水平(见式 (5) 和式 (6)),所以在迭代网络中必须存储每个单元输出状态的历史。第二,分层网络要与迭代网络等价,不同层之间相对应的权重必须取相同的值。为保持这一性质,我们对每组对应权重中所有权重的 求平均,再按与这个平均梯度成正比的量修改该组中的每个权重。满足这两个条件后,学习过程就可以直接用于迭代网络。这样的网络可以学会执行迭代搜索,也可以学习序列结构⁴。
So far, we have only dealt with layered, feed-forward networks. The equivalence between layered networks and recurrent networks that are run iteratively is shown in Fig. 5.
到目前为止,我们只讨论了分层的前馈网络。分层网络与迭代运行的循环网络之间的等价关系见图 5。
The most obvious drawback of the learning procedure is that the error-surface may contain local minima so that gradient descent is not guaranteed to find a global minimum. However, experience with many tasks shows that the network very rarely gets stuck in poor local minima that are significantly worse than the global minimum. We have only encountered this undesirable behaviour in networks that have just enough connections to perform the task. Adding a few more connections creates extra dimensions in weight-space and these dimensions provide paths around the barriers that create poor local minima in the lower dimensional subspaces.
这一学习过程最明显的缺点是误差曲面可能存在局部极小,因此梯度下降不能保证找到全局极小。不过,在许多任务上的经验表明,网络极少陷入明显差于全局极小的糟糕局部极小。我们只在连接数刚好够完成任务的网络中遇到过这种不理想的情况。多加几条连接,就会在权重空间中增加维度,这些维度提供了绕过障碍的路径,而正是这些障碍在低维子空间中造成了糟糕的局部极小。
The learning procedure, in its current form, is not a plausible model of learning in brains. However, applying the procedure to various tasks shows that interesting internal representations can be constructed by gradient descent in weight-space, and this suggests that it is worth looking for more biologically plausible ways of doing gradient descent in neural networks.
就目前的形式而言,这一学习过程并不是大脑学习的合理模型。但把它应用于各种任务的结果表明,在权重空间中做梯度下降可以构造出有意思的内部表征。这提示我们,值得去寻找在神经网络中做梯度下降的、在生物学上更合理的方式。
We thank the System Development Foundation and the Office of Naval Research for financial support.
感谢 System Development Foundation 和美国海军研究办公室(Office of Naval Research)的资助。
Received 1 May; accepted 31 July 1986.
1986 年 5 月 1 日收稿,7 月 31 日接受。
References
参考文献
- Rosenblatt, F. Principles of Neurodynamics (Spartan, Washington, DC, 1961).
- Minsky, M. L. & Papert, S. Perceptrons (MIT, Cambridge, 1969).
- Le Cun, Y. Proc. Cognitiva 85, 599–604 (1985).
- Rumelhart, D. E., Hinton, G. E. & Williams, R. J. in Parallel Distributed Processing: Explorations in the Microstructure of Cognition. Vol. 1: Foundations (eds Rumelhart, D. E. & McClelland, J. L.) 318–362 (MIT, Cambridge, 1986).