This is a self-test page for Backpropagation Algorithm Derivation. Every problem states its level (L1 Recognition → L5 Mastery). Try each one first, then open the collapsible solution. Numbers are checked in the vault's verify system, so trust them.
Throughout we reuse four equations, called BP1–BP4. So this page stands alone, here they are in full before any exercise uses them.
If any symbol looks unfamiliar, it is defined here before we use it — nothing is assumed.
Two number facts we lean on all page (memorise them):
Figure 1 — the 2-2-1 test network. Two butter-yellow input nodes on the left feed two mint hidden neurons (each storing a z(1)), which feed one coral output neuron (z(2)). Lavender arrows are the weights W(1); coral arrows are W(2). The grey arrow along the bottom marks the direction blame flows during backprop: output → inputs. Keep this picture in view for Exercises 3.x.
Which of the four equations produces the gradient you actually feed to Gradient descent for a weight matrix, and which produces the starting error at the output layer?
Recall Solution
WHAT we're asked: just match names to jobs.
The gradient for a weight matrix is BP3: ∂W(l)∂L=δ(l)(a(l−1))⊤.
The starting error at the output is BP1: δ(L)=∇aL⊙σ′(z(L)).
WHY: Gradient descent updates parameters (W, b), so it needs BP3/BP4. But BP3 needs δ, and the whole δ chain has to start somewhere — that start is BP1 at the last layer, because the last layer is the only one that touches the loss directly.
In δ(l)=((W(l+1))⊤δ(l+1))⊙σ′(z(l)), name each of the three pieces in plain English.
Recall Solution
(W(l+1))⊤δ(l+1) — "take the next layer's blame and route it backward through the weights, flipped." The flip (transpose) is because blame travels outputs→inputs.
⊙ — "elementwise gate," multiply position-by-position, no summing across.
σ′(z(l)) — "how sensitive this neuron's output was to its own input at the value it actually saw." If the neuron was in a flat part of σ, this is near 0 and it blocks the blame.
A ReLU neuron with z=−2, and incoming blame from the layer above of ((W)⊤δnext)=0.9. Find this neuron's δ.
Recall Solution
WHAT: apply BP2 for one neuron: δ=(routed blame)×σ′(z).
WHY the sign matters: ReLU′(z)=0 when z<0. Here z=−2<0, so:
δ=0.9×ReLU′(−2)=0.9×0=0.
The neuron was "off," so it forwarded a constant 0; changing its input changes nothing downstream, hence zero blame. This dead-zone is why very negative pre-activations kill gradients — see Vanishing and exploding gradients.
Use the 2-2-1 network from Figure 1 (all values below repeated so you needn't flip back).
Input x=[10], target y=1, sigmoid, MSE.
W(1)=[0.10.30.20.4], b(1)=0, W(2)=[0.50.6], b(2)=0.
Compute the bias gradients∂L/∂b(2) and ∂L/∂b(1).
Recall Solution
WHY biases are easy:∂zj(l)/∂bj(l)=1, so BP4 says the bias gradient equals the delta. No extra multiply.
From the parent note's worked forward+backward pass:
Same network. Take one gradient-descent step on W(2) with learning rate η=1.0.
Recall ∂L/∂W(2)=[−0.0423,−0.0462]. Give the updated W(2) and say whether the output moved toward the target.
Recall Solution
Update rule (Gradient descent): W←W−η∂L/∂W.
Wnew(2)=[0.5,0.6]−1.0⋅[−0.0423,−0.0462]=[0.5423,0.6462].Did we improve? The gradient was negative, meaning "increasing W(2) decreases loss." We increased W(2), so loss should drop. Concretely a larger W(2) raises z(2), raises a(2) toward the target y=1 (we were at 0.647, target 1). ✔ moves toward the target.
Figure 2 — why the gradient's sign sets the step direction. The lavender curve is the loss L as a function of one weight W. At the current weight (grey dot) the tangent (dashed coral) slopes downward to the right, i.e. the gradient is negative. The mint arrow shows the resulting move: step right (increase W) to slide downhill. This is exactly the negative-gradient in Exercise 3.2.
Build a small case where the sigmoid gate itself shrinks the gradient. A hidden neuron has z(l)=6. Its routed blame (W(l+1))⊤δ(l+1)=2.0. Compute δ(l), and compare it to a neuron with z=0 receiving the same routed blame 2.0.
Central neuron (z=0): σ′(0)=0.5×0.5=0.25.
δcenter=2.0×0.25=0.5.The point: same incoming blame, but the saturated neuron passes back ≈100× less. Stack many such layers and the product of tiny σ′ factors vanishes — that is Vanishing and exploding gradients in one line.
Figure 3 — the sigmoid slope σ′(z) is a bell. Mint curve: σ′(z)=a(1−a), peaking at 0.25 when z=0 (coral dot, "fastest learning"). Far out at z=6 (lavender dot) the slope has collapsed to ≈0.0025, so incoming blame is almost entirely blocked. Both flat tails cause vanishing gradients.
Prove BP2 is dimension-forced. Layer l has nl=3 neurons, layer l+1 has nl+1=2 neurons, so W(l+1) is 2×3. Given δ(l+1) has length 2, show that only the transpose produces a length-3 result, and confirm elementwise-multiplying by σ′(z(l)) (length 3) is legal.
Recall Solution
Shapes are the whole proof.
W(l+1) maps activations of layer l (length 3) → pre-activations of layer l+1 (length 2). A matrix that maps length-3 to length-2 is 2×3. ✔
Try W(l+1)δ(l+1): that is (2×3)⋅(3×1) — but δ(l+1) has length 2, not 3, so the inner dimensions (3 vs 2) don't match. Illegal. ✘
Try (W(l+1))⊤δ(l+1): that is (3×2)⋅(2×1)=(3×1). Inner dims 2=2 match, output length 3. ✔
Now ⊙σ′(z(l)): σ′(z(l)) has length 3 (one per layer-l neuron). Elementwise product of two length-3 vectors is length 3. ✔ Legal, and gives the required δ(l) of length 3.
Conclusion: the transpose is not a stylistic choice — it is the only linear map that returns blame to the correct number of neurons. We say the forward map W and the backward map W⊤ are adjoints of each other: an "adjoint" is just the linear-algebra name for the transpose partner that sends a signal back through the reverse wiring. Forward pushes inputs→outputs; its adjoint W⊤ pushes blame outputs→inputs.
Cross-entropy + sigmoid collapse. For a single output neuron with sigmoid and binary cross-entropy loss
L=−[yloga+(1−y)log(1−a)],
show that BP1 simplifies to δ(L)=a−y (the messy σ′ cancels).
σ′(z)=a(1−a).
Multiply:
δ(L)=a(1−a)a−y⋅a(1−a)=a−y.WHY this is beautiful: the a(1−a) that causes vanishing gradients in the sigmoid cancels exactly against the cross-entropy denominator. So the output layer never saturates its own learning signal — a strong reason to pair sigmoid with cross-entropy rather than MSE. Compare with Exercise 2.1, where MSE kept the σ′ factor alive. (See Loss functions (MSE, cross-entropy).)
Recall Quick self-check (cloze — hidden terms in
==...==)
BP4 says the bias gradient equals the delta δ(l) because ∂z/∂b=1.
The backward pass uses W⊤ because forward and backward maps are adjoints (transposes) of each other.
For sigmoid + cross-entropy the output error collapses to ==a−y==.
A neuron with very large ∣z∣ passes back a tiny gradient because σ′(z)≈0.
Why does the transpose (not W) appear in BP2?
Blame flows outputs→inputs (the adjoint direction), and only W⊤ maps a length-nl+1 delta back to length nl.