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
- Simple ODE problem to demonstrate the interface and confirm gradients with analytical solution
- SIR model for a slighlty more complicated model with numerical gradient checking
- Hodgkin-Huxley model for a realistic example from Neuroscience
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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| diffeqtorch-1.0.1.tar.gz | 10.6 kB | Without provenance | Details for diffeqtorch-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| diffeqtorch-1.0.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for diffeqtorch-1.0.1-py2.py3-none-any.whl |
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
|
Security for diffeqtorch 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.