On orthogonality and learning recurrent networks with long term dependencies

Eugene Vorontsov, Chiheb Trabelsi, Samuel Kadoury, Chris Pal

Abstract

Training Recurrent Neural Networks (RNNs) to capture long-term dependencies is notoriously difficult due to the vanishing and exploding gradient problems. While enforcing strict orthogonality in weight matrices ensures gradient stability, it can also limit the model's ability to learn complex transformations. This paper explores a flexible approach that allows weight matrices to deviate from orthogonality within a controlled spectral margin. Our results on synthetic memory tasks and Sequential MNIST demonstrate that a small margin facilitates faster convergence and superior performance compared to strictly orthogonal models.

Introduction

The core challenge in training RNNs is the stability of the hidden state transformation over many time steps. If the transition matrix $W$ has singular values significantly different from unity, gradients will either vanish or explode during backpropagation through time. Restricting $W$ to the Stiefel manifold—the set of all orthogonal matrices where $W^T W = I$—ensures that singular values are exactly 1.0, providing a stable gradient flow.

However, strict orthogonality can be a "straightjacket." Real-world data often requires the network to selectively expand or contract dimensions to extract relevant features. Furthermore, standard non-linear activations like tanh are naturally contractive; if weights are strictly norm-preserving, the overall system still suffers from vanishing signals. We propose a framework that maintains the stability of orthogonal bases while allowing controlled deviations in the singular values.

Methodology

We employ a weight matrix factorization based on Singular Value Decomposition (SVD): $W = USV^T$. To optimize this structure while maintaining near-orthogonality, we treat the components differently:

  1. Orthogonal Bases ($U$ and $V$): These matrices are updated using geodesic gradient descent via the Cayley transform, ensuring they remain strictly on the Stiefel manifold.
  2. Spectral Margin ($S$): Instead of fixing the diagonal matrix $S$ to the identity, we parameterize the singular values $s_i$ as: $$s_i = 2m(\sigma(p_i) - 0.5) + 1$$ where $m$ is a hyperparameter defining the allowable deviation (the margin) and $\sigma$ is the sigmoid function. For $m=0.1$, singular values can range between $[0.9, 1.1]$.

This approach allows the model to adapt its norm-preserving properties to the specific needs of the task and the chosen activation function.

Experimental Results

We evaluated the proposed margin-based RNN on several benchmarks designed to test long-term memory and complex pattern recognition.

Synthetic Memory: The Copy Task

The Copy task requires the model to remember a sequence of symbols and reproduce it after a long delay. As shown in Figure 1, strict orthogonality ($m=0$) often results in slow convergence, especially as the sequence length $T$ increases. A small margin (e.g., $m=0.01$ or $m=0.1$) allows the model to find a solution much faster. Interestingly, for extremely long sequences ($T=10,000$), the task becomes so difficult that only very specific margin settings maintain enough stability to converge.

Figure 1: Accuracy on the Copy task across various sequence lengths (200 to 10,000). A small margin $m$ generally leads to faster convergence than strict orthogonality ($m=0$).

Sequential MNIST

In Sequential MNIST, pixels are fed to the RNN one by one. The "Permuted" version (pMNIST) is particularly challenging as it destroys spatial locality, forcing the model to rely entirely on long-term memory.

Figure 4: Training cost on the MNIST dataset. The margin-based approach allows for lower cost and more stable optimization compared to unconstrained or strictly orthogonal baselines.

Our margin-based RNN achieved 94.10% accuracy on ordered MNIST and 91.44% on pMNIST. This significantly outperformed the strictly orthogonal baseline (77.18% and 83.56%, respectively). Notably, the factorized RNN performed nearly as well as an LSTM on pMNIST, despite lacking complex gating mechanisms, suggesting that proper gradient scaling is a primary driver of performance.

Discussion and Conclusion

Our findings suggest a "Goldilocks" principle for RNN weights: they should be "orthogonal enough" to prevent gradient explosion but flexible enough to adapt. A small margin (typically $m \approx 0.1$) provides a sweet spot. We observed that models often learn to set singular values slightly above 1.0 (e.g., 1.05) to compensate for the contractive nature of activations like tanh.

While the SVD-based update adds computational overhead, the gains in convergence speed and final accuracy justify the cost for tasks with long-term dependencies. Future work could explore adaptive margins that respond to the gradient variance during training.

Summary updated

BibTeX
@inproceedings{vorontsov2017orthogonality,
  author = {Eugene Vorontsov and Chiheb Trabelsi and Samuel Kadoury and Chris Pal},
  title = {{On orthogonality and learning recurrent networks with long term dependencies}},
  booktitle = {International Conference on Machine Learning},
  year = {2017},
  url = {https://openreview.net/forum?id=rkbeNoWu-r},
}
Figure