Skip to content

AI Glossary · Concepts

What is Vanishing and Exploding Gradients?

Vanishing and Exploding Gradients

Vanishing and exploding gradients are training failures in deep neural networks where the error signal used to update early layers shrinks toward zero (vanishing) or grows uncontrollably (exploding) as it passes back through many layers. Either way, the network learns badly or not at all.

Also known as: vanishing gradient, exploding gradient, vanishing gradient problem, exploding gradient problem

· Chain of Thought

Model Training

  • 4 sources

Think of a game of telephone with 100 people. By the end, a whispered message has either faded to nothing or been exaggerated into nonsense. Deep networks have a similar problem during backpropagation, the step that sends the error back from the output to every layer so each can adjust. The signal is multiplied layer by layer; if those multipliers are mostly below 1 it vanishes, and if mostly above 1 it explodes.

With vanishing gradients, the early layers barely change, so the network can’t learn long-range patterns; this is a big reason older recurrent networks struggled to remember the start of a long sentence. With exploding gradients, updates become huge and the loss jumps to enormous values or “NaN” (not a number), and training fails to reach convergence.

Much of modern deep learning design is a set of fixes for this. Activation functions such as ReLU avoid squashing the signal; careful weight initialization keeps multipliers near 1; LSTM cells in recurrent networks give information a protected path; residual connections, introduced in ResNet and used in every transformer, let the signal skip layers. Gradient clipping caps how large an update can be, and a modest learning rate with warm-up helps too. When a large training run “spikes” or diverges, engineers check these first.

Sources