Neural ordinary differential equation

Also known as: Neural ODE

On this page 7

A neural ordinary differential equation, or Neural ODE, is a model in which a neural network defines the time derivative of a hidden state, and the output is obtained by integrating that derivative with a numerical ODE solver. Among neural networks, it replaces a discrete stack of layers with a continuous-depth transformation, so depth becomes an integration interval rather than a fixed number of layers.

The idea was popularized in 2018 by work that connected residual networks to the Euler method for solving differential equations. Neural ODEs are valued for constant-memory training, adaptive computation, natural handling of irregularly sampled time series and a direct route to continuous normalizing flows.

How a Neural ODE transforms its hidden state

A Neural ODE specifies the dynamics dh/dt = f(h(t), t, θ), where f is a neural network with parameters θ, usually a small multilayer perceptron or convolutional block. Given an input state h(t0), a solver integrates these dynamics to time t1, and the final state h(t1) is passed to a task head for classification, regression or density estimation.

The link to residual connections is direct. A residual block computes h(t+1) = h(t) + f(h(t)), which is exactly one Euler step with step size one. Stacking many such blocks with shared weights and shrinking the step size yields the continuous limit that a Neural ODE models explicitly.

PropertyResidual networkNeural ODE
DepthFixed number of layersContinuous integration interval
ParametersSeparate weights per blockOne dynamics network shared over time
Forward computationOne pass per layerSolver chooses number of evaluations
Training memoryGrows with depthConstant with adjoint method
InvertibilityNot guaranteedGuaranteed for well-behaved dynamics
Discrete residual network compared with a Neural ODE

Training with the adjoint sensitivity method

Gradients for a Neural ODE can be computed in two ways. Direct backpropagation through the solver stores every intermediate step and is accurate but memory-intensive. The adjoint sensitivity method instead solves a second ODE backward in time for the adjoint state a(t) = ∂L/∂h(t), recovering parameter gradients without storing the forward trajectory.

The adjoint approach gives O(1) memory cost with respect to the number of solver steps, which is its main attraction. The price is extra computation and possible numerical error, because the backward reconstruction of h(t) may diverge from the forward trajectory when the dynamics are stiff or chaotic. Checkpointed variants store a few states to limit that drift.

MethodMemory useAccuracy and cost
Backpropagation through solverLinear in solver stepsExact for the discretization, fast backward pass
Adjoint methodConstantExtra backward solve, possible reconstruction error
Checkpointed adjointSmall, proportional to checkpointsGood balance for long or stiff trajectories
Gradient computation options

Solvers, tolerances and computational cost

The choice of solver determines both accuracy and speed. Adaptive solvers such as Dormand-Prince adjust step size to meet an error tolerance, so the number of function evaluations (NFE) replaces layer count as the measure of computational depth. Fixed-step solvers such as Euler or fourth-order Runge-Kutta give predictable cost but no error control.

SolverStep controlTypical use
EulerFixedFast prototypes, equivalent to residual stacks
Runge-Kutta 4FixedModerate accuracy with predictable cost
Dormand-PrinceAdaptiveDefault general-purpose choice
Implicit solversAdaptiveStiff dynamics, higher cost per step
Common solver choices

A known practical problem is that NFE tends to increase during training as learned dynamics become more complex, making later epochs slower. Regularization of the dynamics, for example penalizing kinetic energy or Jacobian norms, keeps trajectories smooth and cheap to integrate without large losses in accuracy.

Variants and main applications

The basic formulation has inspired several specialized variants. Each addresses a limitation of the original model or adapts it to a particular kind of data, from irregular clinical measurements to generative modeling of probability densities.

  • Latent ODEs encode an irregular time series into a latent initial state and integrate it forward, handling missing and unevenly spaced observations naturally.
  • Neural controlled differential equations let incoming data continuously steer the dynamics, acting as a continuous analog of recurrent neural networks.
  • Continuous normalizing flows transform a simple distribution into a complex one, using the instantaneous change-of-variables formula for exact likelihoods.
  • Augmented Neural ODEs add extra dimensions to the state so that the model can represent mappings that plain ODE flows cannot.
  • Neural stochastic differential equations add a learned noise term for uncertainty-aware dynamics.

Neural ODEs share ideas with physics-informed neural networks and state space models, but the roles differ. A physics-informed network typically approximates a known equation’s solution, while a Neural ODE learns the equation itself from data. State space models such as Mamba use discretized linear dynamics for efficiency rather than a general learned vector field.

Limitations and common pitfalls

The flow of a Neural ODE is a homeomorphism, so trajectories cannot cross. This prevents a plain model from representing some simple functions, such as mapping concentric regions to swapped positions, without state augmentation. Training is also generally slower than for equivalent discrete networks, and stiff learned dynamics can make the solver take thousands of tiny steps.

Common mistakes include setting tolerances too loose, which produces gradients that do not match the true loss, and benchmarking only accuracy while ignoring wall-clock cost. For dense, regularly sampled data such as image classification, a well-tuned residual network is usually faster and equally accurate; the continuous formulation pays off mainly for irregular time, density estimation and physical systems.

The short version

A normal neural network changes data in a fixed number of steps, like climbing stairs. A Neural ODE changes data smoothly, like walking up a ramp. A small network describes which direction to move at each moment. A solver then follows that direction from start to finish.

This makes the model good at data that arrives at uneven times. Medical readings and sensor logs are good examples. The trade-off is speed, because following the ramp carefully takes more computation.

Where it makes a difference

A hospital research team wants to predict deterioration in intensive care patients. Vital signs and laboratory results arrive at irregular intervals: heart rate every minute, blood tests every few hours, and some measurements missing for long periods. A standard recurrent network requires imputing or binning these values, which introduces artifacts.

The team trains a latent ODE model. An encoder summarizes each patient’s observations into a latent state, and a Neural ODE evolves that state continuously between and beyond measurement times. Because the solver can evaluate any time point, the model produces risk estimates at arbitrary future horizons, such as six or twelve hours ahead, without retraining.

Compared with a baseline that used hourly binning, the latent ODE handled missing data more gracefully and gave smoother risk trajectories that clinicians found easier to interpret. Training took roughly twice as long, which the team accepted because the model matched the irregular structure of real clinical data.