Stateful ODE-Nets using Basis Function Expansions

Alejandro F. Queiruga, N. Benjamin Erichson, Liam Hodgkinson, Michael W. Mahoney

Introduction

Ordinary Differential Equation Networks (ODE-Nets) offer an elegant, memory-efficient way to model neural networks by treating the forward pass as a continuous trajectory. However, they have historically struggled to incorporate "stateful" layers like Batch Normalization and lack systematic methods for post-training compression.

This paper introduces Stateful ODE-Nets, a framework that represents neural network weights as continuous functions using basis expansions. This approach allows ODE-Nets to finally incorporate stateful layers—boosting performance to state-of-the-art levels—and enables compressing models by up to 50% after training without needing to revisit the data.

The Challenges with Standard ODE-Nets

While ODE-Nets are mathematically elegant, they have historically faced two major roadblocks:

  1. The "State" Problem: Modern architectures rely heavily on layers with internal states, most notably Batch Normalization (which tracks running means and variances). Standard ODE-Nets only handle trainable parameters, making it non-obvious how to integrate these crucial "stateful" modules into a continuous-depth framework.
  2. Rigid Architectures: Unlike traditional networks where techniques like stochastic depth or pruning are common, ODE-Nets lack a systematic way to derive smaller, faster versions of a trained model to accommodate different hardware constraints.

Methods: Rethinking Weights as Continuous Functions

The core innovation of this paper is rethinking weights not as static tensors, but as continuous-in-depth functions $\theta(t)$ represented by a linear combination of basis functions (such as piecewise constant or piecewise linear "hat" functions).

Architecture of the Stateful ODE-Block
  • Stateful ODE-Block: The authors formulate a novel block that handles both gradient-based parameters (weights) and state-based parameters (BatchNorm statistics). During training, the internal state is updated and then mathematically "projected" back onto the basis functions.
  • A Posteriori Compression: Because the weights are defined by a basis, researchers can perform a "change of basis" after training. By reducing the number of basis functions or switching from linear to constant representations, the model size can be shrunk and inference speed increased without any fine-tuning.
  • Higher-order Integrators: The paper proves that using more sophisticated numerical solvers (like the 4th-order Runge-Kutta method) during training acts as an implicit regularizer. It forces the weight trajectories to be smoother, making them significantly easier to compress later.

Key Insights

  • Smoothness is Compressibility: The crucial link established here is between numerical analysis and model compression. By using higher-order solvers, the network learns "well-behaved" weight trajectories. These smooth paths can be represented by far fewer "control points" (basis coefficients) than jagged ones.
  • Functional Model Surgery: By treating the network as a continuous object, "compression" becomes a mathematical projection problem rather than a heuristic pruning problem.
  • Bridging the Gap: This work effectively bridges the performance gap between ODE-Nets and standard ResNets by enabling Batch Normalization, which is essential for training deep models on complex datasets.

Key Results

The researchers evaluated their approach across image classification (MNIST, CIFAR-10, CIFAR-100) and Natural Language Processing (English-GUM treebank for sentence-tagging).

  • State-of-the-Art ODE Performance: The Stateful ODE-Net achieved 94.4% accuracy on CIFAR-10 and 79.9% on CIFAR-100, outperforming previous ODE-based models and matching standard ResNet benchmarks.
  • Zero-Shot Compression: On CIFAR-10, the authors compressed a model by 45% (reducing parameters from 207K to 114K) with only a 0.5% drop in accuracy, all without retraining.
  • Inference Speedup: On MNIST, a compressed model reduced inference time from 1.7 seconds to 1.1 seconds (a ~35% speedup) while maintaining 99.2% accuracy.
  • Transformer Compression: In NLP tasks, they demonstrated that a continuous-in-depth transformer could be compressed by a factor of 2 while nearly maintaining its predictive accuracy.
Test Accuracy vs. Compression Ratio

Limitations and Future Work

While powerful, the approach has some trade-offs. The authors note that multi-level refinement training, which helps with compression, can sometimes slightly reduce the accuracy of the initial "source" model compared to a non-refined version. Furthermore, implementing stateful projections and higher-order integrators is more mathematically and computationally involved than standard backpropagation.

For future directions, the authors suggest exploring $hp$-adaptivity, a technique borrowed from finite element analysis. This would allow the network to automatically decide where it needs more "depth" (parameters) and where it can afford to be shallow, potentially leading to even more efficient, self-sizing models.

Summary updated

BibTeX
@inproceedings{queiruga2021stateful,
  author = {Alejandro F. Queiruga and N. Benjamin Erichson and Liam Hodgkinson and Michael W. Mahoney},
  title = {{Stateful ODE-Nets using Basis Function Expansions}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=deoDfo34k3N},
}
Figure