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.0.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: diffeqtorch-1.0.0.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for diffeqtorch-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ab3caa0980e9d0b4d489d83903e550e8a9ca092c16f49863413f74abf30b9d13
MD5 848858dd37f41d2f029ef091661d7c73
BLAKE2b-256 9d670c342750f957ecd62f2b56358ed8a7a15cd7a53362183405e05b0e51e803

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: diffeqtorch-1.0.0-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.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for diffeqtorch-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 47e9087d5beaa28e816dec194c74b7bcd60f546f7b5a3e0f733a99c836c215b2
MD5 d7c7fb57c17c9fd2da68d4ee73df4c14
BLAKE2b-256 a76407b8aaec9d67eb9964f85fb060401ba3c40e243014501a272259aa6aa6e2

See more details on using hashes here.

Provenance

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