Skip to main content

DifferentialEquations.jl with PyTorch.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

diffeqtorch-1.0.1.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

diffeqtorch-1.0.1-py2.py3-none-any.whl (9.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file diffeqtorch-1.0.1.tar.gz.

File metadata

  • Download URL: diffeqtorch-1.0.1.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for diffeqtorch-1.0.1.tar.gz
Algorithm Hash digest
SHA256 405edd3ae1fefe9fe2455ea3d2746c3c77338050ebfc047981fe0a0171d279bf
MD5 0c8f50b8bd83b47e78bad0b5b66c5dfe
BLAKE2b-256 de370c79655c5b2e07b6c0902064375ae227182ea62a4868e12d5e49aade124e

See more details on using hashes here.

File details

Details for the file diffeqtorch-1.0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: diffeqtorch-1.0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using 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

File hashes

Hashes for diffeqtorch-1.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 de484ab7bc833ce44c9bf1bd44d965ae6fd25bc70547bce1f35ba180d85bd21c
MD5 899029a25058cc4fb3e33e7ce569e2b3
BLAKE2b-256 c41406a85b2488c4c978bab3d498c0808e141ae47eb4458c9f10803f4f6581fb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page