This repository contains the code that can be used to reproduce the results presented in the paper 'Modelling chemical reaction networks using neural ordinary differential equations'.
src/
data/ - Vector field implementations, preprocessing
models/ - (neural) ODE implementations, neural networks, model saving & loading utilities
utils/ - Path utilities, facade patterns
visualization/ - Visualization functionalities
train_files/
oscillations/ - Training scripts for experimental oscillating data
single_pulse/ - Training scripts for experimental single-pulse data
synthetic/ - Training scripts for synthetic datasets
trained_models/
oscillations/ - Saved models for experimental oscillating data.
single_pulse/ - Saved models for experimental single-pulse data.
experimental_paper_plots.py - Script that can be used to generate the experimental figures used in the thesis.
plot_data.py - Script that can be used to generate the appendix figures for the data points.
training_with_synthetic_data.ipynb - An example of generating a synthetic dataset and training a nODE.
*.csv, *.txt - Data file, retrieved from https://www.nature.com/articles/s41586-023-06310-2
To run the project, install the dependencies listed in requirements.txt. For example, using Anaconda,
(base) C:\path\to\ChemicalReactionNetworks> conda activate your_condaenv
(your_condaenv) C:\path\to\ChemicalReactionNetworks> pip install -r requirements.txt
or venv
(base) C:\path\to\ChemicalReactionNetworks> source your_virtualenv/bin/activavate
(your_virtualenv) C:\path\to\ChemicalReactionNetworks> pip install -r requirements.txt
For more details on how to get started, please find the file getting_started.md.
If you want to train a neural ODE on your own dataset, you can use the train_loop(...) functionality that is provided
in scr/models/train_loop.py. In case you would like to combine a neural network with a theoretical vector field, you
can initialize the theoretical vector field by implementing the ReactionWrapper
interface (src/data/ReactionWrapper). Have a look at the already implemented vector fields (src/data/vector_fields/)
for an example.
Create the neural ODE with the UDE implementation (scr/models/ODEs.py) where you can provide your
own ReactionWrapper and the neural network specifications.
model = UDE(width, depth, reaction, network, ...)An example of this is also provided in the training_with_synthetic_data.ipynb notebook, and in
the getting_started.md file in the train_files/synthetic/ folder.
Currently, the repository is aimed at making the results and figures presented in the thesis reproducible. The results
found on the synthetic datasets can be reproduced by running the scripts train_files/synthetic/. These scripts train
the models and plot the results. As it is time-consuming to train the models on the experimental data, trained models
have been provided in the trained_models/ folder. One can reproduce the experimental figures and results by running:
(your virtualenv) C:\path\to\ChemicalReactionNetworks> python experimental_paper_plots.py
In case you would like to retrain the models, you can run the training scripts that are included in train_files/.
