Do Residual Neural Networks discretize Neural Ordinary Differential Equations?

Michael E. Sander, Pierre Ablin, Gabriel Peyré · DOI

Introduction

In the landscape of deep learning, a popular intuition has emerged: Residual Neural Networks (ResNets) are essentially discrete approximations of continuous-time dynamical systems, specifically Neural Ordinary Differential Equations (Neural ODEs). While this conceptual bridge is elegant, it often lacks mathematical rigor in practice. Standard ResNets frequently exhibit "jagged" dynamics where weights change abruptly between layers, violating the smoothness required for a true continuous limit.

This research investigates the formal connection between these two architectures, proving that while ResNets do not automatically act as Neural ODEs, the process of training them with gradient descent naturally encourages the smoothness necessary to bridge the gap. This realization allows for the application of memory-efficient training techniques, such as the adjoint method, to standard deep learning architectures.

The Discretization Gap

The fundamental question is whether a standard ResNet of the form $x_{n+1} = x_n + f(x_n, \theta_n)$ actually converges to an ODE $\dot{x} = f(x, \theta(t))$ as the number of layers $N$ goes to infinity. In most practical scenarios, the answer is no. Because the weights $\theta_n$ are independent parameters for each layer, there is no inherent constraint forcing $\theta_n$ to be a smooth sampling of a continuous function $\theta(t)$.

To address this, the authors introduce a "depth-aware" scaling for the forward pass: $$x_{n+1} = x_n + \frac{1}{N} f(x_n, \theta_n)$$ This explicit $1/N$ scaling ensures that as the network becomes deeper, the contribution of each individual layer becomes smaller, mimicking a smaller step size in a numerical ODE solver.

Implicit Regularization and Smoothness

One of the paper's most significant theoretical contributions is the discovery of implicit regularization. For linear ResNets, the authors provide a mathematical proof that gradient descent does not merely find any set of weights that minimize the loss; it specifically favors weights that change slowly across adjacent layers.

This "smoothing" effect means that the optimization process itself acts as a bridge, pushing the discrete ResNet toward a continuous Neural ODE limit. Without this implicit regularization, the discretization error would remain high, making continuous-time interpretations and techniques (like the adjoint method) inapplicable.

The Discrete Adjoint Method

Training extremely deep networks is typically limited by GPU memory, as standard backpropagation requires storing the activations of every layer to compute gradients. Neural ODEs solve this using the adjoint method, which computes gradients by solving the ODE backward in time, requiring only the final state.

By establishing the smoothness of ResNets, the authors propose a Discrete Adjoint Method. This technique reconstructs activations "on the fly" during the backward pass using reverse-time numerical schemes:

  1. Euler Method: A first-order approximation that matches the standard ResNet forward pass.
  2. Heun’s Method: A second-order scheme that significantly reduces reconstruction error.

As the network depth $N$ increases, the discretization error of these schemes decreases. This creates a beneficial paradox: the adjoint method becomes more accurate and viable exactly when the network is deep enough to require its memory-saving properties.

Experimental Validation

The researchers validated their findings on CIFAR-10 and ImageNet, focusing on whether depth-aware scaling and the adjoint method could maintain competitive performance while reducing memory overhead.

  • Performance Parity: On ImageNet, a ResNet-101 using $1/N$ scaling achieved an accuracy of 77.9%, matching the performance of standard ResNet architectures. This proves that the proposed scaling does not inherently limit the model's representational power.
  • Memory-Efficient Fine-Tuning: The authors demonstrated the ability to fine-tune a very deep ResNet (100 blocks per layer) on ImageNet using the adjoint method. They successfully increased accuracy from 73.1% to 75.1% without storing intermediate activations in the residual layers, effectively bypassing the primary memory bottleneck of deep models.
  • Error Convergence: Experiments confirmed that as depth increases, the relative error between the approximated adjoint gradients and the true gradients (computed via standard backpropagation) vanishes, particularly when utilizing the more stable Heun’s method.

Discussion and Limitations

While this work provides a robust mathematical foundation for the ResNet-ODE connection, it introduces certain trade-offs. The adjoint method is computationally more expensive than standard backpropagation because it requires an additional pass to reconstruct activations. Furthermore, the theoretical proofs for implicit regularization are currently focused on the linear case; extending these to non-linear, multi-layer residual blocks remains an area for future research.

Additionally, the success of the backward reconstruction depends on the Lipschitz continuity of the residual functions. If the network dynamics are too chaotic or the initial loss is too high, the reconstruction can diverge, leading to unstable training. However, for sufficiently deep and smooth networks, this approach offers a path toward training models of near-infinite depth on limited hardware.

Summary updated

BibTeX
@inproceedings{sander2022do,
  author = {Michael E. Sander and Pierre Ablin and Gabriel Peyré},
  title = {{Do Residual Neural Networks discretize Neural Ordinary Differential Equations?}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2022},
  url = {https://openreview.net/forum?id=1tCuRbPts3J},
}
Figure