Backpropagation as local derivatives passed backward

← Back to Blog & Articles

Backpropagation computes ∂J/∂W^(l) for every layer by applying the chain rule from the output backward.

Define the layer's error signal δ^(l) = ∂J/∂z^(l). At the output layer (say, squared error J = (1/2)‖ŷ - y‖², identity output activation), δ^(L) = ŷ - y. For earlier layers, the chain rule gives:

δ^(l) = (W^(l+1))^T δ^(l+1) ⊙ g'(z^(l))

where ⊙ is elementwise multiplication. This recursion is why it's called back-propagation: δ^(l) depends only on δ^(l+1) (the layer after it) and locally-computable quantities, letting the error signal be computed layer-by-layer from output back to input in a single backward pass. The weight gradient itself is then a local, one-line computation given δ^(l):

∂J/∂W^(l) = δ^(l) (a^(l-1))^T

Derivation of the recursion. By the chain rule, δ^(l)_i = Σ_j (∂z^(l+1)_j / ∂z^(l)_i)(∂J/∂z^(l+1)_j). Since z^(l+1)_j = Σ_k W^(l+1)_jk a^(l)_k = Σ_k W^(l+1)_jk g(z^(l)_k), we get ∂z^(l+1)_j/∂z^(l)_i = W^(l+1)_ji g'(z^(l)_i). Substituting and factoring out g'(z^(l)_i) recovers exactly the corresponding matrix form. This entire derivation is nothing more than the multivariate chain rule applied systematically, layer by layer — the "trick" of backpropagation is realizing that this repeated application can be organized as two passes (forward to compute activations, backward to compute error signals) that together cost only about twice the forward pass, rather than the exponentially expensive naive approach of perturbing each weight independently.

Continue with the book

Explore the full treatment, worked examples, and exercises in The AI Algorithms Compendium.


Companion article for The AI Algorithms Compendium, published by Choral Software. Article text and original examples © 2026 Choral Software. All rights reserved.

Scroll to Top