Skip to content

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

Fig. / How it works
Role · kind
Failure modes and risksConcept
Level
Intermediate

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

See it on the full map

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 0.2510≈10−60.25^{10} \approx 10^{-6}. Recurrent networks suffer even more, because the same weights are multiplied once per time step.

Almost every modern architecture contains a fix:

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

  1. 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

  2. Q02

    Which technique is the standard fix for exploding gradients?

    Show answer

    A: Gradient clipping

Go deeper

Learn first