Backpropagation
In machine learning, backpropagation is a gradient computation method commonly used for training a neural network in computing parameter updates. It is an efficient application of the chain rule to neural networks. Backpropagation efficiently computes the gradient of the loss with respect to the network weights for a single input–output example. It does this by propagating derivatives backward, one layer at a time, from the output layer to the input layer, thereby avoiding redundant chain-rule calculations. Strictly speaking, the term backpropagation refers only to an algorithm for efficiently computing the gradient, not how the gradient is used, but the term is often used loosely to refer to the entire learning algorithm. This includes changing model parameters in the negative direction of the gradient, such as by stochastic gradient descent, or as an intermediate step in a more complicated optimizer, such as Adaptive Moment Estimation. Backpropagation had multiple discoveries and partial discoveries, with a tangled history and terminology (see § History). Some other names for the technique include "reverse mode of automatic differentiation" or "reverse accumulation".
Overview
Backpropagation computes the gradient in weight space of a feedforward neural network, with respect to a loss function. Denote:
x
{\displaystyle x}
: input (vector of features)
y
{\displaystyle y}
: target output For classification, output will be a vector of class probabilities (e.g.,
( 0.1 , 0.7 , 0.2 )
{\displaystyle (0.1,0.7,0.2)}
, and target output is a specific class, encoded by the one-hot/dummy variable (e.g.,
( 0 , 1 , 0 )
{\displaystyle (0,1,0)}
).
C
{\displaystyle C}
: loss function or "cost function" For classification, this is usually cross-entropy (XC, log loss), while for regression it is usually squared error loss (SEL).
L
{\displaystyle L}
: the number of layers
W
l
= (
w
j k
l
)
{\displaystyle W^{l}=(w_{jk}^{l})}
: the weights between layer
l − 1
{\displaystyle l-1}
and
l
{\displaystyle l}
, where
w
j k
l
{\displaystyle w_{jk}^{l}}
is the weight between the
k
{\displaystyle k}
-th node in layer
l − 1
{\displaystyle l-1}
and the
j
{\displaystyle j}
-th node in layer
l
{\displaystyle l}
f
l
{\displaystyle f^{l}}
: activation functions at layer
l
{\displaystyle l}
For classification the last layer is usually the logistic function for binary classification, and softmax (softargmax) for multi-class 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.
a
j
l
{\displaystyle a_{j}^{l}}
: activation of the
j
{\displaystyle j}
-th node in layer
l
{\displaystyle l}
. In the derivation of backpropagation, other intermediate quantities are used by introducing them as needed below. Bias terms are not treated specially since they correspond to a weight with a fixed input of 1. For 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 sigmoid, tanh, ReLU, Swish, Mish, and many others. The overall network is a combination of function composition and matrix multiplication:
g ( x ) :=
f
L
(
W
L
f
L − 1
(
W
L − 1
⋯
f
1
(
W
1
x ) ⋯ ) )
{\displaystyle g(x):=f^{L}(W^{L}f^{L-1}(W^{L-1}\cdots f^{1}(W^{1}x)\cdots ))}
For a training set there will be a set of input–output pairs,
{
(
x
i
,
y
i
)
}
{\displaystyle \left\{(x_{i},y_{i})\right\}}
. For each input–output pair
(
x
i
,
y
i
)
{\displaystyle (x_{i},y_{i})}
in the training set, the loss of the model on that pair is the cost of the difference between the predicted output
g (
x
i
)
{\displaystyle g(x_{i})}
and the target output
y
i
{\displaystyle y_{i}}
:
C (
y
i
, g (
x
i
) )
{\displaystyle C(y_{i},g(x_{i}))}
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
(
x
i
,
y
i
)
{\displaystyle (x_{i},y_{i})}
, where the weights
w
j k
l
{\displaystyle w_{jk}^{l}}
can vary. Each individual component of the gradient,
∂ C
/
∂
w
j k
l
,
{\displaystyle \partial C/\partial w_{jk}^{l},}
can be computed by the chain rule; but 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
δ
l
{\displaystyle \delta ^{l}}
– from back to front. Informally, the key point is that since the only way a weight in
W
l
{\displaystyle W^{l}}
affects the loss is through its effect on the next layer, and it does so linearly,
δ
l
{\displaystyle \delta ^{l}}
are the only data you need to compute the gradients of the weights at layer
l
{\displaystyle l}
, and then the gradients of weights of previous layer can be computed by
δ
l − 1
{\displaystyle \delta ^{l-1}}
and repeated recursively. This avoids inefficiency in two ways. First, it avoids duplication because when computing the gradient at layer
l
{\displaystyle l}
, it is unnecessary to recompute all derivatives on later layers
l + 1 , l + 2 , …
{\displaystyle l+1,l+2,\ldots }
each time. Second, 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
∂
a
j ′
l ′
/
∂
w
j k
l
{\displaystyle \partial a_{j'}^{l'}/\partial w_{jk}^{l}}
. 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. 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
( x , y )
{\displaystyle (x,y)}
, the loss is:
C ( y ,
f
L
(
W
L
f
L − 1
(
W
L − 1
⋯
f
2
(
W
2
f
1
(
W
1
x ) ) ⋯ ) ) )
{\displaystyle C(y,f^{L}(W^{L}f^{L-1}(W^{L-1}\cdots f^{2}(W^{2}f^{1}(W^{1}x))\cdots )))}
To compute this, one starts with the input
x
{\displaystyle x}
and works forward; denote the weighted input of each hidden layer as
z
l
{\displaystyle z^{l}}
and the output of hidden layer
l
{\displaystyle l}
as the activation
a
l
{\displaystyle a^{l}}
. For backpropagation, the activation
a
l
{\displaystyle a^{l}}
as well as the derivatives
(
f
l
) ′
{\displaystyle (f^{l})'}
(evaluated at
z
l
{\displaystyle z^{l}}
) 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
x
{\displaystyle x}
:
d C
d
a
L
⋅
d
a
L
d
z
L
⋅
d
z
L
d
a
L − 1
⋅
d
a
L − 1
d
z
L − 1
⋅
d
z
L − 1
d
a
L − 2
⋅ … ⋅
d
a
1
d
z
1
⋅
∂
z
1
∂ x
,
{\displaystyle {\frac {dC}{da^{L}}}\cdot {\frac {da^{L}}{dz^{L}}}\cdot {\frac {dz^{L}}{da^{L-1}}}\cdot {\frac {da^{L-1}}{dz^{L-1}}}\cdot {\frac {dz^{L-1}}{da^{L-2}}}\cdot \ldots \cdot {\frac {da^{1}}{dz^{1}}}\cdot {\frac {\partial z^{1}}{\partial x}},}
where
d
a
L
d
z
L
{\displaystyle {\frac {da^{L}}{dz^{L}}}}
is a diagonal matrix. These terms are: the derivative of the loss function; the derivatives of the activation functions; and the matrices of weights:
d C
d
a
L
∘ (
f
L
) ′
⋅
W
L
∘ (
f
L − 1
) ′
⋅
W
L − 1
∘ ⋯ ∘ (
f
1
) ′
⋅
W
1
.
{\displaystyle {\frac {dC}{da^{L}}}\circ (f^{L})'\cdot W^{L}\circ (f^{L-1})'\cdot W^{L-1}\circ \cdots \circ (f^{1})'\cdot W^{1}.}
The gradient
∇
{\displaystyle \nabla }
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:
∇
x
C = (
W
1
)
T
⋅ (
f
1
) ′
∘ … ∘ (
W
L − 1
)
T
⋅ (
f
L − 1
) ′
∘ (
W
L
)
T
⋅ (
f
L
) ′
∘
∇
a
L
C .
{\displaystyle \nabla _{x}C=(W^{1})^{T}\cdot (f^{1})'\circ \ldots \circ (W^{L-1})^{T}\cdot (f^{L-1})'\circ (W^{L})^{T}\cdot (f^{L})'\circ \nabla _{a^{L}}C.}
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 is not just a subexpression: there's an extra multiplication. Introducing the auxiliary quantity
δ
l
{\displaystyle \delta ^{l}}
for the partial products (multiplying from right to left), interpreted as the "error at level
l
{\displaystyle l}
" and defined as the gradient of the input values at level
l
{\displaystyle l}
:
δ
l
:= (
f
l
) ′
∘ (
W
l + 1
)
T
⋅ (
f
l + 1
) ′
∘ ⋯ ∘ (
W
L − 1
)
T
⋅ (
f
L − 1
) ′
∘ (
W
L
)
T
⋅ (
f
L
) ′
∘
∇
a
L
C .
{\displaystyle \delta ^{l}:=(f^{l})'\circ (W^{l+1})^{T}\cdot (f^{l+1})'\circ \cdots \circ (W^{L-1})^{T}\cdot (f^{L-1})'\circ (W^{L})^{T}\cdot (f^{L})'\circ \nabla _{a^{L}}C.}
Note that
δ
l
{\displaystyle \delta ^{l}}
is a vector, of length equal to the number of nodes in level
l
{\displaystyle l}
; each component is interpreted as the "cost attributable to (the value of) that node". The gradient of the weights in layer
l
{\displaystyle l}
is then:
∇
W
l
C =
δ
l
(
a
l − 1
)
T
.
{\displaystyle \nabla _{W^{l}}C=\delta ^{l}(a^{l-1})^{T}.}
The factor of
a
l − 1
{\displaystyle a^{l-1}}
is because the weights
W
l
{\displaystyle W^{l}}
between level
l − 1
{\displaystyle l-1}
and
l
{\displaystyle l}
affect level
l
{\displaystyle l}
proportionally to the inputs (activations): the inputs are fixed, the weights vary. The
δ
l
{\displaystyle \delta ^{l}}
can easily be computed recursively, going from right to left, as:
δ
l − 1
:= (
f
l − 1
) ′
∘ (
W
l
)
T
⋅
δ
l
.
{\displaystyle \delta ^{l-1}:=(f^{l-1})'\circ (W^{l})^{T}\cdot \delta ^{l}.}
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
δ
l
{\displaystyle \delta ^{l}}
for illustration):
δ
1
= (
f
1
) ′
∘ (
W
2
)
T
⋅ (
f
2
) ′
∘ ⋯ ∘ (
W
L − 1
)
T
⋅ (
f
L − 1
) ′
∘ (
W
L
)
T
⋅ (
f
L
) ′
∘
∇
a
L
C
δ
2
= (
f
2
) ′
∘ ⋯ ∘ (
W
L − 1
)
T
⋅ (
f
L − 1
) ′
∘ (
W
L
)
T
⋅ (
f
L
) ′
∘
∇
a
L
C
⋮
δ
L − 1
= (
f
L − 1
) ′
∘ (
W
L
)
T
⋅ (
f
L
) ′
∘
∇
a
L
C
δ
L
= (
f
L
) ′
∘
∇
a
L
C ,
{\displaystyle {\begin{aligned}\delta ^{1}&=(f^{1})'\circ (W^{2})^{T}\cdot (f^{2})'\circ \cdots \circ (W^{L-1})^{T}\cdot (f^{L-1})'\circ (W^{L})^{T}\cdot (f^{L})'\circ \nabla _{a^{L}}C\\\delta ^{2}&=(f^{2})'\circ \cdots \circ (W^{L-1})^{T}\cdot (f^{L-1})'\circ (W^{L})^{T}\cdot (f^{L})'\circ \nabla _{a^{L}}C\\&\vdots \\\delta ^{L-1}&=(f^{L-1})'\circ (W^{L})^{T}\cdot (f^{L})'\circ \nabla _{a^{L}}C\\\delta ^{L}&=(f^{L})'\circ \nabla _{a^{L}}C,\end{aligned}}}
There are two key differences with backpropagation:
Computing
δ
l − 1
{\displaystyle \delta ^{l-1}}
in terms of
δ
l
{\displaystyle \delta ^{l}}
avoids the obvious duplicate multiplication of layers
l
{\displaystyle l}
and beyond. Multiplying starting from
∇
a
L
C
{\displaystyle \nabla _{a^{L}}C}
– propagating the error backwards – means that each step simply multiplies a vector (
δ
l
{\displaystyle \delta ^{l}}
) by the matrices of weights
(
W
l
)
T
{\displaystyle (W^{l})^{T}}
and derivatives of activations
(
f
l − 1
) ′
{\displaystyle (f^{l-1})'}
. 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
l
{\displaystyle l}
forward to changes in the layer
l + 2
{\displaystyle l+2}
(for multiplying
W
l + 1
{\displaystyle W^{l+1}}
by
W
l + 2
{\displaystyle W^{l+2}}
, 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").
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 multi-layered neural network such that it can learn the appropriate internal representations to allow it to learn any arbitrary mapping of input to output.
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 non-linear) 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
(
x
1
,
x
2
, t )
{\displaystyle (x_{1},x_{2},t)}
where
x
1
{\displaystyle x_{1}}
and
x
2
{\displaystyle x_{2}}
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
x
1
{\displaystyle x_{1}}
and
x
2
{\displaystyle x_{2}}
, will compute an output y that likely differs from t (given random weights). A loss function
L ( t , y )
{\displaystyle L(t,y)}
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 cross-entropy can be used. As an example consider a regression problem using the square error as a loss:
L ( t , y ) = ( t − y
)
2
= E ,
{\displaystyle L(t,y)=(t-y)^{2}=E,}
where E is the discrepancy or error.
Consider the network on a single training case:
( 1 , 1 , 0 )
{\displaystyle (1,1,0)}
. Thus, the input
x
1
{\displaystyle x_{1}}
and
x
2
{\displaystyle x_{2}}
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:
y =
x
1
w
1
+
x
2
w
2
,
{\displaystyle y=x_{1}w_{1}+x_{2}w_{2},}
where
w
1
{\displaystyle w_{1}}
and
w
2
{\displaystyle w_{2}}
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
( 1 , 1 , 0 )
{\displaystyle (1,1,0)}
, the loss function becomes
E = ( t − y
)
2
=
y
2
= (
x
1
w
1
+
x
2
w
2
)
2
= (
w
1
+
w
2
)
2
.
{\displaystyle E=(t-y)^{2}=y^{2}=(x_{1}w_{1}+x_{2}w_{2})^{2}=(w_{1}+w_{2})^{2}.}
Then, the loss function
E
{\displaystyle E}
takes the form of a parabolic cylinder with its base directed along
w
1
= −
w
2
{\displaystyle w_{1}=-w_{2}}
. Since all sets of weights that satisfy
w
1
= −
w
2
{\displaystyle w_{1}=-w_{2}}
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, the squared error function is
E = L ( t , y )
{\displaystyle E=L(t,y)}
where
L
{\displaystyle L}
is the loss for the output
y
{\displaystyle y}
and target value
t
{\displaystyle t}
,
t
{\displaystyle t}
is the target output for a training sample, and
y
{\displaystyle y}
is the actual output of the output neuron. In this section, the order of the weight indexes are reversed relative to the prior section:
w
i j
{\displaystyle w_{ij}}
is weight from the
i
{\displaystyle i}
th to the
j
{\displaystyle j}
th unit. For each neuron
j
{\displaystyle j}
, its output
o
j
{\displaystyle o_{j}}
is defined as
o
j
= φ (
net
j
) = φ
(
∑
k = 1
n
w
k j
x
k
)
,
{\displaystyle o_{j}=\varphi ({\text{net}}_{j})=\varphi \left(\sum _{k=1}^{n}w_{kj}x_{k}\right),}
where the activation function
φ
{\displaystyle \varphi }
is non-linear and differentiable over the activation region (the ReLU is not differentiable at one point). A historically used activation function is the logistic function:
φ ( z ) =
1
1 +
e
− z
{\displaystyle \varphi (z)={\frac {1}{1+e^{-z}}}}
which has a convenient derivative of:
d φ
d z
= φ ( z ) ( 1 − φ ( z ) )
{\displaystyle {\frac {d\varphi }{dz}}=\varphi (z)(1-\varphi (z))}
The input
net
j
{\displaystyle {\text{net}}_{j}}
to a neuron is the weighted sum of outputs
o
k
{\displaystyle o_{k}}
of previous neurons. If the neuron is in the first layer after the input layer, the
o
k
{\displaystyle o_{k}}
of the input layer are simply the inputs
x
k
{\displaystyle x_{k}}
to the network. The number of input units to the neuron is
n
{\displaystyle n}
. The variable
w
k j
{\displaystyle w_{kj}}
denotes the weight between neuron
k
{\displaystyle k}
of the previous layer and neuron
j
{\displaystyle j}
of the current layer.
Finding the derivative of the error
Calculating the partial derivative of the error with respect to a weight
w
i j
{\displaystyle w_{ij}}
is done using the chain rule twice:
In the last factor of the right-hand side of the above, only one term in the sum
net
j
{\displaystyle {\text{net}}_{j}}
depends on
w
i j
{\displaystyle w_{ij}}
, so that
If the neuron is in the first layer after the input layer,
o
i
{\displaystyle o_{i}}
is just
x
i
{\displaystyle x_{i}}
. The derivative of the output of neuron
j
{\displaystyle j}
with respect to its input is simply the partial derivative of the activation function:
which for the logistic activation function
∂
o
j
∂
net
j
=
∂
∂
net
j
φ (
net
j
) = φ (
net
j
) ( 1 − φ (
net
j
) ) =
o
j
( 1 −
o
j
)
{\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}(1-o_{j})}
This is the reason why backpropagation requires that the activation function be differentiable. (Nevertheless, the ReLU activation function, which is non-differentiable 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
o
j
= y
{\displaystyle o_{j}=y}
and
If half of the square error is used as loss function we can rewrite it as
∂ E
∂
o
j
=
∂ E
∂ y
=
∂
∂ y
1 2
( t − y
)
2
= y − t
{\displaystyle {\frac {\partial E}{\partial o_{j}}}={\frac {\partial E}{\partial y}}={\frac {\partial }{\partial y}}{\frac {1}{2}}(t-y)^{2}=y-t}
However, if
j
{\displaystyle j}
is in an arbitrary inner layer of the network, finding the derivative
E
{\displaystyle E}
with respect to
o
j
{\displaystyle o_{j}}
is less obvious. Considering
E
{\displaystyle E}
as a function with the inputs being all neurons
L = { u , v , … , w }
{\displaystyle L=\{u,v,\dots ,w\}}
receiving input from neuron
j
{\displaystyle j}
,
∂ E (
o
j
)
∂
o
j
=
∂ E (
n e t
u
,
net
v
, … ,
n e t
w
)
∂
o
j
{\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}}}}
and taking the total derivative with respect to
o
j
{\displaystyle o_{j}}
, a recursive expression for the derivative is obtained:
Therefore, the derivative with respect to
o
j
{\displaystyle o_{j}}
can be calculated if all the derivatives with respect to the outputs
o
ℓ
{\displaystyle o_{\ell }}
of the next layer – the ones closer to the output neuron – are known. [Note, if any of the neurons in set
L
{\displaystyle L}
were not connected to neuron
j
{\displaystyle j}
, they would be independent of
w
i j
{\displaystyle w_{ij}}
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:
∂ E
∂
w
i j
=
∂ E
∂
o
j
∂
o
j
∂
net
j
∂
net
j
∂
w
i j
=
∂ E
∂
o
j
∂
o
j
∂
net
j
o
i
{\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}}
∂ E
∂
w
i j
=
o
i
δ
j
{\displaystyle {\frac {\partial E}{\partial w_{ij}}}=o_{i}\delta _{j}}
with
δ
j
=
∂ E
∂
o
j
∂
o
j
∂
net
j
=
{
∂ L ( t ,
o
j
)
∂
o
j
d φ (
net
j
)
d
net
j
if
j
is an output neuron,
(
∑
ℓ ∈ L
w
j ℓ
δ
ℓ
)
d φ (
net
j
)
d
net
j
if
j
is an inner neuron.