What is an exploding gradient?
An exploding gradient is a sudden, very large rise in the gradient norm computed by backpropagation during training. In recurrent networks especially, contributions from distant time steps can grow exponentially until one update wrecks the parameters.
The vanishing gradient is the opposite: distant contributions shrink towards zero and links between events far apart in time go unlearnt. Both stem from long chains of multiplied matrices.
- Topic
- Machine learning, models and training
- Also known as
- Exploding gradient problem
- Origin
- 1994 study; 2013 ICML study proposed gradient norm clipping
How an exploding gradient works
- Backpropagation multiplies matrices across layers or time steps.
- Such a product can shrink to zero or blow up; a recurrent matrix whose largest eigenvalue exceeds 1 is necessary for explosion.
- Steep walls form in the error surface; a gradient step hitting one can be thrown out of the valley.
- Rescaling gradients whose norm crosses a threshold limits the damage; normalised initialisation and normalisation layers also largely address it in deep networks.
In more detail
The necessary condition for explosion
In the analysis of a linear recurrent network, a largest eigenvalue of the recurrent weight matrix below 1 is sufficient for long term components to vanish, while a largest eigenvalue above 1 is necessary for gradients to explode. The same study generalised these results to nonlinear activation functions whose derivative is bounded.
Commonly confused terms
| Term | How it differs |
|---|---|
| Gradient clipping | An exploding gradient is a problem that arises during training; gradient clipping is a remedy that rescales a gradient whose norm crosses a threshold while keeping its direction. Clipping does not remove the cause of the explosion; it limits the damage a single step can do. |
Why an exploding gradient matters for on-premises AI
A 2013 study revisited this problem (first detailed in 1994) and proposed gradient norm clipping, finding that clipping solves an optimisation issue rather than acting as a regulariser. The threshold can be set from the average gradient norm over many updates, so long runs log the norm at every step.
A logistics company training a recurrent delivery time model on its own servers sees the loss jump at some steps. The team logs the gradient norm, finds the spikes cluster in long shipment histories, enables norm clipping and sets the threshold from earlier average norms.
Common questions
How is an exploding gradient spotted?
The clearest sign is a gradient norm that suddenly becomes very large while the loss jumps within a few steps. That is why the gradient norm is logged throughout training.
Does it only happen in recurrent networks?
No. It is most visible in recurrent networks but can also block convergence from the start in very deep networks. There, normalised initialisation and normalisation layers largely reduce the problem.
Related terms
Sources
- On the difficulty of training recurrent neural networks, ICML, 2013
- Deep Residual Learning for Image Recognition, arXiv, 2015
In the glossary: Glossary, E to L