Backpropagation
Q: Explain backpropagation.
Backprop is the chain rule applied efficiently on the computation graph: run a forward pass and cache activations, then propagate ∂L/∂(output) backwards, multiplying by each layer's local Jacobian. Cost ≈ 2× the forward pass.
forward: x --W1--> z1 --ReLU--> a1 --W2--> z2 --softmax/CE--> L
backward: dz2 = p - y
dW2 = a1ᵀ dz2 da1 = dz2 W2ᵀ
dz1 = da1 * (z1 > 0) dW1 = xᵀ dz1
Key facts: gradients of a linear layer y = xW are dW = xᵀ·dy, dx = dy·Wᵀ; softmax + cross-entropy has the clean gradient p − y; autodiff frameworks implement exactly this (reverse-mode AD).