Using JKOnet*ο
This guide provides an overview of how to use JKOnet* to train models on synthetic data. The guide is divided into the following sections:
Generating synthetic data
Training JKOnet* (and other models)
For reproducing the experiments in the paper, see the Benchmarks π₯ page, and for more examples (including training JKOnet* on the single-cell RNA dataset), see the Tutorials π page.
Generating synthetic data π§©ο
You can generate synthetic data using the data_generator.py script. The script generates data for a given potential energy, interaction energy, and internal energy. The script also computes the couplings and fits the densities, which are required for training JKOnet*.
Example:ο
To generate population data driven by a potential energy function (e.g., the wavy_plateau function), run the following command:
python data_generator.py --potential wavy_plateau --dataset-name test-wavy-plateau
Other parametersο
The data_generator.py script accepts the following parameters for customizing the data generation and performing ablations on various datasets:
Parameter |
Description |
|---|---|
|
Load pre-generated trajectory data from a file. Expects a NumPy array of shape |
|
Specifies the potential energy to be used for the SDE simulation. Examples include |
|
Number of timesteps in the SDE simulation. Defines the length of the particle trajectory. |
|
Timestep size in the SDE simulation. Controls how often particles are updated in time. |
|
Specifies the type of internal energy, such as |
|
Standard deviation of the Wiener process (used with |
|
Specifies interaction energy between particles, such as |
|
Dimensionality of the system (e.g., 2D, 3D). Determines how many spatial dimensions the particles can move in. |
|
Number of particles to simulate in the dataset. More particles increase the complexity and size of the data. |
|
Batch size for computing couplings during the processing phase. Negative values disable batching. |
|
Number of components in the Gaussian Mixture Model (GMM) fitted to the data. Setting to 0 disables GMM fitting. |
|
Seed for random number generation to ensure reproducibility of results. |
|
Proportion of the data to be allocated to the test set during the train-test split. Values range from 0 to 1. |
|
If set, the train-test split is performed at every timestep; otherwise, it is performed on entire trajectories preserving continuity between timesteps. |
|
Leaves one time point out from the training data when set to a non-negative integer. |
|
Regularization parameter for the Sinkhorn algorithm. If less than |
|
Specifies the name of the output dataset. If not provided, a directory name will be automatically generated based on the simulation parameters. This option is only used if data is generated. If data is loaded from a file (using |
For more information on the data_generator.py script, see the data_generator module.
The script saves the generated data in the data/ directory by default. The directory name containing the generated data includes the potential, internal, interaction, and the other parameters. The name of the folder is the dataset parameter to use in the following.
Training JKOnet* πο
To train JKOnet* on the generated data, use the train.py script. The script trains a model using the JKOnet* architecture and evaluates it on the test set.
For more information on the train.py script, see the train module.
For more information on the available models, see the Models page and check the paper.
Example 1:ο
To train the JKOnet* modeling only the potential energy on the generated data, run the following command:
python train.py --solver jkonet-star-potential --dataset test-wavy-plateau
Available solversο
The following solvers (models) are available for training with JKOnet*. Each solver corresponds to a different model configuration or variation:
Solver |
Description |
|---|---|
|
JKOnet* with full generality, modeling all energy components (potential, internal, and interaction). |
|
Fits only the potential energy component. |
|
Fits both the potential energy and Wiener process (internal energy). |
|
Fits the potential energy with time-dependent features. |
|
JKOnet* using a linear parametrization for potential, internal, and interaction energies. |
|
JKOnet* using linear parametrization for potential energy only (no interaction or internal energy). |
|
JKOnet* using linear parametrization for both potential and internal energies. |
|
JKOnet* using linear parametrization for interaction energy only. |
|
Standard JKOnet model for fitting potential energy, as described in the paper. |
|
JKOnet model without using Input Convex Neural Networks (ICNN). |
|
JKOnet with Monge gap regularization. |
To add a custom solver, see the Adding a custom model page.
Other parametersο
The train.py script accepts the following parameters for customizing the training process:
Parameter |
Description |
|---|---|
|
Name of the solver (model) to use. |
|
Name of the dataset to train the model on. The dataset should be prepared and located in a directory matching this name. |
|
Option to test the fit on |
|
If specified, activates Weights & Biases logging for experiment tracking. |
|
If specified, runs the script in debug mode (disables JIT compilation in JAX for easier debugging). |
|
Seed for random number generation to ensure reproducibility. |
Configuration file(s)ο
There are two configuration files in the repo: config.yaml and config-jkonet-extra.yaml. The latter imports additional configuration parameters for the JKOnet models; see the JKOnet repo for more information.
The config.yaml is divided into the following sections:
Training settings: Specifies evaluation frequency, batch size, total epochs, and whether to save outputs locally.
Metrics configuration: Specifies the evaluation metrics.
Weights and biases integration: Options for tracking experiments using WandB.
Model configuration: Contains the settings for the modelβs optimization and network architecture.
Linear parametrization: Specifies the features used for linear parametrization.
Please check the configuration files for more details on the available parameters.