Backpropagation by Hand: Output-Layer Error Term and Parameter Gradients
Agent-Assisted Engineering Check
Prerequisites
Day 34 forward ledger for network N1 ($o = 3.1255$, $L = 4.5179$).
Learning Objective
Apply the chain rule in staged form to the output layer of N1: define the error term $\delta = \partial L / \partial o$, then compute $\partial L / \partial w_{o1}$, $\partial L / \partial w_{o2}$, and $\partial L / \partial b_o$ as upstream-times-local products.
Instructions
Work the derivation symbolically first, then substitute numbers.
For the linear output neuron $o = w_{o1} a_1 + w_{o2} a_2 + b_o$ and loss $L = (o - y)^2$:
1. Output error term: $\delta_o = \frac{\partial L}{\partial o} = 2(o - y)$.
2. Local input gradients: $\frac{\partial o}{\partial a_1} = w_{o1}$, $\frac{\partial o}{\partial a_2} = w_{o2}$.
3. Local parameter gradients: $\frac{\partial o}{\partial w_{o1}} = a_1$, $\frac{\partial o}{\partial w_{o2}} = a_2$, $\frac{\partial o}{\partial b_o} = 1$.
4. Chain rule: every parameter gradient equals upstream $\delta_o$ times the local derivative: $\frac{\partial L}{\partial w_{o1}} = \delta_o \cdot a_1$.
Substitute the Day 34 ledger values $o = 3.1255$, $a_1 = 0.8741$, $a_2 = -0.9757$ and predict the three output-layer gradients before checking the answer.
Practice & Prediction Log
1. Derive $\delta_o$ symbolically for $L = (o - y)^2$.
2. Compute the numeric values of $\partial L / \partial w_{o1}$, $\partial L / \partial w_{o2}$, $\partial L / \partial b_o$.
3. Explain why the bias gradient always equals $\delta_o$ for a linear unit.
4. State which activation the gradient into hidden neuron $h_1$ must still pass through.
$\delta_o = 2(3.1255 - 1.0) = 4.2511$. The product rule for $o = w_{o1} a_1 + \cdots$ makes each weight gradient proportional to the activation it multiplies. Bias multiplies nothing, so its local derivative is exactly $1$.
Reference Solution:
1. $\delta_o = 2(o - y) = 4.2511$.
2. $\partial L / \partial w_{o1} = 4.2511 \times 0.8741 = 3.7157$; $\partial L / \partial w_{o2} = 4.2511 \times (-0.9757) = -4.1480$; $\partial L / \partial b_o = 4.2511 \times 1 = 4.2511$.
3. Because $o = \cdots + 1 \cdot b_o$, the local derivative $\partial o / \partial b_o = 1$, so the bias gradient inherits the full upstream delta.
4. The gradient reaching $a_1$ is $\delta_o \cdot w_{o1} = 4.2511$; it must still multiply through $\tanh'(z_1) = 1 - a_1^2$ to reach $z_1$.
The learner reproduces all three output-layer gradients within $10^{-3}$ of the engine values ($3.7157$, $-4.1480$, $4.2511$) and explains the upstream-times-local structure without looking at the answer.
Authoritative Source Resources & Provenance
Neural Networks and Deep Learning: How the backpropagation algorithm works
Relevant Section / Range: The four fundamental equations of backpropagation
Verified Version & Date: Online book (Verified: 2026-10-30)
Clear four-equation derivation of backpropagation with scalar and matrix notation.
Matrix multiplication and the multivariable chain rule from Days 19-24.
All four backprop equations and derivations are self-contained within the lesson text.
Compared Candidate Sources & Selection Analysis (2)
Comprehensive graduate reference, but heavier tensor notation than needed for first MLP derivations.
Modular computational graph view; used as secondary source on Days 35-36.
CS231n: Backpropagation and Intuitions
Relevant Section / Range: Patterns in backward flow
Verified Version & Date: Course notes (Verified: 2026-10-30)
Modular local-gradient interpretation (gate operations: add, multiply, max) and gradient flow intuition.
Multivariable calculus and basic Python.
Local gate definitions and circuit flow diagrams in the lesson provide full coverage.
Compared Candidate Sources & Selection Analysis (2)
Raw circuit view; CS231n notes are more structured with explicit gate derivations.
Top-down approach; CS231n bottom-up modular view matches our first-principles curriculum.