On the difficulty of training recurrent neural networks

Razvan Pascanu, Tomas Mikolov, Yoshua Bengio

TL;DR: This seminal paper provides a deep dive into why Recurrent Neural Networks (RNNs) are notoriously difficult to train, specifically focusing on the "vanishing" and "exploding" gradient problems. The authors offer a geometric and dynamical systems explanation for these phenomena and introduce two highly influential solutions: gradient norm clipping to handle exploding gradients and a novel regularization term to combat vanishing gradients.

The Challenge of Long-Term Dependencies

While RNNs are theoretically powerful for modeling sequences, they were historically difficult to optimize. In the 1990s, researchers identified that as errors are backpropagated through time, the gradients tend to either shrink to zero (vanishing) or grow uncontrollably (exploding).

The "vanishing" problem means the network "forgets" long-term dependencies, making it unable to link events separated by many time steps. Conversely, the "exploding" problem makes the optimization process unstable, as a single update can catapult the model's parameters into a regime where the error is massive. This paper seeks to move beyond just identifying these problems to understanding their underlying geometry and providing practical, robust solutions.

Dynamical Systems and Attractors

The authors analyze RNNs through the lens of dynamical systems and Jacobian matrices. They demonstrate that the gradient's behavior is tied to the spectral radius (the largest eigenvalue) of the recurrent weight matrix.

Bifurcation diagram illustrating state changes

From this perspective, vanishing gradients happen when the network's state converges too quickly to a "point attractor." If the state is at an attractor, it no longer retains information about where it came from (the past), causing the gradient to decay to zero. Furthermore, the authors use bifurcation theory to explain how small changes in parameters can lead to radical changes in the network's long-term behavior.

The "Cliff" Geometry and Gradient Clipping

The paper's most famous insight is the visualization of the error surface. Exploding gradients aren't just a numerical nuisance; they represent steep "walls" or "cliffs" in the optimization landscape. When an optimizer hits these walls, the massive gradient "kicks" the parameters far away, destroying training progress.

Error surface showing cliffs and gradient clipping

To combat this, the authors propose Gradient Norm Clipping. This simple but effective heuristic rescales the gradient down to a specific threshold if its norm exceeds that limit. Clipping acts as a safety harness, allowing the model to stay near the wall and descend along it rather than being launched into space. The authors emphasize that clipping is an optimization fix, not a regularizer—it makes Stochastic Gradient Descent (SGD) more robust to the specific geometry of RNNs without changing the underlying objective.

Vanishing Gradient Regularization

To address vanishing gradients, the authors introduce a soft constraint (a regularizer) that encourages the Jacobian of the hidden state to preserve its norm as it moves backward through time. This forces the network to maintain sensitivity to long-term inputs, preventing the rapid decay of error signals.

Key Results and Impact

The authors validated their approach on both pathological synthetic problems (like the "Temporal Order" and "Addition" problems) and real-world datasets (polyphonic music prediction and language modeling).

  • Solving the Unsolvable: Using gradient clipping and the proposed regularizer, the authors solved synthetic tasks for sequences up to 200 steps, previously considered nearly impossible for standard RNNs.
  • Generalization: A model trained on sequences of length 50-200 generalized to sequences of up to 5,000 steps without further training, suggesting the model learned actual stable attractors.
  • State-of-the-Art Performance: Their methods achieved state-of-the-art results for RNNs on polyphonic music datasets and character-level Penn Treebank, outperforming more complex second-order optimization methods in some cases.

Limitations

While highly effective, these methods introduce new hyperparameters: the gradient clipping threshold and the regularization weight. The vanishing gradient regularizer can also sometimes interfere with the model's ability to learn short-term correlations, and computing parts of the Jacobian adds computational overhead during training. Despite these limitations, gradient clipping remains a standard, indispensable tool in modern deep learning.

Summary updated

BibTeX
@inproceedings{pascanu2013difficulty,
  author = {Razvan Pascanu and Tomas Mikolov and Yoshua Bengio},
  title = {{On the difficulty of training recurrent neural networks}},
  booktitle = {International Conference on Machine Learning},
  year = {2013},
  url = {https://openreview.net/forum?id=B1WYPobdbS},
}
Figure