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

Uploaded Source

Built Distribution

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

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: diffeqtorch-0.1.2.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.4

File hashes

Hashes for diffeqtorch-0.1.2.tar.gz
Algorithm Hash digest
SHA256 34ee20183220bda7d086b92965fcc96664e7a97c298e4d358e38f211de5292cf
MD5 45e9183da837b122cb598425600e8c58
BLAKE2b-256 8d0f5a7781fc4563a4f009b31b5233d23f79c08ad9b7664788f7eab3c044cb12

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: diffeqtorch-0.1.2-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.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.4

File hashes

Hashes for diffeqtorch-0.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 984e744f46ee9f2f415a66d4cf5c896a2cd004280d9def9cb890fb3219ee19f3
MD5 8d11f5c5cf3c789f4731655f8763c71c
BLAKE2b-256 52193e17f1736a13e8936336a2a40d9c8d5252e1fac9d9e2e5cfa561c70c24a8

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