projUNN: efficient method for training deep networks with unitary matrices

Bobak Kiani, Randall Balestriero, Yann LeCun, Seth Lloyd

Recurrent Neural Networks (RNNs) and ultra-deep feed-forward networks often suffer from a "Goldilocks" problem: gradients either vanish into nothingness or explode into infinity. Unitary matrices—matrices that preserve the length of vectors—are the theoretical "just right" solution, but they’ve historically been too slow to use in practice. A new method, projUNN, introduces a way to get the stability of unitary matrices without the computational hangover.

The Problem: Stability vs. Computation

In deep learning, stability is everything. When you multiply a hidden state by a weight matrix over and over (like in an RNN), any eigenvalue slightly larger than 1 leads to exploding gradients, while anything smaller than 1 leads to vanishing gradients.

Unitary matrices, where all eigenvalues have a magnitude of exactly 1, naturally solve this. However, keeping a matrix unitary during training is hard. Standard methods either use expensive parameterizations or require $O(n^3)$ operations like Singular Value Decomposition (SVD) or matrix exponentials at every step. For a hidden layer of size 1000, $n^3$ is a billion operations per update. This bottleneck has kept unitary networks as a niche academic interest rather than a standard tool.

Methods: projUNN and Low-Rank Gradients

The core insight of projUNN is that gradients in deep learning are typically low-rank. You don't need to update the entire $n \times n$ matrix; you only need to update a small subspace.

The authors introduce two variants of Projected Unitary Neural Networks (projUNN):

  1. projUNN-D (Direct): Takes a standard gradient step and then "projects" the result back to the closest unitary matrix using polar decomposition.
  2. projUNN-T (Tangent): Projects the gradient onto the "tangent space" (the Lie algebra) of the unitary group and then uses an exponential map to "rotate" the matrix along the manifold.
Illustration of projUNN-D and projUNN-T algorithms on the unitary Lie group manifold.

By using low-rank approximations (rank-$k$) for the gradients, they perform these projections in $O(kn^2)$ time. When $k \ll n$, this is essentially the same cost as a standard, unconstrained gradient update. They also extend this logic to convolutional layers by performing the operations in the Fourier domain, where convolutions become block-diagonal matrix multiplications.

Key Insights and Results

projUNN was validated across several classic "stress tests" for long-range dependencies, including the Adding Task, Copy Memory Task, and Permuted MNIST.

  • Rank-1 is often enough: Surprisingly, even setting $k=1$ (the most extreme approximation) allowed the models to converge to solutions as good as or better than full-rank methods. This suggests that the "direction" of the gradient is more important than its full complexity for maintaining unitarity.
  • Speed: In RNN settings, projUNN scales asymptotically at the same rate as a vanilla (non-unitary) RNN, making it orders of magnitude faster than $O(n^3)$ methods as the hidden dimension grows.
Optimization step runtime comparison across different RNN models as hidden size increases.
  • Performance: On the Permuted MNIST task, projUNN achieved up to 97.0% accuracy, matching or slightly exceeding previous state-of-the-art unitary models like expRNN and scoRNN.
  • Stability at Extreme Depth: In a 100-layer CNN experiment on Deep MNIST, a standard unconstrained network collapsed (23.5% accuracy), while the projUNN-T version maintained 94.6% accuracy.

Limitations and Future Work

While projUNN is a major step forward, there are a few hurdles. Their CNN implementation uses cyclic padding, which isn't standard in computer vision and might affect performance on some tasks. Additionally, to keep the math efficient in the Fourier domain, they use memory-intensive full-width filters. Finally, in standard CNN architectures like ResNet-9 on CIFAR-10, enforcing unitarity still results in a slight drop in accuracy compared to unconstrained models (82% vs 92%). This suggests that unitary constraints might need to be used in tandem with other techniques rather than as a total replacement to close the accuracy gap.

Reference: Kiani, B. T., Balestriero, R., LeCun, Y., & Lloyd, S. (2022). projUNN: efficient method for training deep networks with unitary matrices. 36th Conference on Neural Information Processing Systems (NeurIPS 2022).

Summary updated

BibTeX
@inproceedings{kiani2022projunn,
  author = {Bobak Kiani and Randall Balestriero and Yann LeCun and Seth Lloyd},
  title = {{projUNN: efficient method for training deep networks with unitary matrices}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2022},
  url = {https://openreview.net/forum?id=nEJMdZd8cIi},
}
Figure