Skip to content

mattlevine22/autodiff_ODE_matlab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Autodifferentiable ODEs in MATLAB

This repository demonstrates how to use MATLAB’s Deep Learning Toolbox for computing gradients of ODE solutions (and losses related to them). By leveraging automatic differentiation, we can easily find sensitivities with respect to parameters, initial conditions, and other inputs; this enables rapid prototyping of gradient-based optimization of ODE models with respect to data.

While we leverage MATLAB's deep learning toolbox, this demonstration does not involve any neural networks. MATLAB’s deep learning toolbox is not limited to neural networks, and allows for generic computations with automatic differentiation; of course, neural networks are also supported. We use this generic autodifferentiation framework to our advantage to compute gradients of ODE solutions with respect to model inputs; in the past, this often required manual derivations or finite differences. This is particularly useful for gradient-based optimization/inference and sensitivity analysis.

Key Features:

  • Automatic Differentiation: Use dlgradient and dlfeval to compute gradients without manually deriving expressions.
  • Parameter & Initial Condition Sensitivity: Evaluate how ODE solutions change with variations in model inputs.

Requirements:

  • MATLAB R2023b (tested)
  • Deep Learning Toolbox

Usage:

  1. Clone the repository:
    git clone https://github.com/yourusername/autodiff_ODE_matlab.git
  2. Open MATLAB and navigate to the repository folder
  3. Run the demo: autodiff_ODE_demo.m
  • This script demonstrates how to compute gradients of ODE solutions (Lorenz '63) with respect to parameters and initial conditions.
  • It makes plots to visualize the sensitivities.

Other Resources:

Contributing:

  • Feel free to open an issue or submit a pull request if you have any suggestions or improvements.
  • If you find this repository helpful, please consider starring it!
  • If you use this code in your research, please cite this repository.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages