Understanding the exploding gradient problem

Razvan Pascanu, Tomás Mikolov, Yoshua Bengio

Abstract

There are two widely known issues with properly training Recurrent Neural Networks, the vanishing and the exploding gradient problems detailed in Bengio et al. (1994). In this paper we attempt to improve the understanding of the underlying issues by exploring these problems from an analytical, a geometric and a dynamical systems perspective. Our analysis is used to justify a simple yet effective solution. We propose a gradient norm clipping strategy to deal with exploding gradients and a soft constraint for the vanishing gradients problem. We validate empirically our hypothesis and proposed solutions in the experimental section.

Introduction

Recurrent Neural Networks (RNNs) are theoretically capable of modeling complex temporal dependencies by maintaining a hidden state that evolves over time. However, training these models using Backpropagation Through Time (BPTT) has historically proven difficult. This paper investigates the fundamental reasons behind these training challenges, specifically focusing on the vanishing and exploding gradient problems.

The Vanishing and Exploding Gradient Problems

The core difficulty in training RNNs arises from the repeated multiplication of the same weight matrix during backpropagation. As the error signal is propagated back through many time steps, the gradient's magnitude is governed by the eigenvalues of the recurrent weight matrix.

Backpropagation through time (BPTT) in an RNN, illustrating the chain of gradients.

If these eigenvalues are significantly greater than one, the gradient can grow exponentially, leading to "exploding gradients" that cause unstable weight updates and model crashes. Conversely, if the eigenvalues are less than one, the gradient shrinks to zero, resulting in "vanishing gradients." In the latter case, the network fails to learn long-term correlations because the influence of distant past inputs on the current error becomes negligible.

Proposed Solutions: Clipping and Regularization

To address these issues, two distinct strategies are proposed:

  1. Gradient Norm Clipping: To mitigate exploding gradients, we introduce a simple yet effective heuristic. If the norm of the gradient exceeds a predefined threshold, it is rescaled. This prevents the optimizer from taking excessively large steps when encountering high-curvature regions of the error surface.
  2. Vanishing Gradient Regularization: To combat vanishing gradients, we propose a soft constraint in the form of a regularization term. This term encourages the Jacobian of the hidden state transformation to maintain its norm, ensuring that the gradient signal persists across many time steps.

A Geometric and Dynamical Systems Perspective

The difficulty of training is further illuminated by viewing the RNN as a dynamical system. Exploding gradients often correspond to the system crossing a bifurcation boundary, where a small change in parameters leads to a qualitative change in behavior. Geometrically, these events manifest as "walls" or steep cliffs in the error surface.

Error surface of an RNN showing a steep 'wall' and the effect of gradient clipping.

As shown in the visualization of the error surface, when the optimizer hits such a wall, standard SGD would normally be catapulted far from the local minimum. Gradient clipping allows the model to safely navigate these regions by limiting the step size, effectively moving the weights along the face of the wall rather than off it.

Experimental Validation

The proposed methods were evaluated on both synthetic and natural tasks. On pathological synthetic problems designed to test long-term memory (e.g., the Temporal Order and Addition tasks), standard RNNs failed completely for sequences longer than 20 steps. In contrast, the enhanced algorithm (SGD-CR) achieved 100% success even for sequences of 200 steps. Furthermore, the methods demonstrated state-of-the-art performance on real-world tasks such as polyphonic music prediction and character-level language modeling, rivaling more complex architectures like LSTMs.

Conclusion

By combining analytical insights with geometric and dynamical systems perspectives, we have provided a clearer understanding of why RNNs are hard to train. The proposed solutions—gradient norm clipping and a vanishing gradient regularizer—offer a robust way to improve RNN training, enabling these models to capture long-term dependencies more effectively.

Summary updated

BibTeX
@inproceedings{pascanu2013understanding,
  author = {Razvan Pascanu and Tomás Mikolov and Yoshua Bengio},
  title = {{Understanding the exploding gradient problem}},
  booktitle = {International Conference on Machine Learning},
  year = {2013},
  url = {https://openreview.net/forum?id=B1WYPobdbS},
}
Figure