Backpropagation derivation using Leibniz notation: Difference between revisions

From Machinelearning
No edit summary
No edit summary
Line 16: Line 16:


<math display="block">\frac{\partial a^{l+1}_i}{\partial a^l_j} = \sigma'(z^{l+1}_i)w^{l+1}_{ij}</math>
<math display="block">\frac{\partial a^{l+1}_i}{\partial a^l_j} = \sigma'(z^{l+1}_i)w^{l+1}_{ij}</math>
Putting all this together, we obtain
<math display="block">\begin{align}\frac{\partial C}{\partial w^l_{jk}} &= \frac{\partial C}{\partial a^l_j} \frac{\partial a^l_j}{\partial w^l_{jk}} \\ &= \left(\sum_{i \in \{1,\ldots,n(l+1)\}} \frac{\partial C}{\partial a^{l+1}_i} \frac{\partial a^{l+1}_i}{\partial a^l_j}\right) \sigma'(z^l_j)a^{l-1}_k \\ &= \left(\sum_{i \in \{1,\ldots,n(l+1)\}} \frac{\partial C}{\partial a^{l+1}_i} \sigma'(z^{l+1}_i)w^{l+1}_{ij}\right) \sigma'(z^l_j)a^{l-1}_k\end{align}</math>

Revision as of 22:44, 8 November 2018

The cost function C depends on wjkl only through the activation of the jth neuron in the lth layer, i.e. on the value of ajl. Thus we can use the chain rule to expand:

∂C∂wjkl=∂C∂ajl∂ajl∂wjkl

We know that ∂ajl∂wjkl=σ′(zjl)akl−1 because ajl=σ(zjl)=σ(∑kwjklakl−1+bjl). We have used the chain rule again here.

In turn, C depends on ajl only through the activations of the (l+1)th layer. Thus we can write:

∂C∂ajl=∑i∈{1,…,n(l+1)}∂C∂ail+1∂ail+1∂ajl

where n(l+1) is the number of neurons in the (l+1)th layer.

Backpropagation works recursively starting at the later layers. Since we are trying to compute ∂C∂ajl for the lth layer, we can assume inductively that we have already computed ∂C∂ail+1.

It remains to find ∂ail+1∂ajl. But ail+1=σ(zil+1)=σ(∑jwijl+1ajl+bil+1) so we have

∂ail+1∂ajl=σ′(zil+1)wijl+1

Putting all this together, we obtain

∂C∂wjkl=∂C∂ajl∂ajl∂wjkl=(∑i∈{1,…,n(l+1)}∂C∂ail+1∂ail+1∂ajl)σ'(zjl)akl−1=(∑i∈{1,…,n(l+1)}∂C∂ail+1σ′(zil+1)wijl+1)σ'(zjl)akl−1