Backpropagation Algorithm
Computes how much each weight contributed to the error, using the chain rule.
The idea
After a forward pass computes the loss, backpropagation works backwards through the network. At each layer it multiplies the incoming gradient by the local derivative (the chain rule), producing the gradient of the loss with respect to every weight in one sweep, at a cost comparable to one forward pass.
∂L/∂W = δ · aᵀ, δ_prev = (Wᵀδ) ⊙ f′(z)
Watch it run
This is a real computation, not a drawing. Pause, step, change the settings, or try new random data.
- predicts 0
- predicts 1
Random weights: the network guesses about 50% everywhere, so the map is a washed-out mush. XOR needs a bent boundary.
- epoch:
- 0
- loss:
- 2.114
- accuracy:
- 50%
Left: what the network predicts across the square. Right: the loss falling. The four ringed dots are XOR's corners.
Step by step
- 1Forward pass: compute and store every layer's activations and the loss.
- 2Compute the gradient of the loss at the output.
- 3Move back one layer: multiply by the activation derivative and the transposed weights.
- 4Collect the gradient for each layer's weights.
- 5Update the weights with an optimiser.
Where it is used
Training every modern neural network.
Watch out for
Gradients can vanish or explode in deep networks; it needs differentiable operations.