torchlaplace

Neural Laplace: Differentiable Laplace Reconstructions for modelling any time observation with O(1) complexity.

https://github.com/samholt/neurallaplace

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.8%) to scientific vocabulary

Keywords

dde deep-learning deep-neural-networks delay-differential-equations differential-equations dynamical-systems forced-ode ide ilt integro-differential-equations inverse-laplace-transform laplace-transform neural-differential-equations neural-network ode pytorch riemann-sphere stereographic-projection stiff-ode
Last synced: 6 months ago · JSON representation ·

Repository

Neural Laplace: Differentiable Laplace Reconstructions for modelling any time observation with O(1) complexity.

Basic Info
Statistics
  • Stars: 78
  • Watchers: 4
  • Forks: 12
  • Open Issues: 0
  • Releases: 0
Topics
dde deep-learning deep-neural-networks delay-differential-equations differential-equations dynamical-systems forced-ode ide ilt integro-differential-equations inverse-laplace-transform laplace-transform neural-differential-equations neural-network ode pytorch riemann-sphere stereographic-projection stiff-ode
Created over 3 years ago · Last pushed 10 months ago
Metadata Files
Readme Funding License Citation

README.md

PyTorch Implementation of Differentiable Laplace Reconstructions

Documentation Status Tests arXiv License: MIT

This library provides Inverse Laplace Transform (ILT) algorithms implemented in PyTorch. Backpropagation through differential equation (DE) solutions in the Laplace domain is supported using the Riemann stereographic projection for better global representation of the complex Laplace domain. For usage for DE representations in the Laplace domain in deep learning applications, see reference [1].

Installation

To install latest stable version:

pip install torchlaplace

To install the latest on GitHub:

pip install git+https://github.com/samholt/NeuralLaplace.git

Tutorials

  1. Tutorial: Laplace Reconstruct Test In Colab
  2. Tutorial: Inverse Laplace Transform Algorithms Test In Colab ## Examples

Examples are placed in the examples directory.

We encourage those who are interested in using this library to take a look at examples/simple_demo.py for understanding how to use torchlaplace to fit a DE system.

Lotka Volterra DDE Demo

Basic usage

This library provides one main interface laplace_reconstruct which uses a selected inverse Laplace transform algorithm to reconstruct trajectories from a provided parameterized Laplace representation functional $\mathbf{F}(\mathbf{p},\mathbf{s})$,

$$\mathbf{x}(t) = \text{inverse laplace transform}(\mathbf{F}(\mathbf{p},\mathbf{s}), t)$$

Where $\mathbf{p}$ is a Tensor encoding the initial system state as a latent variable, and $t$ is the time points to reconstruct trajectories for.

This can be used by

``` from torchlaplace import laplace_reconstruct

laplacereconstruct(laplacerep_func, p, t) ```

where laplace_rep_func is any callable implementing the parameterized Laplace representation functional $\mathbf{F}(\mathbf{p},\mathbf{s})$, p is a Tensor encoding the initial state of shape $(\text{MiniBatchSize},\text{K})$. Where $\text{K}$ is a hyperparameter, and can be set by the user. Finally, t is a Tensor of shape $(\text{MiniBatchSize},\text{SeqLen})$ or $(\text{SeqLen})$ containing the time points to reconstruct the trajectories for.

Note that this is not numerically stable for all ILT methods, however should probably be fine with the default fourier (fourier series inverse) ILT algorithm.

The parameterized Laplace representation functional laplace_rep_func, $\mathbf{F}(\mathbf{p},\mathbf{s})$ also takes an input complex value $\mathbf{s}$. This $\mathbf{s}$ is used internally when reconstructing a specified time point with the selected inverse Laplace transform algorithm ilt_algorithm.

The biggest gotcha is that laplace_rep_func must be a nn.Module when using the laplace_rep_func function. This is due to internally needing to collect the parameters of the parameterized Laplace representation.

To replicate the experiments in [1] see the in the experiments directory.

Keyword arguments for laplace_rep_func

Keyword arguments:

  • recon_dim (int): trajectory dimension for a given time point. Corresponds to dim $d_{\text{obs}}$. If not explicitly specified, will use the same last dimension of p, i.e. $\text{K}$.
  • ilt_algorithm (str): inverse Laplace transform algorithm to use. Default: fourier. Available are {fourier, dehoog, cme, fixed_tablot, stehfest}. See api documentation on ILTs for further details.
  • use_sphere_projection (bool): this uses the laplace_rep_func in the stereographic projection of the Riemann sphere. Default True.
  • ilt_reconstruction_terms (int): number of ILT reconstruction terms, i.e. the number of complex $s$ points in laplace_rep_func to reconstruct a single time point.

List of ILT Algorithms:

ILT algorithms implemented:

  • fourier Fourier Series Inverse [default].
  • dehoog DeHoog (Accelerated version of Fourier) - Slower inference in comparison.
  • cme Concentrated Matrix Exponentials.
  • fixed_tablot Fixed Tablot.
  • stehfest Gaver-Stehfest.

