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

Uploaded Source

Built Distribution

diffeqtorch-0.1.4-py2.py3-none-any.whl (24.2 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: diffeqtorch-0.1.4.tar.gz
  • Upload date:
  • Size: 24.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.4.tar.gz
Algorithm Hash digest
SHA256 d8c2deb178dd38b893e391f4930fedcb30845cc12108b018733c4cef67b9ce28
MD5 9b20d40bf4e3060646c812f0ce7c96c3
BLAKE2b-256 a907cf91a5839786d2207dc2d24c010a82104f174ce7ccd8da9fbae78de94fca

See more details on using hashes here.

File details

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

File metadata

  • Download URL: diffeqtorch-0.1.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 24.2 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.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 2d0e54ade3d5d816ee71431207ecd086ebe3914bcc85bc2515b378a54b1189cd
MD5 9cb897594d9a0bc18e2265bedf6970fc
BLAKE2b-256 f916d4c135d5e64beaaee8a814f7152359e137c3f702ac1fac05fda16914eb3c

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