Skip to content

jaxhybridmodelsTrain functions inside ODE models

A JAX library for combining user-written differential equations with trainable predictors, bounded physical quantities, and irregular time-series data.

Start here

From a repository checkout, run the known-answer sanity check first:

bash
uv sync --extra examples
uv run python examples/pendulum/train_harmonic.py --no-plot

It recovers the frequency of a synthetic harmonic oscillator from noisy position measurements. The Getting started page then builds the same pipeline step by step, and the Examples page shows where to go for a real hybrid ODE.

In a nutshell

jaxhybridmodels keeps the ODE simulation function in user code. The Python package is imported as jaxhybridmodels. The library adds the surrounding data, predictor, and training machinery.

PartResponsibility
predictorsAn Equinox PyTree of trainable functions.
simulate_fnIntegrates one experiment and returns the full state.
state_to_outputSelects the observed channels from the full state.
SolverConfigStores the Diffrax solver and its settings.
DatasetStores bucketed observations and masks.

The core training call is:

python
import jaxhybridmodels as hm

dataset = hm.make_dataset(experiments, output_channel_names=("value",))
history, trained = hm.train_with_optax(
    predictors,
    dataset,
    config,
    simulate_fn=simulate_fn,
    state_to_output=state_to_output,
    solver=solver,
    key=key,
)

The variables in this short call are defined in the complete Getting started example. Read Concepts for the data and model interfaces.

Find your path

If you want to...Start hereMain API
Build irregular experiments and datasetsData and bucketsmake_experiment, make_dataset
Write the ODE and observation mapModel interfacesimulate_fn, state_to_output
Choose a bounded predictorPredictors and boundsBoundedPredictor, BoundScaler
Train with gradients or population searchTrainingtrain_with_optax, train_with_evosax
Add time-varying inputs or schedulesProfiles and schedulesramp_profile, annealing_schedule
Save, evaluate, or ensemble modelsSaving and loading, Ensemblessave_run, predict_dataset

Install

The package requires Python 3.11 or newer and uses uv:

bash
uv add jax-hybridmodels==0.2.0b1

For a checkout of the repository:

bash
uv sync --extra examples

Released under the BSD-3-Clause License.