Vanishing and Exploding Gradients
In deep or recurrent networks, gradients are multiplied through many layers and can shrink to nothing or blow up, so early layers stop learning or training becomes unstable.
Also vanishing gradient problem · exploding gradients · gradient clipping
Hochreiter, 1991; Bengio, Simard and Frasconi, 1994
A whisper passed along a line of 50 people fades to nothing by the end. A shout that each person makes a bit louder becomes a deafening roar. Signals multiplied many times either vanish or explode.
Where it fits
+All relationships as a list
How it works
Backpropagation computes gradients by multiplying local slopes along the computational graph. In a deep network that is a long product: one factor per layer.
- If the factors are typically smaller than 1, the product shrinks exponentially. The first layers receive almost no gradient and stop learning: vanishing gradients.
- If they are typically larger than 1, it grows exponentially. Updates become huge and training diverges: exploding gradients.
The sigmoid is a classic culprit: its slope is at most 0.25, so ten sigmoid layers can scale the gradient by . Recurrent networks suffer even more, because the same weights are multiplied once per time step.
Almost every modern architecture contains a fix:
- ReLU and friends: slope 1 for positive inputs. See activation functions.
- Good weight initialization keeps signals at a steady size at the start.
- Normalization layers rescale activations at every layer.
- Residual connections give gradients a direct highway to early layers.
- Gates in LSTMs and GRUs let information and gradients pass through time almost unchanged.
- Gradient clipping caps the gradient’s size to stop explosions.
Everyday use cases
- Case 01
Why deep nets were hard before 2010
Networks with many sigmoid layers barely trained; fixes for vanishing gradients unlocked deep learning.
- Case 02
Training RNNs
Plain RNNs forget anything more than a few dozen steps back; LSTMs were designed to fix exactly this.
Strengths, weaknesses and when to use it
Strengths
- Understanding it explains many architecture choices (ReLU, residuals, LSTM gates, normalization).
Weaknesses
- Not a technique but a failure mode; diagnosing it requires watching gradient norms per layer.
When to use itWhen a deep network's loss will not decrease, early layers barely change, or the loss suddenly becomes NaN.
Compare with
Check yourself
- Q01
Why does a stack of sigmoid layers suffer from vanishing gradients?
Show answer
A: The sigmoid's derivative is at most 0.25, and many small factors multiply
- Q02
Which technique is the standard fix for exploding gradients?
Show answer
A: Gradient clipping