Backpropagation
Machine learning and data mining 

In machine learning, backpropagation (backprop,^{[1]} BP) is a widely used algorithm for training feedforward neural networks. Generalizations of backpropagation exist for other artificial neural networks (ANNs), and for functions generally. These classes of algorithms are all referred to generically as "backpropagation".^{[2]} In fitting a neural network, backpropagation computes the gradient of the loss function with respect to the weights of the network for a single input–output example, and does so efficiently, unlike a naive direct computation of the gradient with respect to each weight individually. This efficiency makes it feasible to use gradient methods for training multilayer networks, updating weights to minimize loss; gradient descent, or variants such as stochastic gradient descent, are commonly used. The backpropagation algorithm works by computing the gradient of the loss function with respect to each weight by the chain rule, computing the gradient one layer at a time, iterating backward from the last layer to avoid redundant calculations of intermediate terms in the chain rule; this is an example of dynamic programming.^{[3]}
The term backpropagation strictly refers only to the algorithm for computing the gradient, not how the gradient is used; however, the term is often used loosely to refer to the entire learning algorithm, including how the gradient is used, such as by stochastic gradient descent.^{[4]} Backpropagation generalizes the gradient computation in the delta rule, which is the singlelayer version of backpropagation, and is in turn generalized by automatic differentiation, where backpropagation is a special case of reverse accumulation (or "reverse mode").^{[5]} The term backpropagation and its general use in neural networks was announced in (Rumelhart Hinton), then elaborated and popularized in (Rumelhart Hinton), but the technique was independently rediscovered many times, and had many predecessors dating to the 1960s; see § History.^{[6]} A modern overview is given in the deep learning textbook by (Goodfellow Bengio).^{[7]}
Overview
Backpropagation computes the gradient in weight space of a feedforward neural network, with respect to a loss function. Denote:
 [math]\displaystyle{ x }[/math]: input (vector of features)
 [math]\displaystyle{ y }[/math]: target output
 For classification, output will be a vector of class probabilities (e.g., [math]\displaystyle{ (0.1, 0.7, 0.2) }[/math], and target output is a specific class, encoded by the onehot/dummy variable (e.g., [math]\displaystyle{ (0, 1, 0) }[/math]).
 [math]\displaystyle{ C }[/math]: loss function or "cost function"^{[loweralpha 1]}
 For classification, this is usually cross entropy (XC, log loss), while for regression it is usually squared error loss (SEL).
 [math]\displaystyle{ L }[/math]: the number of layers
 [math]\displaystyle{ W^l = (w^l_{jk}) }[/math]: the weights between layer [math]\displaystyle{ l  1 }[/math] and [math]\displaystyle{ l }[/math], where [math]\displaystyle{ w^l_{jk} }[/math] is the weight between the [math]\displaystyle{ k }[/math]th node in layer [math]\displaystyle{ l  1 }[/math] and the [math]\displaystyle{ j }[/math]th node in layer [math]\displaystyle{ l }[/math]^{[loweralpha 2]}
 [math]\displaystyle{ f^l }[/math]: activation functions at layer [math]\displaystyle{ l }[/math]
 For classification the last layer is usually the logistic function for binary classification, and softmax (softargmax) for multiclass classification, while for the hidden layers this was traditionally a sigmoid function (logistic function or others) on each node (coordinate), but today is more varied, with rectifier (ramp, ReLU) being common.
In the derivation of backpropagation, other intermediate quantities are used; they are introduced as needed below. Bias terms are not treated specially, as they correspond to a weight with a fixed input of 1. For the purpose of backpropagation, the specific loss function and activation functions do not matter, as long as they and their derivatives can be evaluated efficiently. Traditional activation functions include but are not limited to sigmoid, tanh, and ReLU. Since, swish,^{[8]} mish,^{[9]} and other activation functions were proposed as well.
The overall network is a combination of function composition and matrix multiplication:
 [math]\displaystyle{ g(x) := f^L(W^L f^{L1}(W^{L1} \cdots f^1(W^1 x)\cdots)) }[/math]
For a training set there will be a set of input–output pairs, [math]\displaystyle{ \left\{(x_i, y_i)\right\} }[/math]. For each input–output pair [math]\displaystyle{ (x_i, y_i) }[/math] in the training set, the loss of the model on that pair is the cost of the difference between the predicted output [math]\displaystyle{ g(x_i) }[/math] and the target output [math]\displaystyle{ y_i }[/math]:
 [math]\displaystyle{ C(y_i, g(x_i)) }[/math]
Note the distinction: during model evaluation, the weights are fixed, while the inputs vary (and the target output may be unknown), and the network ends with the output layer (it does not include the loss function). During model training, the input–output pair is fixed, while the weights vary, and the network ends with the loss function.
Backpropagation computes the gradient for a fixed input–output pair [math]\displaystyle{ (x_i, y_i) }[/math], where the weights [math]\displaystyle{ w^l_{jk} }[/math] can vary. Each individual component of the gradient, [math]\displaystyle{ \partial C/\partial w^l_{jk}, }[/math] can be computed by the chain rule; however, doing this separately for each weight is inefficient. Backpropagation efficiently computes the gradient by avoiding duplicate calculations and not computing unnecessary intermediate values, by computing the gradient of each layer – specifically, the gradient of the weighted input of each layer, denoted by [math]\displaystyle{ \delta^l }[/math] – from back to front.
Informally, the key point is that since the only way a weight in [math]\displaystyle{ W^l }[/math] affects the loss is through its effect on the next layer, and it does so linearly, [math]\displaystyle{ \delta^l }[/math] are the only data you need to compute the gradients of the weights at layer [math]\displaystyle{ l }[/math], and then you can compute the previous layer [math]\displaystyle{ \delta^{l1} }[/math] and repeat recursively. This avoids inefficiency in two ways. Firstly, it avoids duplication because when computing the gradient at layer [math]\displaystyle{ l }[/math], you do not need to recompute all the derivatives on later layers [math]\displaystyle{ l+1, l+2, \ldots }[/math] each time. Secondly, it avoids unnecessary intermediate calculations because at each stage it directly computes the gradient of the weights with respect to the ultimate output (the loss), rather than unnecessarily computing the derivatives of the values of hidden layers with respect to changes in weights [math]\displaystyle{ \partial a^{l'}_{j'}/\partial w^l_{jk} }[/math].
Backpropagation can be expressed for simple feedforward networks in terms of matrix multiplication, or more generally in terms of the adjoint graph.
Matrix multiplication
For the basic case of a feedforward network, where nodes in each layer are connected only to nodes in the immediate next layer (without skipping any layers), and there is a loss function that computes a scalar loss for the final output, backpropagation can be understood simply by matrix multiplication.^{[loweralpha 3]} Essentially, backpropagation evaluates the expression for the derivative of the cost function as a product of derivatives between each layer from right to left – "backwards" – with the gradient of the weights between each layer being a simple modification of the partial products (the "backwards propagated error").
Given an input–output pair [math]\displaystyle{ (x, y) }[/math], the loss is:
 [math]\displaystyle{ C(y, f^L(W^L f^{L1}(W^{L1} \cdots f^2(W^2 f^1(W^1 x))\cdots))) }[/math]
To compute this, one starts with the input [math]\displaystyle{ x }[/math] and works forward; denote the weighted input of each hidden layer as [math]\displaystyle{ z^l }[/math] and the output of hidden layer [math]\displaystyle{ l }[/math] as the activation [math]\displaystyle{ a^l }[/math]. For backpropagation, the activation [math]\displaystyle{ a^l }[/math] as well as the derivatives [math]\displaystyle{ (f^l)' }[/math] (evaluated at [math]\displaystyle{ z^l }[/math]) must be cached for use during the backwards pass.
The derivative of the loss in terms of the inputs is given by the chain rule; note that each term is a total derivative, evaluated at the value of the network (at each node) on the input [math]\displaystyle{ x }[/math]:
 [math]\displaystyle{ \frac{d C}{d a^L}\circ \frac{d a^L}{d z^L}\cdot \frac{d z^L}{d a^{L1}} \circ \frac{d a^{L1}}{d z^{L1}}\cdot \frac{d z^{L1}}{d a^{L2}} \ldots \frac{d a^1}{d z^1} \cdot \frac{\partial z^1}{\partial x}, }[/math]
where [math]\displaystyle{ \circ }[/math] is a Hadamard product, that is an elementwise product.
These terms are: the derivative of the loss function;^{[loweralpha 4]} the derivatives of the activation functions;^{[loweralpha 5]} and the matrices of weights:^{[loweralpha 6]}
 [math]\displaystyle{ \frac{d C}{d a^L}\circ (f^L)' \cdot W^L \circ (f^{L1})' \cdot W^{L1} \cdots (f^1)' \cdot W^1. }[/math]
The gradient [math]\displaystyle{ \nabla }[/math] is the transpose of the derivative of the output in terms of the input, so the matrices are transposed and the order of multiplication is reversed, but the entries are the same:
 [math]\displaystyle{ \nabla_x C = (W^1)^T \cdot (f^1)' \ldots \circ (W^{L1})^T \cdot (f^{L1})' \circ (W^L)^T \cdot (f^L)' \circ \nabla_{a^L} C. }[/math]
Backpropagation then consists essentially of evaluating this expression from right to left (equivalently, multiplying the previous expression for the derivative from left to right), computing the gradient at each layer on the way; there is an added step, because the gradient of the weights isn't just a subexpression: there's an extra multiplication.
Introducing the auxiliary quantity [math]\displaystyle{ \delta^l }[/math] for the partial products (multiplying from right to left), interpreted as the "error at level [math]\displaystyle{ l }[/math]" and defined as the gradient of the input values at level [math]\displaystyle{ l }[/math]:
 [math]\displaystyle{ \delta^l := (f^l)' \circ (W^{l+1})^T \cdots \circ (W^{L1})^T \cdot (f^{L1})' \circ (W^L)^T \cdot (f^L)' \circ \nabla_{a^L} C. }[/math]
Note that [math]\displaystyle{ \delta^l }[/math] is a vector, of length equal to the number of nodes in level [math]\displaystyle{ l }[/math]; each component is interpreted as the "cost attributable to (the value of) that node".
The gradient of the weights in layer [math]\displaystyle{ l }[/math] is then:
 [math]\displaystyle{ \nabla_{W^l} C = \delta^l(a^{l1})^T. }[/math]
The factor of [math]\displaystyle{ a^{l1} }[/math] is because the weights [math]\displaystyle{ W^l }[/math] between level [math]\displaystyle{ l  1 }[/math] and [math]\displaystyle{ l }[/math] affect level [math]\displaystyle{ l }[/math] proportionally to the inputs (activations): the inputs are fixed, the weights vary.
The [math]\displaystyle{ \delta^l }[/math] can easily be computed recursively, going from right to left, as:
 [math]\displaystyle{ \delta^{l1} := (f^{l1})' \circ (W^l)^T \cdot \delta^l. }[/math]
The gradients of the weights can thus be computed using a few matrix multiplications for each level; this is backpropagation.
Compared with naively computing forwards (using the [math]\displaystyle{ \delta^l }[/math] for illustration):
 [math]\displaystyle{ \begin{align} \delta^1 &= (f^1)' \circ (W^2)^T \cdot (f^2)' \cdots \circ (W^{L1})^T \cdot (f^{L1})' \circ (W^L)^T \cdot (f^L)' \circ \nabla_{a^L} C\\ \delta^2 &= (f^2)' \cdots \circ (W^{L1})^T \cdot (f^{L1})' \circ (W^L)^T \cdot (f^L)' \circ \nabla_{a^L} C\\ &\vdots\\ \delta^{L1} &= (f^{L1})' \circ (W^L)^T \cdot (f^L)' \circ \nabla_{a^L} C\\ \delta^L &= (f^L)' \circ \nabla_{a^L} C, \end{align} }[/math]
there are two key differences with backpropagation:
 Computing [math]\displaystyle{ \delta^{l1} }[/math] in terms of [math]\displaystyle{ \delta^l }[/math] avoids the obvious duplicate multiplication of layers [math]\displaystyle{ l }[/math] and beyond.
 Multiplying starting from [math]\displaystyle{ \nabla_{a^L} C }[/math] – propagating the error backwards – means that each step simply multiplies a vector ([math]\displaystyle{ \delta^l }[/math]) by the matrices of weights [math]\displaystyle{ (W^l)^T }[/math] and derivatives of activations [math]\displaystyle{ (f^{l1})' }[/math]. By contrast, multiplying forwards, starting from the changes at an earlier layer, means that each multiplication multiplies a matrix by a matrix. This is much more expensive, and corresponds to tracking every possible path of a change in one layer [math]\displaystyle{ l }[/math] forward to changes in the layer [math]\displaystyle{ l+2 }[/math] (for multiplying [math]\displaystyle{ W^{l+1} }[/math] by [math]\displaystyle{ W^{l+2} }[/math], with additional multiplications for the derivatives of the activations), which unnecessarily computes the intermediate quantities of how weight changes affect the values of hidden nodes.
Adjoint graph
For more general graphs, and other advanced variations, backpropagation can be understood in terms of automatic differentiation, where backpropagation is a special case of reverse accumulation (or "reverse mode").^{[5]}
Intuition
Motivation
The goal of any supervised learning algorithm is to find a function that best maps a set of inputs to their correct output. The motivation for backpropagation is to train a multilayered neural network such that it can learn the appropriate internal representations to allow it to learn any arbitrary mapping of input to output.^{[10]}
Learning as an optimization problem
To understand the mathematical derivation of the backpropagation algorithm, it helps to first develop some intuition about the relationship between the actual output of a neuron and the correct output for a particular training example. Consider a simple neural network with two input units, one output unit and no hidden units, and in which each neuron uses a linear output (unlike most work on neural networks, in which mapping from inputs to outputs is nonlinear)^{[loweralpha 7]} that is the weighted sum of its input.
Initially, before training, the weights will be set randomly. Then the neuron learns from training examples, which in this case consist of a set of tuples [math]\displaystyle{ (x_1, x_2, t) }[/math] where [math]\displaystyle{ x_1 }[/math] and [math]\displaystyle{ x_2 }[/math] are the inputs to the network and t is the correct output (the output the network should produce given those inputs, when it has been trained). The initial network, given [math]\displaystyle{ x_1 }[/math] and [math]\displaystyle{ x_2 }[/math], will compute an output y that likely differs from t (given random weights). A loss function [math]\displaystyle{ L(t, y) }[/math] is used for measuring the discrepancy between the target output t and the computed output y. For regression analysis problems the squared error can be used as a loss function, for classification the categorical crossentropy can be used.
As an example consider a regression problem using the square error as a loss:
 [math]\displaystyle{ L(t, y)= (ty)^2 = E, }[/math]
where E is the discrepancy or error.
Consider the network on a single training case: [math]\displaystyle{ (1, 1, 0) }[/math]. Thus, the input [math]\displaystyle{ x_1 }[/math] and [math]\displaystyle{ x_2 }[/math] are 1 and 1 respectively and the correct output, t is 0. Now if the relation is plotted between the network's output y on the horizontal axis and the error E on the vertical axis, the result is a parabola. The minimum of the parabola corresponds to the output y which minimizes the error E. For a single training case, the minimum also touches the horizontal axis, which means the error will be zero and the network can produce an output y that exactly matches the target output t. Therefore, the problem of mapping inputs to outputs can be reduced to an optimization problem of finding a function that will produce the minimal error.
However, the output of a neuron depends on the weighted sum of all its inputs:
 [math]\displaystyle{ y=x_1w_1 + x_2w_2, }[/math]
where [math]\displaystyle{ w_1 }[/math] and [math]\displaystyle{ w_2 }[/math] are the weights on the connection from the input units to the output unit. Therefore, the error also depends on the incoming weights to the neuron, which is ultimately what needs to be changed in the network to enable learning.
In this example, upon injecting the training data [math]\displaystyle{ (1, 1, 0) }[/math], the loss function becomes
[math]\displaystyle{ E = (ty)^2 = y^2 = (x_1w_1 + x_2w_2)^2 = (w_1 + w_2)^2. }[/math]
Then, the loss function [math]\displaystyle{ E }[/math] takes the form of a parabolic cylinder with its base directed along [math]\displaystyle{ w_1 = w_2 }[/math]. Since all sets of weights that satisfy [math]\displaystyle{ w_1 = w_2 }[/math] minimize the loss function, in this case additional constraints are required to converge to a unique solution. Additional constraints could either be generated by setting specific conditions to the weights, or by injecting additional training data.
One commonly used algorithm to find the set of weights that minimizes the error is gradient descent. By backpropagation, the steepest descent direction is calculated of the loss function versus the present synaptic weights. Then, the weights can be modified along the steepest descent direction, and the error is minimized in an efficient way.
Derivation
The gradient descent method involves calculating the derivative of the loss function with respect to the weights of the network. This is normally done using backpropagation. Assuming one output neuron,^{[loweralpha 8]} the squared error function is
 [math]\displaystyle{ E = L(t, y) }[/math]
where
 [math]\displaystyle{ L }[/math] is the loss for the output [math]\displaystyle{ y }[/math] and target value [math]\displaystyle{ t }[/math],
 [math]\displaystyle{ t }[/math] is the target output for a training sample, and
 [math]\displaystyle{ y }[/math] is the actual output of the output neuron.
For each neuron [math]\displaystyle{ j }[/math], its output [math]\displaystyle{ o_j }[/math] is defined as
 [math]\displaystyle{ o_j = \varphi(\text{net}_j) = \varphi\left(\sum_{k=1}^n w_{kj}o_k\right), }[/math]
where the activation function [math]\displaystyle{ \varphi }[/math] is nonlinear and differentiable (even if the ReLU is not in one point). A historically used activation function is the logistic function:
 [math]\displaystyle{ \varphi(z) = \frac 1 {1+e^{z}} }[/math]
which has a convenient derivative of:
 [math]\displaystyle{ \frac {d \varphi(z)}{d z} = \varphi(z)(1\varphi(z)) }[/math]
The input [math]\displaystyle{ \text{net}_j }[/math] to a neuron is the weighted sum of outputs [math]\displaystyle{ o_k }[/math] of previous neurons. If the neuron is in the first layer after the input layer, the [math]\displaystyle{ o_k }[/math] of the input layer are simply the inputs [math]\displaystyle{ x_k }[/math] to the network. The number of input units to the neuron is [math]\displaystyle{ n }[/math]. The variable [math]\displaystyle{ w_{kj} }[/math] denotes the weight between neuron [math]\displaystyle{ k }[/math] of the previous layer and neuron [math]\displaystyle{ j }[/math] of the current layer.
Finding the derivative of the error
Calculating the partial derivative of the error with respect to a weight [math]\displaystyle{ w_{ij} }[/math] is done using the chain rule twice:

[math]\displaystyle{ \frac{\partial E}{\partial w_{ij}} = \frac{\partial E}{\partial o_{j}} \frac{\partial o_{j}}{\partial w_{ij}} = \frac{\partial E}{\partial o_j} \frac{\partial o_j}{\partial\text{net}_j} \frac{\partial \text{net}_j}{\partial w_{ij}} }[/math]
(
)
In the last factor of the righthand side of the above, only one term in the sum [math]\displaystyle{ \text{net}_j }[/math] depends on [math]\displaystyle{ w_{ij} }[/math], so that

[math]\displaystyle{ \frac{\partial \text{net}_j}{\partial w_{ij}} = \frac{\partial}{\partial w_{ij}} \left(\sum_{k=1}^n w_{kj} o_k\right) = \frac{\partial}{\partial w_{ij}} w_{ij} o_i= o_i. }[/math]
(
)
If the neuron is in the first layer after the input layer, [math]\displaystyle{ o_i }[/math] is just [math]\displaystyle{ x_i }[/math].
The derivative of the output of neuron [math]\displaystyle{ j }[/math] with respect to its input is simply the partial derivative of the activation function:

[math]\displaystyle{ \frac{\partial o_j}{\partial\text{net}_j} = \frac {\partial \varphi(\text{net}_j)}{\partial \text{net}_j} }[/math]
(
)
which for the logistic activation function case is:
 [math]\displaystyle{ \frac{\partial o_j}{\partial\text{net}_j} = \frac {\partial}{\partial \text{net}_j} \varphi(\text{net}_j) = \varphi(\text{net}_j)(1\varphi(\text{net}_j)) = o_j(1o_j) }[/math]
This is the reason why backpropagation requires the activation function to be differentiable. (Nevertheless, the ReLU activation function, which is nondifferentiable at 0, has become quite popular, e.g. in AlexNet)
The first factor is straightforward to evaluate if the neuron is in the output layer, because then [math]\displaystyle{ o_j = y }[/math] and

[math]\displaystyle{ \frac{\partial E}{\partial o_j} = \frac{\partial E}{\partial y} }[/math]
(
)
If half of the square error is used as loss function we can rewrite it as
 [math]\displaystyle{ \frac{\partial E}{\partial o_j} = \frac{\partial E}{\partial y} = \frac{\partial}{\partial y} \frac{1}{2}(t  y)^2 = y  t }[/math]
However, if [math]\displaystyle{ j }[/math] is in an arbitrary inner layer of the network, finding the derivative [math]\displaystyle{ E }[/math] with respect to [math]\displaystyle{ o_j }[/math] is less obvious.
Considering [math]\displaystyle{ E }[/math] as a function with the inputs being all neurons [math]\displaystyle{ L = \{u, v, \dots, w\} }[/math] receiving input from neuron [math]\displaystyle{ j }[/math],
 [math]\displaystyle{ \frac{\partial E(o_j)}{\partial o_j} = \frac{\partial E(\mathrm{net}_u, \text{net}_v, \dots, \mathrm{net}_w)}{\partial o_j} }[/math]
and taking the total derivative with respect to [math]\displaystyle{ o_j }[/math], a recursive expression for the derivative is obtained:

[math]\displaystyle{ \frac{\partial E}{\partial o_j} = \sum_{\ell \in L} \left(\frac{\partial E}{\partial \text{net}_\ell}\frac{\partial \text{net}_\ell}{\partial o_j}\right) = \sum_{\ell \in L} \left(\frac{\partial E}{\partial o_\ell}\frac{\partial o_\ell}{\partial \text{net}_\ell}\frac{\partial \text{net}_\ell}{\partial o_j}\right) = \sum_{\ell \in L} \left(\frac{\partial E}{\partial o_\ell}\frac{\partial o_\ell}{\partial \text{net}_\ell}w_{j \ell}\right) }[/math]
(
)
Therefore, the derivative with respect to [math]\displaystyle{ o_j }[/math] can be calculated if all the derivatives with respect to the outputs [math]\displaystyle{ o_\ell }[/math] of the next layer – the ones closer to the output neuron – are known. [Note, if any of the neurons in set [math]\displaystyle{ L }[/math] were not connected to neuron [math]\displaystyle{ j }[/math], they would be independent of [math]\displaystyle{ w_{ij} }[/math] and the corresponding partial derivative under the summation would vanish to 0.]
Substituting Eq. 2, Eq. 3 Eq.4 and Eq. 5 in Eq. 1 we obtain:
 [math]\displaystyle{ \frac{\partial E}{\partial w_{ij}} = \frac{\partial E}{\partial o_{j}} \frac{\partial o_{j}}{\partial \text{net}_{j}} \frac{\partial \text{net}_{j}}{\partial w_{ij}} = \frac{\partial E}{\partial o_{j}} \frac{\partial o_{j}}{\partial \text{net}_{j}} o_i }[/math]
 [math]\displaystyle{ \frac{\partial E}{\partial w_{ij}} = o_i \delta_j }[/math]
with
 [math]\displaystyle{ \delta_j = \frac{\partial E}{\partial o_j} \frac{\partial o_j}{\partial\text{net}_j} = \begin{cases} \frac{\partial L(o_j, t)}{\partial o_j} \frac {d \varphi(\text{net}_j)}{d \text{net}_j} & \text{if } j \text{ is an output neuron,}\\ (\sum_{\ell\in L} w_{j \ell} \delta_\ell)\frac {d \varphi(\text{net}_j)}{d \text{net}_j} & \text{if } j \text{ is an inner neuron.} \end{cases} }[/math]
if [math]\displaystyle{ \varphi }[/math] is the logistic function, and the error is the square error:
 [math]\displaystyle{ \delta_j = \frac{\partial E}{\partial o_j} \frac{\partial o_j}{\partial\text{net}_j} = \begin{cases} (o_jt_j)o_j(1o_{j}) & \text{if } j \text{ is an output neuron,}\\ (\sum_{\ell\in L} w_{j \ell} \delta_\ell)o_j(1o_j) & \text{if } j \text{ is an inner neuron.} \end{cases} }[/math]
To update the weight [math]\displaystyle{ w_{ij} }[/math] using gradient descent, one must choose a learning rate, [math]\displaystyle{ \eta \gt 0 }[/math]. The change in weight needs to reflect the impact on [math]\displaystyle{ E }[/math] of an increase or decrease in [math]\displaystyle{ w_{ij} }[/math]. If [math]\displaystyle{ \frac{\partial E}{\partial w_{ij}} \gt 0 }[/math], an increase in [math]\displaystyle{ w_{ij} }[/math] increases [math]\displaystyle{ E }[/math]; conversely, if [math]\displaystyle{ \frac{\partial E}{\partial w_{ij}} \lt 0 }[/math], an increase in [math]\displaystyle{ w_{ij} }[/math] decreases [math]\displaystyle{ E }[/math]. The new [math]\displaystyle{ \Delta w_{ij} }[/math] is added to the old weight, and the product of the learning rate and the gradient, multiplied by [math]\displaystyle{ 1 }[/math] guarantees that [math]\displaystyle{ w_{ij} }[/math] changes in a way that always decreases [math]\displaystyle{ E }[/math]. In other words, in the equation immediately below, [math]\displaystyle{  \eta \frac{\partial E}{\partial w_{ij}} }[/math] always changes [math]\displaystyle{ w_{ij} }[/math] in such a way that [math]\displaystyle{ E }[/math] is decreased:
 [math]\displaystyle{ \Delta w_{ij} =  \eta \frac{\partial E}{\partial w_{ij}} =  \eta o_i \delta_j }[/math]
Secondorder gradient descent
Using a Hessian matrix of secondorder derivatives of the error function, the LevenbergMarquardt algorithm often converges faster than firstorder gradient descent, especially when the topology of the error function is complicated.^{[11]}^{[12]} It may also find solutions in smaller node counts for which other methods might not converge.^{[12]} The Hessian can be approximated by the Fisher information matrix.^{[13]}
Loss function
The loss function is a function that maps values of one or more variables onto a real number intuitively representing some "cost" associated with those values. For backpropagation, the loss function calculates the difference between the network output and its expected output, after a training example has propagated through the network.
Assumptions
The mathematical expression of the loss function must fulfill two conditions in order for it to be possibly used in backpropagation.^{[14]} The first is that it can be written as an average [math]\displaystyle{ E=\frac{1}{n}\sum_xE_x }[/math] over error functions [math]\displaystyle{ E_x }[/math], for [math]\displaystyle{ n }[/math] individual training examples, [math]\displaystyle{ x }[/math]. The reason for this assumption is that the backpropagation algorithm calculates the gradient of the error function for a single training example, which needs to be generalized to the overall error function. The second assumption is that it can be written as a function of the outputs from the neural network.
Example loss function
Let [math]\displaystyle{ y,y' }[/math] be vectors in [math]\displaystyle{ \mathbb{R}^n }[/math].
Select an error function [math]\displaystyle{ E(y,y') }[/math] measuring the difference between two outputs. The standard choice is the square of the Euclidean distance between the vectors [math]\displaystyle{ y }[/math] and [math]\displaystyle{ y' }[/math]:[math]\displaystyle{ E(y,y') = \tfrac{1}{2} \lVert yy'\rVert^2 }[/math]The error function over [math]\displaystyle{ n }[/math] training examples can then be written as an average of losses over individual examples:[math]\displaystyle{ E=\frac{1}{2n}\sum_x\lVert (y(x)y'(x)) \rVert^2 }[/math]
Limitations
 Gradient descent with backpropagation is not guaranteed to find the global minimum of the error function, but only a local minimum; also, it has trouble crossing plateaus in the error function landscape. This issue, caused by the nonconvexity of error functions in neural networks, was long thought to be a major drawback, but Yann LeCun et al. argue that in many practical problems, it is not.^{[15]}
 Backpropagation learning does not require normalization of input vectors; however, normalization could improve performance.^{[16]}
 Backpropagation requires the derivatives of activation functions to be known at network design time.
History
The term backpropagation and its general use in neural networks was announced in (Rumelhart Hinton), then elaborated and popularized in (Rumelhart Hinton), but the technique was independently rediscovered many times, and had many predecessors dating to the 1960s.^{[6]}^{[17]}
The basics of continuous backpropagation were derived in the context of control theory by Henry J. Kelley in 1960,^{[18]} and by Arthur E. Bryson in 1961.^{[19]}^{[20]}^{[21]}^{[22]}^{[23]} They used principles of dynamic programming. In 1962, Stuart Dreyfus published a simpler derivation based only on the chain rule.^{[24]} Bryson and Ho described it as a multistage dynamic system optimization method in 1969.^{[25]}^{[26]} Backpropagation was derived by multiple researchers in the early 60's^{[22]} and implemented to run on computers as early as 1970 by Seppo Linnainmaa.^{[27]}^{[28]}^{[29]} Paul Werbos was first in the US to propose that it could be used for neural nets after analyzing it in depth in his 1974 dissertation.^{[30]} While not applied to neural networks, in 1970 Linnainmaa published the general method for automatic differentiation (AD).^{[28]}^{[29]} Although very controversial, some scientists believe this was actually the first step toward developing a backpropagation algorithm.^{[22]}^{[23]}^{[27]}^{[31]} In 1973 Dreyfus adapts parameters of controllers in proportion to error gradients.^{[32]} In 1974 Werbos mentioned the possibility of applying this principle to artificial neural networks,^{[30]} and in 1982 he applied Linnainmaa's AD method to nonlinear functions.^{[23]}^{[33]}
Later the Werbos method was rediscovered and described in 1985 by Parker,^{[34]}^{[35]} and in 1986 by Rumelhart, Hinton and Williams.^{[17]}^{[35]}^{[36]} Rumelhart, Hinton and Williams showed experimentally that this method can generate useful internal representations of incoming data in hidden layers of neural networks.^{[10]}^{[37]}^{[38]} Yann LeCun proposed the modern form of the backpropagation learning algorithm for neural networks in his PhD thesis in 1987. In 1993, Eric Wan won an international pattern recognition contest through backpropagation.^{[22]}^{[39]}
During the 2000s it fell out of favour, but returned in the 2010s, benefitting from cheap, powerful GPUbased computing systems. This has been especially so in speech recognition, machine vision, natural language processing, and language structure learning research (in which it has been used to explain a variety of phenomena related to first^{[40]} and second language learning.^{[41]}).
Error backpropagation has been suggested to explain human brain ERP components like the N400 and P600.^{[42]}
See also
 Artificial neural network
 Biological neural network
 Catastrophic interference
 Ensemble learning
 AdaBoost
 Overfitting
 Neural backpropagation
 Backpropagation through time
Notes
 ↑ Use [math]\displaystyle{ C }[/math] for the loss function to allow [math]\displaystyle{ L }[/math] to be used for the number of layers
 ↑ This follows (Nielsen 2015), and means (left) multiplication by the matrix [math]\displaystyle{ W^l }[/math] corresponds to converting output values of layer [math]\displaystyle{ l  1 }[/math] to input values of layer [math]\displaystyle{ l }[/math]: columns correspond to input coordinates, rows correspond to output coordinates.
 ↑ This section largely follows and summarizes (Nielsen 2015).
 ↑ The derivative of the loss function is a covector, since the loss function is a scalarvalued function of several variables.
 ↑ The activation function is applied to each node separately, so the derivative is just the diagonal matrix of the derivative on each node. This is often represented as the Hadamard product with the vector of derivatives, denoted by [math]\displaystyle{ (f^l)'\odot }[/math], which is mathematically identical but better matches the internal representation of the derivatives as a vector, rather than a diagonal matrix.
 ↑ Since matrix multiplication is linear, the derivative of multiplying by a matrix is just the matrix: [math]\displaystyle{ (Wx)' = W }[/math].
 ↑ One may notice that multilayer neural networks use nonlinear activation functions, so an example with linear neurons seems obscure. However, even though the error surface of multilayer networks are much more complicated, locally they can be approximated by a paraboloid. Therefore, linear neurons are used for simplicity and easier understanding.
 ↑ There can be multiple output neurons, in which case the error is the squared norm of the difference vector.
References
 ↑ Goodfellow, Bengio & Courville 2016, p. 200, "The backpropagation algorithm (Rumelhart et al., 1986a), often simply called backprop, ..."
 ↑ Goodfellow, Bengio & Courville 2016, p. 200, "Furthermore, backpropagation is often misunderstood as being specific to multilayer neural networks, but in principle it can compute derivatives of any function"
 ↑ Goodfellow, Bengio & Courville 2016, p. 214, "This tablefilling strategy is sometimes called dynamic programming."
 ↑ Goodfellow, Bengio & Courville 2016, p. 200, "The term backpropagation is often misunderstood as meaning the whole learning algorithm for multilayer neural networks. Backpropagation refers only to the method for computing the gradient, while other algorithms, such as stochastic gradient descent, is used to perform learning using this gradient."
 ↑ ^{5.0} ^{5.1} (Goodfellow Bengio), "The backpropagation algorithm described here is only one approach to automatic differentiation. It is a special case of a broader class of techniques called reverse mode accumulation."
 ↑ ^{6.0} ^{6.1} (Goodfellow Bengio), "Efficient applications of the chain rule based on dynamic programming began to appear in the 1960s and 1970s, mostly for control applications (Kelley, 1960; Bryson and Denham, 1961; Dreyfus, 1962; Bryson and Ho, 1969; Dreyfus, 1973) but also for sensitivity analysis (Linnainmaa, 1976). ... The idea was finally developed in practice after being independently rediscovered in different ways (LeCun, 1985; Parker, 1985; Rumelhart et al., 1986a). The book Parallel Distributed Processing presented the results of some of the first successful experiments with backpropagation in a chapter (Rumelhart et al., 1986b) that contributed greatly to the popularization of backpropagation and initiated a very active period of research in multilayer neural networks."
 ↑ (Goodfellow Bengio)
 ↑ Ramachandran, Prajit; Zoph, Barret; Le, Quoc V. (20171027). "Searching for Activation Functions". arXiv:1710.05941 [cs.NE].
 ↑ Misra, Diganta (20190823). "Mish: A Self Regularized NonMonotonic Activation Function". arXiv:1908.08681 [cs.LG].
 ↑ ^{10.0} ^{10.1} Rumelhart, David E.; Hinton, Geoffrey E.; Williams, Ronald J. (1986a). "Learning representations by backpropagating errors". Nature 323 (6088): 533–536. doi:10.1038/323533a0. Bibcode: 1986Natur.323..533R.
 ↑ Tan, Hong Hui; Lim, King Han (2019). "Review of secondorder optimization techniques in artificial neural networks backpropagation". IOP Conference Series: Materials Science and Engineering 495 (1): 012003. doi:10.1088/1757899X/495/1/012003. Bibcode: 2019MS&E..495a2003T.
 ↑ ^{12.0} ^{12.1} Wiliamowski, Bogdan; Yu, Hao (June 2010). "Improved Computation for Levenberg–Marquardt Training". IEEE Transactions on Neural Networks and Learning Systems 21 (6). https://www.eng.auburn.edu/~wilambm/pap/2010/Improved%20Computation%20for%20LM%20Training.pdf.
 ↑ Martens, James (August 2020). "New Insights and Perspectives on the Natural Gradient Method". Journal of Machine Learning Research (21). https://arxiv.org/pdf/1412.1193.pdf.
 ↑ (Nielsen 2015), "[W]hat assumptions do we need to make about our cost function ... in order that backpropagation can be applied? The first assumption we need is that the cost function can be written as an average ... over cost functions ... for individual training examples ... The second assumption we make about the cost is that it can be written as a function of the outputs from the neural network ..."
 ↑ LeCun, Yann; Bengio, Yoshua; Hinton, Geoffrey (2015). "Deep learning". Nature 521 (7553): 436–444. doi:10.1038/nature14539. PMID 26017442. Bibcode: 2015Natur.521..436L.
 ↑ Buckland, Matt; Collins, Mark (2002). AI Techniques for Game Programming. Boston: Premier Press. ISBN 193184108X.
 ↑ ^{17.0} ^{17.1} Rumelhart; Hinton; Williams (1986). "Learning representations by backpropagating errors". Nature 323 (6088): 533–536. doi:10.1038/323533a0. Bibcode: 1986Natur.323..533R. http://www.cs.toronto.edu/~hinton/absps/naturebp.pdf.
 ↑ Kelley, Henry J. (1960). "Gradient theory of optimal flight paths". ARS Journal 30 (10): 947–954. doi:10.2514/8.5282.
 ↑ Bryson, Arthur E. (1962). "A gradient method for optimizing multistage allocation processes". Proceedings of the Harvard Univ. Symposium on digital computers and their applications, 3–6 April 1961. Cambridge: Harvard University Press. OCLC 498866871.
 ↑ Dreyfus, Stuart E. (1990). "Artificial Neural Networks, Back Propagation, and the KelleyBryson Gradient Procedure". Journal of Guidance, Control, and Dynamics 13 (5): 926–928. doi:10.2514/3.25422. Bibcode: 1990JGCD...13..926D.
 ↑ Mizutani, Eiji; Dreyfus, Stuart; Nishio, Kenichi (July 2000). "On derivation of MLP backpropagation from the KelleyBryson optimalcontrol gradient formula and its application". Proceedings of the IEEE International Joint Conference on Neural Networks. https://coeieor.wpengine.com/wpcontent/uploads/2019/03/ijcnn2k.pdf.
 ↑ ^{22.0} ^{22.1} ^{22.2} ^{22.3} Schmidhuber, Jürgen (2015). "Deep learning in neural networks: An overview". Neural Networks 61: 85–117. doi:10.1016/j.neunet.2014.09.003. PMID 25462637.
 ↑ ^{23.0} ^{23.1} ^{23.2} Schmidhuber, Jürgen (2015). "Deep Learning". Scholarpedia 10 (11): 32832. doi:10.4249/scholarpedia.32832. Bibcode: 2015SchpJ..1032832S.
 ↑ Dreyfus, Stuart (1962). "The numerical solution of variational problems". Journal of Mathematical Analysis and Applications 5 (1): 30–45. doi:10.1016/0022247x(62)900045.
 ↑ Russell, Stuart; Norvig, Peter (1995). Artificial Intelligence : A Modern Approach. Englewood Cliffs: Prentice Hall. p. 578. ISBN 0131038052. "The most popular method for learning in multilayer networks is called Backpropagation. It was first invented in 1969 by Bryson and Ho, but was more or less ignored until the mid1980s."
 ↑ Bryson, Arthur Earl; Ho, YuChi (1969). Applied optimal control: optimization, estimation, and control. Waltham: Blaisdell. OCLC 3801.
 ↑ ^{27.0} ^{27.1} Griewank, Andreas (2012). "Who Invented the Reverse Mode of Differentiation?". Optimization Stories. Documenta Matematica, Extra Volume ISMP. pp. 389–400.
 ↑ ^{28.0} ^{28.1} Seppo Linnainmaa (1970). The representation of the cumulative rounding error of an algorithm as a Taylor expansion of the local rounding errors. Master's Thesis (in Finnish), Univ. Helsinki, 6–7.
 ↑ ^{29.0} ^{29.1} Linnainmaa, Seppo (1976). "Taylor expansion of the accumulated rounding error". BIT Numerical Mathematics 16 (2): 146–160. doi:10.1007/bf01931367.
 ↑ ^{30.0} ^{30.1} The thesis, and some supplementary information, can be found in his book, Werbos, Paul J. (1994). The Roots of Backpropagation : From Ordered Derivatives to Neural Networks and Political Forecasting. New York: John Wiley & Sons. ISBN 0471598976.
 ↑ Griewank, Andreas; Walther, Andrea (2008). Evaluating Derivatives: Principles and Techniques of Algorithmic Differentiation, Second Edition. SIAM. ISBN 9780898717761. https://books.google.com/books?id=xoiiLaRxcbEC.
 ↑ Dreyfus, Stuart (1973). "The computational solution of optimal control problems with time lag". IEEE Transactions on Automatic Control 18 (4): 383–385. doi:10.1109/tac.1973.1100330.
 ↑ Werbos, Paul (1982). "Applications of advances in nonlinear sensitivity analysis". System modeling and optimization. Springer. pp. 762–770. http://werbos.com/Neural/SensitivityIFIPSeptember1981.pdf.
 ↑ Parker, D.B. (1985). Learning Logic. Cambridge MA: Massachusetts Institute of Technology.
 ↑ ^{35.0} ^{35.1} Hertz, John (1991). Introduction to the theory of neural computation. Krogh, Anders., Palmer, Richard G.. Redwood City, Calif.: AddisonWesley. pp. 8. ISBN 0201503956. OCLC 21522159.
 ↑ Neurocomputing Foundations of research. MIT Press. 1988. ISBN 0262010976. OCLC 489622044.
 ↑ Rumelhart, David E.; Hinton, Geoffrey E.; Williams, Ronald J. (1986b). "8. Learning Internal Representations by Error Propagation". in Rumelhart, David E.; McClelland, James L.. Parallel Distributed Processing : Explorations in the Microstructure of Cognition. 1 : Foundations. Cambridge: MIT Press. ISBN 0262181207. https://archive.org/details/paralleldistribu00rume.
 ↑ Alpaydin, Ethem (2010). Introduction to Machine Learning. MIT Press. ISBN 9780262012430. https://books.google.com/books?id=4j9GAQAAIAAJ.
 ↑ Wan, Eric A. (1994). "Time Series Prediction by Using a Connectionist Network with Internal Delay Lines". in Weigend, Andreas S.; Gershenfeld, Neil A.. Time Series Prediction : Forecasting the Future and Understanding the Past. Proceedings of the NATO Advanced Research Workshop on Comparative Time Series Analysis. 15. Reading: AddisonWesley. pp. 195–217. ISBN 0201626012.
 ↑ Chang, Franklin; Dell, Gary S.; Bock, Kathryn (2006). "Becoming syntactic.". Psychological Review 113 (2): 234–272. doi:10.1037/0033295x.113.2.234. PMID 16637761.
 ↑ Janciauskas, Marius; Chang, Franklin (2018). "Input and AgeDependent Variation in Second Language Learning: A Connectionist Account". Cognitive Science 42: 519–554. doi:10.1111/cogs.12519. PMID 28744901.
 ↑ Fitz, Hartmut; Chang, Franklin (2019). "Language ERPs reflect learning through prediction error propagation" (in en). Cognitive Psychology 111: 15–52. doi:10.1016/j.cogpsych.2019.03.002. PMID 30921626.
Further reading
 Goodfellow, Ian; Bengio, Yoshua; Courville, Aaron (2016). Deep Learning. MIT Press. pp. 200–220. ISBN 9780262035613. http://www.deeplearningbook.org.
 Nielsen, Michael A. (2015). "How the backpropagation algorithm works". Neural Networks and Deep Learning. Determination Press. http://neuralnetworksanddeeplearning.com/chap2.html.
 McCaffrey, James (October 2012). "Neural Network BackPropagation for Programmers". MSDN Magazine. https://docs.microsoft.com/enus/archive/msdnmagazine/2012/october/testrunneuralnetworkbackpropagationforprogrammers.
 Rojas, Raúl (1996). "The Backpropagation Algorithm". Neural Networks : A Systematic Introduction. Berlin: Springer. ISBN 3540605053. https://page.mi.fuberlin.de/rojas/neural/chapter/K7.pdf.
External links
 Backpropagation neural network tutorial at the Wikiversity
 Bernacki, Mariusz; Włodarczyk, Przemysław (2004). "Principles of training multilayer neural network using backpropagation". http://galaxy.agh.edu.pl/~vlsi/AI/backp_t_en/backprop.html.
Original source: https://en.wikipedia.org/wiki/Backpropagation.
Read more 