Backpropagation
How a neural network measures its mistakes and assigns blame. See how the chain rule passes errors backward to update every weight.
A neural network contains thousands or billions of weights. When the network makes a mistake, we need a mathematically exact way to answer: if we change this specific weight by a tiny amount, how much does the final loss change?
The Forward Cache
To calculate those changes later, the network must remember what it just did. During the forward pass, it caches every intermediate activation in a massive computation graph.
The Chain Rule
Calculus gives us the chain rule: to find the derivative of a composite function, multiply the derivatives of its parts. Backpropagation applies this by taking the final error and passing it backward, multiplying by the local derivative at each step.
One Pass, All Gradients
Because the graph was cached, a single backward pass sweeping from the output to the input computes the exact gradient for every parameter at the exact same time.
Depth Interaction
Since backpropagation relies on multiplying numbers together, a deep network risks exponential scaling. If the numbers are slightly less than 1, the gradient vanishes. If they are slightly more than 1, it explodes.
Where It Breaks
If gradients explode, a single update can throw the weights into entirely useless ranges, causing the loss to become NaN (Not a Number) and crashing training. The standard engineering patch is gradient clipping: manually capping the size of the update.
The Quick Version
- Backpropagation calculates how every weight affects the loss.
- The forward pass caches all intermediate activations.
- The chain rule pushes the error backward, multiplying local derivatives.
- A single backward sweep calculates gradients for every weight simultaneously.
- Multiplying derivatives through many layers causes gradients to vanish or explode.
- Exploding gradients crash training, requiring clipping as an engineering fix.