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 designed to process sequences by maintaining a "hidden state" that persists over time. In theory, this allows them to learn long-term dependencies, such as connecting a word from the beginning of a sentence to its conclusion. However, in practice, RNNs have historically been an optimization nightmare due to the way error signals are propagated back through time (BPTT).
The Gradient Problem in RNNs
As error signals are backpropagated, they are repeatedly multiplied by the network's weight matrices. This leads to two catastrophic outcomes:
- Exploding Gradients: The gradient grows exponentially, causing model weights to "jump" to massive values and destroying training progress.
- Vanishing Gradients: The gradient shrinks to zero, meaning the model stops learning how to connect distant events in a sequence.
While these issues were identified in the 1990s, this paper seeks to explain why they happen through the lens of dynamical systems and the geometry of the "error surface."
Proposed Solutions
The authors introduce two primary algorithmic solutions to stabilize RNN training:
1. Gradient Norm Clipping
When the norm of the gradient exceeds a certain threshold, it is rescaled down. This ensures that the optimization step size stays within a reasonable range, even when the gradient "explodes." Unlike previous methods that clipped individual entries, this method preserves the direction of the gradient, allowing the optimizer to navigate high-curvature regions safely.
2. Vanishing Gradient Regularization
The authors propose a soft constraint (a regularization term) that encourages the Jacobian of the hidden state to preserve its norm as it travels back in time. This prevents the error signal from decaying to zero too quickly, facilitating the learning of long-range dependencies.
The Geometry of the Error Surface
A key insight of the paper is the visualization of the error surface. The authors discovered that exploding gradients correspond to "walls" of extremely high curvature. If a standard optimizer hits this wall, it gets catapulted far away from the local minimum. Clipping allows the optimizer to "bounce" off the wall and stay within the valley where the solution resides.
From a dynamical perspective, vanishing gradients happen when the hidden state converges too quickly to an attractor. If the system is too stable, it "forgets" the initial inputs that led it there. Exploding gradients, conversely, often occur near "bifurcation boundaries" where the qualitative behavior of the system changes abruptly.
Experimental Validation
The authors evaluated their methods on several challenges:
- Synthetic Tasks: On problems like Temporal Order and Addition, which require long-term memory, the version with clipping and regularization (SGD-CR) achieved 100% success on sequences up to 200 steps, whereas standard SGD failed beyond 20 steps.
- Natural Tasks: The approach reached state-of-the-art performance at the time on character-level language modeling (Penn Treebank) and polyphonic music prediction, proving that these geometric insights translate to real-world performance.
Conclusion
By framing the training of RNNs as a challenge of navigating complex geometry and dynamical stability, Pascanu et al. provided a theoretical justification for gradient clipping. Their work moved the field beyond viewing these issues as mere implementation hurdles, offering a robust framework for training deep recurrent architectures.
Summary updated