Skip to main content

paramfittorchdemo

This file will become your README and also the index of your documentation.

Install

pip install paramfittorchdemo

How to use

Using the integration routines in the library torchdiffeq we can integrate differential equations using torch modules as the base class for describing the systems. This allows for gradients to be computed with respect to the model parameters. This can be combined with the local optimization schemes used to train neural networks to give a powerful framework for fitting differential equation models found in the scientific literature.

In this package I provide a few example systems and parameter fitting routines for fitting the parameters.

The below code demonstrates how the van der Pol oscillator system defined as `torch.nn.module1 can be integrated against inside of pytorch.

import torch 
from torchdiffeq import odeint_adjoint as odeint
import matplotlib.pyplot as plt
vdp_model = VDP(mu=0.5)
ts = torch.linspace(0,30.0,1000)
# Create a batch of initial conditions 
batch_size = 30
initial_conditions = torch.tensor([0.01, 0.01]) + 0.2*torch.randn((batch_size,2))
sol = odeint(vdp_model, initial_conditions, ts, method='dopri5').detach().numpy()


# Check the solution
plt.plot(sol[:,:,0], sol[:,:,1], color='black', lw=0.5);
plt.title("Phase plot of the VDP oscillator");
plt.xlabel("x");
plt.ylabel("y");

The automatic batching dimensions means we can easily integrate a collection of initial conditions at the same time using these routines as well. The above shows the phase plane plot of the VDP oscillator for 30 random initial conditions.

Metadata

Release files for paramfittorchdemo 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for paramfittorchdemo 0.0.1
File Size Uploaded
paramfittorchdemo-0.0.1.tar.gz 10.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for paramfittorchdemo 0.0.1
File Interpreter ABI Platform
paramfittorchdemo-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 20.5 kB

Release files / paramfittorchdemo-0.0.1.tar.gz

Download URL paramfittorchdemo-0.0.1.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7f240d455f0eff274bca27dccd4371a56d8f538b984a2f4e1019d9f5d36884af
BLAKE2b-256 checksum
How to use checksums
59467b271dcc71340f687baa3df79ed9bc6e21330d19656c9d741cc70fb987b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.10

Release files / paramfittorchdemo-0.0.1-py3-none-any.whl

Download URL paramfittorchdemo-0.0.1-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
70e905ca0de1b5490535bd7951af0d6f865ab388941313198ff6a15c11773df5
BLAKE2b-256 checksum
How to use checksums
17fbe89bdae2858ade7545173f35ba667bd63c8bd1aabacfddb275a9d883b26e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.10

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page