Source-linked AI summary

On the difficulty of training Recurrent Neural Networks

Razvan Pascanu, Tomas Mikolov, Yoshua Bengio

arXiv:1211.5063v2cs.LG

TL;DR

Training recurrent neural networks is difficult because gradients can vanish or explode over long time spans. This paper analyzes these problems from analytical, geometric, and dynamical-systems perspectives, then proposes gradient clipping and soft Jacobian regularization, achieving strong performance on pathological sequence-learning tasks.

  • Problem

    Recurrent neural networks are difficult to train properly because of vanishing and exploding gradient problems.

  • Method

    The paper analyzes gradient behavior from multiple perspectives and uses gradient-norm clipping plus soft regularization to preserve error-signal norms in relevant directions.

  • Results

    The proposed approach achieved 100% success on nearly all listed pathological tasks and generalized across sequence lengths with single models.

  • Takeaways & Limitations

    The analysis supports combining gradient clipping with direction-specific soft regularization to address exploding and vanishing gradients in recurrent networks.

  • Takeaways & Limitations

    Soft regularization does not ensure error-signal norms are preserved and can bring the model closer to regions where gradients explode.

Abstract

from arXiv · show

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.

1. Introduction

RNNs model time series by retaining information through recurrent hidden-unit connections, but they are difficult to train because of vanishing and exploding gradients. The paper introduces analytical, geometric, and dynamical-systems perspectives to study these problems and motivates gradient norm clipping and a soft constraint.

  • 1. Introduction: RNNs model time series by using delayed hidden-unit connections to retain information about past inputs and discover temporal correlations.The recurrent connections allow information to persist from one input to another.
  • 1. Introduction: Despite their simplicity and power in principle, RNNs are difficult to train properly because of vanishing and exploding gradients.These problems are described in Bengio et al. (1994).
  • 1. Introduction: Backpropagation Through Time represents the recurrent model as a deep network with an unbounded number of layers by unrolling it across time.Backpropagation is then applied to the unrolled model.
  • 1. Introduction: The paper rewrites BPTT gradients in sum-of-products form to expose exploding-gradient behavior and analyzes individual temporal contributions that transport error backward through time.Long-term contributions correspond to k ≪ t, while short-term contributions comprise the remaining components.

2. Exploding and Vanishing Gradients

The section analyzes exploding and vanishing gradients through Jacobian products, recurrent-weight eigenvalues, and dynamical-systems behavior. It shows how attractor-boundary crossings and curvature can produce exploding gradients, including in input-driven models.

  • Analytical perspective: Products of Jacobian matrices can shrink toward zero or grow without bound along some direction, explaining vanishing and exploding temporal components.The product contains t−k Jacobian factors, paralleling the behavior of products of real numbers.
  • Analytical perspective: For the linear model, long-term components vanish when the largest recurrent-weight eigenvalue is below 1, while exploding gradients require it to exceed 1.The nonlinear analysis bounds activation derivatives; tanh has γ = 1 and sigmoid has γ = 1/4.
  • Dynamical-systems perspective: Crossing a basin-of-attraction boundary is sufficient for gradients to explode, whereas crossing a bifurcation boundary is neither necessary nor sufficient.Small parameter changes can send the system toward different attractors, producing large changes in x_t for large t.
  • Dynamical-systems perspective: The input-driven extension folds inputs into step-specific maps and studies their asymptotic behavior to identify conditions where trajectories diverge and gradients become large.The maps must agree and change direction in at least some direction, unless the input maps oppose this behavior.
  • Geometric perspective: If gradients grow at least as Cα^t for α > 1 along a direction v, the section hypothesizes that curvature also explodes, creating a wall in the error surface.For the linear case, v is the eigenvector associated with the largest recurrent-weight eigenvalue.

3. Dealing with the exploding and vanishing gradient

The paper reviews existing approaches to exploding and vanishing gradients, then proposes norm clipping for sudden gradient explosions and a soft regularizer that favors preserving error-signal norms during backpropagation.

  • Related approaches: Alternative solutions include LSTM units, Hessian-Free optimization with structural damping, and Echo State Networks, each addressing gradient behavior through architecture, optimization, or fixed recurrent weights.The reviewed approaches have stated limitations, including teacher forcing’s requirement for targets at every time step and Echo State Networks’ difficulty with long-term dependencies.
  • Exploding gradients: Norm clipping rescales gradients whenever their norm exceeds a threshold, providing a simple and computationally efficient response to sudden explosions.The method adds a threshold hyper-parameter and uses instantaneous gradient norms, allowing it to handle abrupt norm changes.
  • Exploding gradients: The clipping algorithm differs from Mikolov’s element-wise approach by aiming to preserve a descent direction for the current mini-batch, although both variants behave similarly in practice.The paper identifies gradient clipping as the backbone of its approach.
  • Vanishing gradients: For vanishing gradients, the proposed regularization prefers parameter values such that back-propagated error signals preserve their norm as they travel backward through time.The authors motivate increasing gradient norms even at the cost of temporarily larger errors from irrelevant inputs, which the network can subsequently learn to ignore.
  • Vanishing gradients: The regularizer is a soft constraint applied for the current error direction rather than all directions, so it does not ensure norm preservation and may still permit exploding gradients.The paper therefore combines this treatment with gradient clipping for cases where Jacobian products cause norms to grow over time.

