YOLO Vision 2026:
Back to Ultralytics Glossary

Neural Ordinary Differential Equations (Neural ODEs)

Learn how Neural ODEs model continuous hidden-state dynamics, support irregular time-series analysis, and enable motion forecasting with practical examples.

Neural Ordinary Differential Equations, or Neural ODEs, are neural networks that model how a hidden state changes continuously rather than passing it through a fixed sequence of layers. They define a learnable rate of change, written as dh/dt = f(h, t, parameters), and use a numerical differential-equation solver to evolve the state from an initial value to a requested time. Intuitively, a conventional neural network learns a stack of transformations, while a Neural ODE learns the continuous path connecting its input and output.

How Neural ODEs Work#

The function f is usually a small neural network called the vector field or dynamics function. Given the current state h and optional time t, it predicts the direction and speed at which that state should move. An ODE solver repeatedly evaluates this function and integrates those changes to estimate the state later.

Three components define the workflow:

  • Initial state: The input, encoded observation, or known system condition at the starting time.
  • Learned dynamics: A parameterized function that returns the state derivative rather than the next state directly.
  • Numerical integration: An algorithm such as Runge-Kutta that approximates the trajectory. The solve_ivp ODE interface illustrates how initial-value problems are handled by conventional numerical software.

Adaptive solvers can take small steps where the dynamics change quickly and larger steps in smoother regions. Consequently, computational cost depends on the learned dynamics, solver method, interval length, and error tolerances—not only on a predetermined layer count. The DiffEqFlux Neural ODE example demonstrates this continuous-time formulation directly.

  • Residual Networks: A residual block makes a discrete update such as “current state plus a learned change.” A Neural ODE can be viewed as a continuous-depth extension in which an ODE solver determines the intermediate updates.

  • Recurrent Neural Networks: RNNs update their hidden state at discrete sequence steps. Neural ODEs evolve continuously and can naturally query states at arbitrary timestamps, although they may require more computation.

  • State-Space Models: Both represent evolving hidden states. State-space models often use structured discrete or continuous dynamics for efficient sequence processing, whereas a Neural ODE specifically places a neural network inside a numerical ODE solve.

  • Neural Operators: Neural operators learn mappings between entire functions or fields, often across varying spatial resolutions. Neural ODEs usually learn the trajectory of a finite-dimensional state from an initial condition.

Neural ODEs also differ from physics-informed neural networks. A physics-informed network commonly approximates an ODE’s solution while being constrained by a known equation; a Neural ODE commonly learns all or part of the derivative function itself.

Real-World Applications#

  • Irregular Time-Series Analysis: Hospital measurements, machine telemetry, and environmental sensors may arrive at uneven intervals. A Neural ODE can evolve a latent patient or machine state between actual timestamps, supporting interpolation, forecasting, and missing-observation handling without forcing every sample onto a fixed grid.

  • Object Tracking and Motion Forecasting: A vision system can use Ultralytics YOLO26 to observe objects or keypoints in video, then pass positions and velocities to a separate Neural ODE that models continuous motion. This can help estimate trajectories between frames or during brief occlusions. YOLO itself is not a Neural ODE; the ODE acts as a downstream temporal model.

For the perception portion of such systems, Ultralytics Platform supports cloud dataset annotation, model training, deployment, and monitoring, while the custom Neural ODE remains a separate dynamics component.

Minimal Differentiable Example#

The torchdiffeq package provides differentiable ODE solvers for PyTorch. After running pip install torch torchdiffeq, this example creates a neural vector field, integrates a two-dimensional state, and computes a training gradient:

import torch
from torch import nn
from torchdiffeq import odeint

torch.manual_seed(0)

dynamics = nn.Sequential(
    nn.Linear(2, 32),
    nn.Tanh(),
    nn.Linear(32, 2),
)

initial_state = torch.tensor([[1.0, 0.0]])
times = torch.linspace(0.0, 2.0, 21)

trajectory = odeint(lambda _time, state: dynamics(state), initial_state, times)
loss = trajectory[-1].square().mean()
loss.backward()

print(dynamics[0].weight.grad.norm())

The output trajectory contains the estimated state at every requested time. The nonzero gradient shows that the solver remains part of the trainable computation. This relies on concepts covered by PyTorch automatic differentiation; comparable gradient systems are available in TensorFlow and JAX.

Practical Considerations#

Neural ODEs are most useful when continuous evolution, irregular timestamps, or known dynamical structure matters. They are not automatically faster or more accurate than ordinary layers.

Solver tolerances should be validated because loose tolerances can reduce accuracy, while strict tolerances can trigger many function evaluations. Stiff or discontinuous dynamics may also make training slow or unstable. Teams should compare direct differentiation with adjoint sensitivity methods, monitor solver evaluations and gradient behavior, and benchmark against simpler recurrent or state-space baselines. Production tools such as MATLAB’s documented Neural ODE layer also expose solver and gradient settings, emphasizing that numerical configuration is an essential part of the model.

Explore solutions

Let's build the future of AI together!

Begin your journey with the future of machine learning