Last updated October 16, 2026
\[\boldsymbol\theta\leftarrow\boldsymbol\theta-\eta\nabla_{\boldsymbol\theta}J.\]
The parameters now sit inside a composition of many layers.
Backpropagation computes \(\nabla_{\boldsymbol\theta}J\) efficiently. Gradient descent (or Adam) uses those gradients to update the parameters.
Training loop: forward computation → backpropagation → parameter update.
For \(a=f(\theta)\), \(b=g(a)\), and \(\ell=q(b)\):
\[\frac{\partial\ell}{\partial\theta} =\frac{\partial\ell}{\partial b}\, \frac{\partial b}{\partial a}\, \frac{\partial a}{\partial\theta}.\]
Forward: \(\theta\to a\to b\to\ell\); save the values needed by the derivatives.
Backward: start with \(\frac{\partial\ell}{\partial\ell}=1\), then compute
\[\frac{\partial\ell}{\partial b}=\frac{\partial q(b)}{\partial b},\qquad \frac{\partial\ell}{\partial a}=\frac{\partial\ell}{\partial b}\,\frac{\partial b}{\partial a},\qquad \frac{\partial\ell}{\partial\theta}=\frac{\partial\ell}{\partial a}\,\frac{\partial a}{\partial\theta}.\]
Same chain rule, reversed evaluation order. We need the forward output to evaluate the loss’s derivative, and saved intermediate values to evaluate the local derivatives.
For a batch \(\mathcal B\) of \(B\) examples, use the mean loss:
\[J_{\mathcal B}(\boldsymbol\theta)=\frac1B\sum_{i\in\mathcal B}\ell_i(\boldsymbol\theta), \qquad \nabla_{\boldsymbol\theta}J_{\mathcal B}=\frac1B\sum_{i\in\mathcal B}\nabla_{\boldsymbol\theta}\ell_i.\]
An epoch visits the training set once. Monitor validation performance across epochs to choose when to stop.
For an MLP with biases, that includes \(W,\boldsymbol b,V,\boldsymbol c\).
We specify the model and loss; automatic differentiation organizes the chain rule.
Next topic: implement this training cycle in PyTorch.
In 1D: \(\displaystyle\frac{\partial J}{\partial\theta}\approx\frac{J(\theta+\epsilon)-J(\theta)}{\epsilon}\).
One objective evaluation takes 1 second. Reuse the unperturbed value \(J(\boldsymbol\theta)\).
Finite differences: about how long for 10,000 parameters?
A. 2 seconds
B. 100 seconds
C. 10,000 seconds
C: 10,000 parameters → about 10,000 seconds.
One new evaluation per parameter.
Backpropagation: how long for the same full gradient?
Assume backward ≈ forward cost.
A. 2 seconds
B. 100 seconds
C. 10,000 seconds
A: about 2 seconds for forward + backward.
One reverse pass reuses work for all parameters.