For most problems, good choices are the default fourier. However other ILT algorithms may be more appropriate when using higher ILT reconstruction terms, such as the cme algorithm. Some allow trade-offs between speed and accuracy, for example dehoog is very accurate if the representation is known or exact, however is slow and can be unstable to use when learning the correct representation.

Detailed documentation

For detailed documentation see the official docs.

Frequently Asked Questions

Take a look at our FAQ for frequently asked questions.

References

For usage for DE representations in the Laplace domain and leveraging the stereographic projection and other applications see:

[1] Samuel Holt, Zhaozhi Qian, and Mihaela van der Schaar. "Neural laplace: Learning diverse classes of differential equations in the laplace domain." International Conference on Machine Learning. 2022. [arxiv]


If you found this library useful in your research, please consider citing.

``` @inproceedings{holt2022neural, title={Neural Laplace: Learning diverse classes of differential equations in the Laplace domain}, author={Holt, Samuel I and Qian, Zhaozhi and van der Schaar, Mihaela}, booktitle={International Conference on Machine Learning}, pages={8811--8832}, year={2022}, organization={PMLR} }

```

Projects (Papers) that use Neural Laplace 📝

  • 💻 Neural Laplace Control: Neural Laplace Control for Continuous-time Delayed Systems - an offline RL method combining Neural Laplace dynamics model and MPC planner to achieve near-expert policy performance in environments with irregular time intervals and an unknown constant delay.

Owner

  • Name: Samuel Holt
  • Login: samholt
  • Kind: user
  • Location: Cambridge, UK
  • Company: samuel.holt.direct@gmail.com

PhD Candidate in AI/ML for LLM Agents, University of Cambridge | Oxford MEng https://samholt.github.io/

Citation (CITATION.cff)

# YAML 1.2
---
abstract: |
    "This library provides Inverse Laplace Transform (ILT) algorithms implemented in PyTorch. Backpropagation through differential equation (DE) solutions in the Laplace domain is supported using the Riemann stereographic projection for better global representation of the complex Laplace domain.

    This is implemented in PyTorch, and fully supports running the library on the GPU."
authors:
  -
    family-names: Holt
    given-names: "Samuel"
cff-version: "1.1.0"
date-released: 2022-07-04
license: MIT
message: "PyTorch Implementation of Differentiable Laplace Reconstructions"
repository-code: "https://github.com/samholt/NeuralLaplace"
title: torchlaplace
version: "0.0.1"
...

GitHub Events

Total
  • Issues event: 2
  • Watch event: 9
  • Issue comment event: 1
  • Push event: 13
  • Fork event: 2
Last Year
  • Issues event: 2
  • Watch event: 9
  • Issue comment event: 1
  • Push event: 13
  • Fork event: 2

Issues and Pull Requests

Last synced: 9 months ago

All Time
  • Total issues: 5
  • Total pull requests: 4
  • Average time to close issues: about 1 month
  • Average time to close pull requests: 18 minutes
  • Total issue authors: 5
  • Total pull request authors: 1
  • Average comments per issue: 2.2
  • Average comments per pull request: 0.0
  • Merged pull requests: 4
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 0
  • Average time to close issues: about 2 hours
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 0
  • Average comments per issue: 1.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • thibmonsel (1)
  • ForrestPi (1)
  • DrShushen (1)
  • qm-intel (1)
  • LLiRarry (1)
Pull Request Authors
  • bcebere (4)
Top Labels
Issue Labels
enhancement (1)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 106 last-month
  • Total dependent packages: 1
  • Total dependent repositories: 1
  • Total versions: 4
  • Total maintainers: 3
pypi.org: torchlaplace

Differentiable Laplace Reconstructions in PyTorch

  • Versions: 4
  • Dependent Packages: 1
  • Dependent Repositories: 1
  • Downloads: 106 Last month
Rankings
Dependent packages count: 4.8%
Stargazers count: 9.5%
Forks count: 11.9%
Average: 12.4%
Downloads: 14.4%
Dependent repos count: 21.6%
Last synced: 6 months ago

Dependencies

docs/requirements.txt pypi
  • furo ==2021.11.16
  • ipykernel *
  • nbsphinx ==0.8.9
  • sphinx-panels ==0.6.0
  • sphinx-rtd-theme ==1.0.0
  • torchlaplace *
.github/workflows/codeql-analysis.yml actions
  • actions/checkout v3 composite
  • github/codeql-action/analyze v2 composite
  • github/codeql-action/autobuild v2 composite
  • github/codeql-action/init v2 composite
.github/workflows/release.yml actions
  • actions/checkout v2 composite
  • actions/checkout v1 composite
  • actions/setup-python v1 composite
.github/workflows/sphinx.yml actions
  • actions/checkout v3 composite
  • actions/upload-artifact v3 composite
  • ammaraskar/sphinx-action 0.4 composite
  • peaceiris/actions-gh-pages v3 composite
.github/workflows/test.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v1 composite
setup.py pypi