4. Experiments and Results

Experiments show that gradient clipping addresses exploding-gradient difficulties, while combining clipping with regularization enables long-memory learning and strong performance across pathological and sequence-prediction tasks. SGD-CR solved temporal order sequences up to 200 steps and achieved state-of-the-art or improved results on several benchmarks.

  • Temporal order problem: For sequences longer than 20, vanishing gradients prevent both standard SGD and clipped SGD-C from solving the temporal order task.SGD-C denotes SGD with the clipping strategy, while SGD-CR additionally includes regularization.
  • Temporal order problem: Exploding gradients are empirically linked to long-memory tasks, and addressing them improves success whenever vanishing gradients are not limiting performance.The analysis relates increased memory to a larger spectral radius and rich regimes where gradients are likely to explode.
  • Temporal order problem: 100% success was achieved by SGD-CR for temporal order sequences up to 200 steps, including a single model trained across lengths 50–200.SGD-CR combines gradient clipping with the regularization term proposed in section 3.3.
  • Other pathological problems: SGD-CR achieved 100% success on the listed lengths for all but one of five additional pathological tasks and two noiseless memorization variants.The tasks included addition, multiplication, 3-bit temporal order, random permutation, and noiseless memorization.
  • Sequence prediction: SGD-CR significantly improved state-of-the-art RNN performance on all polyphonic music tasks except MuseData, where it matched the state of the art exactly.Scores were average negative log likelihood per time step, with hyperparameters fixed across runs except regularization and clipping thresholds.
  • Sequence prediction: Gradient clipping generally improved both training and test error, while regularization improved test error even on tasks not dominated by long-term contributions.Penn Treebank reached Mikolov et al.’s state of the art, and the regularized model performed as well as the Hessian-Free trained model.

5. Summary and Conclusions

The paper analyzes exploding and vanishing gradients from multiple perspectives and proposes clipping the norm of excessively large gradients to address exploding gradients. This solution assumes that exploding gradients coincide with exploding curvature and higher-order derivatives, producing a characteristic error-surface pattern.

  • The paper examines exploding and vanishing gradients through different perspectives to provide greater insight into the underlying issue.
  • The proposed remedy for exploding gradients clips the norm of gradients when it becomes excessively large.
  • The clipping strategy is motivated by the assumption that exploding gradients also cause exploding curvature and higher-order derivatives, creating a valley with a single

Experimental setup

The experiments use grid-searched hyperparameters, shared success criteria, and sequence tasks involving sums, products, and temporal order. A single clipped-gradient model reaches 100% success on lengths up to 200 and generalizes to sequences up to 400 steps on the reported tasks.

  • Evaluation and implementation: Hyperparameters were selected by grid search according to validation-set performance.
  • Evaluation and implementation: Success required no more than 1% error on 10,000 test samples, with regression predictions counted correct below 0.04 error.Discrete symbols used one-hot encoding.
  • Sum and product tasks: The 50-unit tanh model uses learning rate .01, regularization factor α = 0.5, gradient-norm clipping at 6, and normally initialized weights.
  • Sum and product tasks: 100% success was achieved on sum sequences of lengths 50–200, while one model generalized to new sequences up to 400 steps with error under 1%.The result outperformed Hessian Free, whose success rate declined near length 200.
  • Sum and product tasks: The product task used the same hyperparameters as the sum task and produced very similar results.
  • Temporal order task: For temporal order, the model predicts one of {AA, AB, BA, BB} from two marked symbols among distractors, achieving 100% success from 50–200 steps and generalizing to 400 steps.This used 50 hidden units, learning rate .001, α = 2, and gradient clipping at 6.

3-bit temporal order problem

The 3-bit temporal order task samples three random positions from separated sequence intervals. Using 100 hidden units, the model outperforms the state of the art and generalizes to new sequence lengths.

  • Task setup: Three random positions are sampled from [T/10, 2T/10], [3T/10, 4T/10], and [6T/10, 7T/10].The task uses three temporally separated positions within a sequence of length T.
  • Results: With 100 hidden units and similar hyper-parameters, a single model outperforms the state of the art and generalizes to new sequence lengths.The model is trained once rather than separately for each sequence length.
Loading 1211.5063v2…