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:

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

It fits the frequency of a harmonic oscillator and predicts with the fitted model. Getting started walks through the same code, and Examples lists the larger hybrid models.

In a nutshell ​

You write the ODE solve for one experiment. The library batches it over irregular data, differentiates through it, and trains the predictors.

PartResponsibility
predictorsA PyTree of trainable values and networks.
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.

HybridModel binds the first four; the data is passed per call, as a list of experiments or a Dataset:

python
import jaxhybridmodels as hm

model = hm.HybridModel(
    predictors=predictors,
    simulate_fn=simulate_fn,
    state_to_output=state_to_output,
    output_channel_names=("conc",),
)
result = model.fit(experiments, hm.OptaxTrainingConfig(steps=500, lr=1e-2), key=key)
predictions = result.model.predict(experiments)
hm.print_metrics(predictions)

Getting started defines every variable here. Concepts explains the data and model interfaces.

Find your path ​

If you want to...Start hereMain API
Build irregular experiments and datasetsData and bucketsmake_experiment, experiments_from_dataframe
Write the ODE and observation mapModel interfaceHybridModel
Choose parameters, networks and boundsPredictors and boundsParameter, BoundedPredictor
Train with gradients or population searchTrainingObjective, OptaxTrainingConfig, EvosaxTrainingConfig
Add time-varying inputs or schedulesProfiles and schedulesramp_profile, annealing_schedule
Save, evaluate, or ensemble modelsSaving and loading, Ensemblessave, compute_metrics

Install ​

Python 3.11 or newer:

bash
uv add jax-hybridmodels==0.2.0b1

The 0.2.0b1 release predates HybridModel, Parameter and Constant. Until the next release, use a checkout and uv sync --extra examples.

Released under the BSD-3-Clause License.