Piecewise-constant Neural ODEs

Sam Greydanus, Stefan Lee, Alan FernarXiv 2021

Abstract

Neural networks are a popular tool for modeling sequential data but they generally do not treat time as a continuous variable. Neural ODEs represent an important exception: they parameterize the time derivative of a hidden state with a neural network and then integrate over arbitrary amounts of time. But these parameterizations, which have arbitrary curvature, can be hard to integrate and thus train and evaluate. In this paper, we propose making a piecewise-constant approximation to Neural ODEs to mitigate these issues. Our model can be integrated exactly via Euler integration and can generate autoregressive samples in 3-20 times fewer steps than comparable RNN and ODE-RNN models. We evaluate our model on several synthetic physics tasks and a planning task inspired by the game of billiards. We find that it matches the performance of baseline approaches while requiring less time to train and evaluate.

Introduction

Sequential data modeling typically relies on discrete-time Recurrent Neural Networks (RNNs), which struggle with irregularly sampled data or systems where dynamics vary in complexity over time. Neural Ordinary Differential Equations (Neural ODEs) offer a continuous-time alternative by parameterizing the hidden state's derivative. However, the arbitrary curvature of these learned derivatives often necessitates computationally expensive numerical integration using complex solvers.

In this work, we introduce Piecewise-constant Neural ODEs (PC-ODEs). By constraining the hidden state derivative to be piecewise-constant, we enable exact integration via simple Euler steps and allow the model to adaptively choose its time-stepping, focusing computation where dynamics are most complex.

Methodology

The PC-ODE framework approximates hidden state dynamics as a series of linear segments. Unlike standard Neural ODEs that require complex solvers, the constant derivative $\dot{h}(t)$ over an interval $\Delta t$ allows the hidden state to be updated exactly as $h(t) = h_0 + \dot{h}_0 \Delta t$. This makes Euler integration mathematically exact rather than an approximation.

Comparison of RNN, ODE-RNN, and PC-ODE architectures and their sampling behavior.

As shown in the figure above, the PC-ODE cell (built around a GRU) predicts the new state $h$, the derivative $\dot{h}$, and the duration of the next step $\Delta t$. During training, a "forward line search" determines the largest $\Delta t$ that maintains prediction error below a threshold $\epsilon$. This mechanism allows the model to "skip" predictable intervals—such as a billiard ball moving in a straight line—and take smaller steps during critical events like collisions. By mapping complex observations into a latent space using non-linear encoders, the model can linearize complex physics.

Experiments and Results

We evaluated PC-ODEs on synthetic physics tasks, including coordinate-based and image-based billiards simulations, as well as a model-based planning task.

Performance on circular motion task and evolution of adaptive time-stepping during training.

Key findings include:

  • Efficiency: PC-ODEs achieved a 3x to 20x speedup in inference compared to RNNs and ODE-RNNs by requiring significantly fewer cell updates to reach the same error levels.
  • Adaptive Learning: As training progresses, the model learns to take increasingly larger time steps (see the "Mean $\Delta t$" plot above).
  • Capacity and Step Size: Increasing the model's hidden state size allowed it to find latent spaces where dynamics are simpler, enabling even larger jumps through time.
  • Planning: In a billiards planning task, PC-ODEs achieved a 61% success rate, matching RNN performance with 4x fewer updates and significantly outperforming ODE-RNNs.

Conclusion

PC-ODEs bridge the gap between continuous-time flexibility and discrete-time efficiency. While training currently involves higher overhead due to the line search process and bootstrapping requirements, the resulting models offer dramatic speedups during inference. Future work will explore applying this piecewise-linear assumption to more complex, high-frequency dynamical systems where a constant derivative may be a more challenging approximation.

Summary updated

BibTeX
@misc{greydanus2021piecewise,
  author = {Sam Greydanus and Stefan Lee and Alan Fern},
  title = {{Piecewise-constant Neural ODEs}},
  year = {2021},
  eprint = {2106.06621},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2106.06621},
}
Figure