Skip to main content

PyPI version Contributions welcome

diffeqtorch

Bridges DifferentialEquations.jl with PyTorch. Besides benefitting from the huge range of solvers available in DifferentialEquations.jl, this allows taking gradients through solvers using local sensitivity analysis/auto-diff. The package has only been tested with ODE problems, and in particular, automatic differentiation is only supported for ODEs using ForwardDiff.jl. This can be extended in the future, contributions are welcome.

Examples

Installation

Prerequisites for using diffeqtorch are installation of Julia and Python. Note that the binary directory of julia needs to be in your PATH.

Install diffeqtorch:

$ pip install diffeqtorch
$ export JULIA_SYSIMAGE_DIFFEQTORCH="$HOME/.julia_sysimage_diffeqtorch.so"
$ python -c "from diffeqtorch.install import install_and_test; install_and_test()"

We recommend using a custom Julia system image containing dependencies. By setting the environment variable JULIA_SYSIMAGE_DIFFEQTORCH, an image will be created and used automatically. This may take a while but will improve speed afterwards.

Usage

from diffeqtorch import DiffEq

f = """
function f(du,u,p,t)
    du[1] = p[1] * u[1]
end
"""
de = DiffEq(f)

u0 = torch.tensor([1.])
tspan = torch.tensor([0., 3.])
p = torch.tensor([1.01])

u, t = de(u0, tspan, p)

See also help(DiffEq) and examples provided in notebooks/.

License

MIT

Metadata

Release files for diffeqtorch 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for diffeqtorch 1.0.1
File Size Uploaded
diffeqtorch-1.0.1.tar.gz 10.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for diffeqtorch 1.0.1
File Interpreter ABI Platform
diffeqtorch-1.0.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 20.5 kB

Release files / diffeqtorch-1.0.1.tar.gz

Download URL diffeqtorch-1.0.1.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
405edd3ae1fefe9fe2455ea3d2746c3c77338050ebfc047981fe0a0171d279bf
BLAKE2b-256 checksum
How to use checksums
de370c79655c5b2e07b6c0902064375ae227182ea62a4868e12d5e49aade124e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.10

Release files / diffeqtorch-1.0.1-py2.py3-none-any.whl

Download URL diffeqtorch-1.0.1-py2.py3-none-any.whl
Size 9.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
de484ab7bc833ce44c9bf1bd44d965ae6fd25bc70547bce1f35ba180d85bd21c
BLAKE2b-256 checksum
How to use checksums
c41406a85b2488c4c978bab3d498c0808e141ae47eb4458c9f10803f4f6581fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.10

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page