Backpropagation derivation using Leibniz notation: Difference between revisions

From Machinelearning
No edit summary
No edit summary
Line 3: Line 3:
Most of the notation on this page is borrowed from Michael Nielsen's book.<ref>[http://neuralnetworksanddeeplearning.com/chap2.html "Chapter 2: How the backpropagation algorithm works"] in ''Neural Networks and Deep Learning''. Michael A. Nielsen. ''Determination Press''. 2015. Retrieved November 8, 2018.</ref>
Most of the notation on this page is borrowed from Michael Nielsen's book.<ref>[http://neuralnetworksanddeeplearning.com/chap2.html "Chapter 2: How the backpropagation algorithm works"] in ''Neural Networks and Deep Learning''. Michael A. Nielsen. ''Determination Press''. 2015. Retrieved November 8, 2018.</ref>


<div style="border: 1px solid black; padding: 5px;">'''Theorem.''' Let <math>N</math> be a neural network with <math>L</math> layers and <math>n(l)</math> be the number of neurons in layer <math>l</math> for <math>l \in \{1, \ldots, L\}</math>. a cost function <math> C = \frac12 \sum_{j=1}^n(L)</div>
<div style="border: 1px solid black; padding: 5px;">'''Theorem.''' Let <math>N</math> be a neural network with <math>L</math> layers and <math>n(l)</math> be the number of neurons in layer <math>l</math> for <math>l \in \{1, \ldots, L\}</math>. Let <math>C = \frac12 \sum_{j=1}^{n(L)} (y_j - a^L_j)^2</math> be a cost function.</div>


''Proof.'' The cost function <math>C</math> depends on <math>w^l_{jk}</math> only through the activation of the <math>j</math>th neuron in the <math>l</math>th layer, i.e. on the value of <math>a^l_j</math>. Thus we can use the chain rule to expand:
''Proof.'' The cost function <math>C</math> depends on <math>w^l_{jk}</math> only through the activation of the <math>j</math>th neuron in the <math>l</math>th layer, i.e. on the value of <math>a^l_j</math>. Thus we can use the chain rule to expand:

Revision as of 23:54, 8 November 2018

This page presents a derivation/proof of backpropagation derivation using Leibniz notation. Leibniz notation is the most common notation for presenting backpropagation, but it is somewhat complicated due to its blurring of the function/value distinction and its reliance on functional relationships being implicit. Those who prefer function notation may wish to refer to backpropagation derivation using function notation instead of (or in addition to) this page.

Most of the notation on this page is borrowed from Michael Nielsen's book.[1]

Theorem. Let N be a neural network with L layers and n(l) be the number of neurons in layer l for l{1,,L}. Let C=12j=1n(L)(yjajL)2 be a cost function.

Proof. 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:

Cwjkl=Cajlajlwjkl

We know that ajlwjkl=σ(zjl)akl1 because ajl=σ(zjl)=σ(k=1n(l1)wjklakl1+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 (using the chain rule once again):

Cajl=i=1n(l+1)Cail+1ail+1ajl

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

It remains to find ail+1ajl. But ail+1=σ(zil+1)=σ(j=1n(l)wijl+1ajl+bil+1) so we have

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

Putting all this together, we obtain

Cwjkl=Cajlajlwjkl=(i=1n(l+1)Cail+1ail+1ajl)σ'(zjl)akl1=(i=1n(l+1)Cail+1σ(zil+1)wijl+1)σ'(zjl)akl1

Let us verify that we can calculate the right-hand side. By induction hypothesis, we can calculate Cail+1. We calculate zil+1, zjl, and akl1 during the forward pass through the network. Finally, wijl+1 is just a weight in the network, so we already know its value.

References

  1. "Chapter 2: How the backpropagation algorithm works" in Neural Networks and Deep Learning. Michael A. Nielsen. Determination Press. 2015. Retrieved November 8, 2018.