Momentum Residual Neural Networks

Michael E. Sander, Pierre Ablin, Mathieu Blondel, Gabriel Peyré

TL;DR

Momentum Residual Neural Networks (MoResNets) are a new class of invertible neural networks that serve as a drop-in replacement for standard ResNets. By adding a simple momentum term to the forward pass, they achieve a nearly constant memory footprint regardless of depth while matching the accuracy of traditional ResNets and offering superior representation power through second-order dynamical systems.

What Problem Does This Paper Address?

Training deep Residual Networks (ResNets) is notoriously memory-intensive. Standard backpropagation requires storing all intermediate activations at every layer to compute gradients, meaning the memory cost scales linearly with the network's depth. For state-of-the-art models with hundreds of layers, this often becomes a hard bottleneck, limiting the batch sizes or model sizes that can fit on a single GPU.

While "reversible" architectures like RevNets exist to solve this by recomputing activations on the fly, they typically require specialized, restricted designs (like splitting channels) that aren't compatible with standard pre-trained ResNets. Another alternative, Neural ODEs, offers $O(1)$ memory but is mathematically limited: because they represent first-order ODEs, their trajectories cannot cross, preventing them from learning certain complex, non-homeomorphic mappings.

Methods

The authors propose a minimal but profound change to the ResNet forward rule. A standard ResNet layer computes $x_{n+1} = x_n + f(x_n, \theta_n)$. The Momentum ResNet introduces a "velocity" term $v$:

  1. $v_{n+1} = \gamma v_n + (1 - \gamma)f(x_n, \theta_n)$
  2. $x_{n+1} = x_n + v_{n+1}$

Here, $\gamma \in [0, 1]$ is the momentum term. This simple change makes the network exactly invertible in practice: one can recover $x_n$ and $v_n$ from $x_{n+1}$ and $v_{n+1}$ without storing intermediate states.

Crucially, this architecture can be interpreted as a discretization of a second-order ODE ($\epsilon \ddot{x} + \dot{x} = f(x, \theta)$). This shift from first-order to second-order dynamics is the key to its increased expressivity.

Figure 3. Overview of the four different paradigms.

Datasets

The authors validated their approach across several benchmarks:

  • Synthetic Data: A point cloud separation task (nested rings) to test mathematical expressivity.
  • Image Classification: CIFAR-10, CIFAR-100, and the large-scale ImageNet dataset.
  • Transfer Learning: The Hymenoptera dataset for fine-tuning experiments.
  • Learning to Optimize: The Learned-ISTA (LISTA) framework for sparse coding.

Key Insights and Ideas

  • Crossing Trajectories: Unlike standard ResNets (first-order ODEs) where trajectories cannot cross, MoResNets (second-order ODEs) allow trajectories to cross in the $x$-space because they are separated in the $(x, v)$ phase space. This allows them to learn mappings that are topologically impossible for standard ResNets.
Comparison of dynamics: ResNet trajectories (left) cannot cross, while Momentum ResNet trajectories (right) can model more complex dynamics.
  • Drop-in Compatibility: MoResNets use the exact same parameters as standard ResNets. You can take a pre-trained ResNet-152 and "convert" it into a MoResNet with minimal fine-tuning, which is impossible with previous reversible architectures like RevNets.
  • Memory Efficiency: Because activations are recomputed during the backward pass, the memory footprint remains nearly constant as depth increases.
MoResNets maintain a nearly constant memory footprint compared to the linear growth of standard ResNets.
  • Convergence to Fixed Points: The authors prove that MoResNets can converge to stable fixed points, a property required for "learning to optimize" tasks where other reversible models like RevNets fundamentally fail due to inherent instability.

Key Results

  • Accuracy: MoResNets achieve virtually identical accuracy to standard ResNets on ImageNet (e.g., ~23% top-1 error for a 101-layer model) while using significantly less memory.
  • Fine-tuning Speedup: On a memory-constrained GPU (3GB), MoResNets allowed for a 2x larger batch size than standard ResNets, leading to a 2x speedup in training time for fine-tuning tasks.
  • Mathematical Expressivity: MoResNets successfully separated nested rings in the synthetic task, whereas standard ResNets of the same depth failed.
  • Linear Universality: The authors provide a formal proof (Theorem 1) that MoResNets with linear residual functions have universal approximation capabilities for linear mappings, whereas first-order models are restricted.

Limitations and Future Work

  • Numerical Precision: While the authors use a specific algorithm to handle finite-precision multiplication by $\gamma$, there is still a tiny, negligible loss of floating-point precision during inversion.
  • Hyperparameter Tuning: The momentum term $\gamma$ is a new hyperparameter. While $\gamma=0.9$ worked well across their tests, optimal values might vary for different tasks.
  • Broader Architectures: The current work focuses on ResNets. Extending this momentum-based reversibility to other popular architectures, like Transformers, remains an open and promising direction for future research.

Summary updated

BibTeX
@inproceedings{sander2021momentum,
  author = {Michael E. Sander and Pierre Ablin and Mathieu Blondel and Gabriel Peyré},
  title = {{Momentum Residual Neural Networks}},
  booktitle = {International Conference on Machine Learning},
  year = {2021},
  url = {https://openreview.net/forum?id=xb6PDI6ZY5T},
}
Figure