NODEFit


NameNODEFit JSON
Version 0.1 PyPI version JSON
download
home_pagehttps://github.com/gpavanb1/NODEFit
SummaryFit time-series data with a Neural Differential Equation
upload_time2023-12-17 10:11:25
maintainer
docs_urlNone
authorgpavanb1
requires_python
licenseMIT
keywords python neural-network pytorch numerical-methods neural-ode
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # NODEFit

![Downloads](https://pepy.tech/badge/nodefit)(https://pepy.tech/project/nodefit)

Fit time-series data with a Neural Differential Equation!

This repository contains time-series data fit capabilities using both Neural Ordinary Differential Equations and Neural Stochastic Differential Equations

GPU support is packaged as part of [PyTorch](https://pytorch.org/)

# How to install and execute?

Tested on Python 3.9

Just run 
```
pip install nodefit
```

The following program illustrates a basic example
```python
import numpy as np
import torch.nn as nn
from nodefit.constants import DEVICE

from nodefit.neural_ode import NeuralODE
from nodefit.neural_sde import NeuralSDE


###
# DEFINE NETWORKS
###

# Neural ODE parameters
ndim, drift_nhidden, diffusion_nhidden = 2, 10, 2

drift_nn = nn.Sequential(
    nn.Linear(ndim+1, drift_nhidden),
    nn.Sigmoid(),
    nn.Linear(drift_nhidden, ndim)
).double().to(DEVICE)

diffusion_nn = nn.Sequential(
    nn.Linear(ndim+1, diffusion_nhidden),
    nn.Sigmoid(),
    nn.Linear(diffusion_nhidden, ndim)
).double().to(DEVICE)

###
# PROVIDE DATA
###

# Training between data for 0 and 5 seconds
t = np.linspace(0, 5, 10)
# Provide data as list of lists with starting condition
data = np.array([[...]])

###
# FIT USING NEURALODE
###
print('Performing fit using Neural ODE...')

neural_ode = NeuralODE(drift_nn, t, data)
neural_ode.train(2000)

# # Extrapolate the training data to 10 seconds
extra_data = neural_ode.extrapolate(10)
neural_ode.plot(extra_data)

###
# FIT USING NEURALSDE
###
print('Performing fit using Neural SDE...')

neural_sde = NeuralSDE(drift_nn, diffusion_nn, t, data)
neural_sde.train(1)

# # Extrapolate the training data to 10 seconds
extra_data = neural_sde.extrapolate(10)
neural_sde.plot(extra_data)

```

## Sample Output

![Sample Output](anim/output.gif)


## Whom to contact?

Please direct your queries to [gpavanb1](http://github.com/gpavanb1)
for any questions.

## Acknowledgements

This package would not be possible without the supporting packages - [torchdiffeq](https://github.com/rtqichen/torchdiffeq) and [torchsde](https://github.com/google-research/torchsde)
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/gpavanb1/NODEFit",
    "name": "NODEFit",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python neural-network pytorch numerical-methods neural-ode",
    "author": "gpavanb1",
    "author_email": "gpavanb@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/24/7d/1cf1a2cfbcd48378ea6505c38f48a6d5adbab04e29ceb86fd85dc24d3ecc/NODEFit-0.1.tar.gz",
    "platform": null,
    "description": "# NODEFit\n\n![Downloads](https://pepy.tech/badge/nodefit)(https://pepy.tech/project/nodefit)\n\nFit time-series data with a Neural Differential Equation!\n\nThis repository contains time-series data fit capabilities using both Neural Ordinary Differential Equations and Neural Stochastic Differential Equations\n\nGPU support is packaged as part of [PyTorch](https://pytorch.org/)\n\n# How to install and execute?\n\nTested on Python 3.9\n\nJust run \n```\npip install nodefit\n```\n\nThe following program illustrates a basic example\n```python\nimport numpy as np\nimport torch.nn as nn\nfrom nodefit.constants import DEVICE\n\nfrom nodefit.neural_ode import NeuralODE\nfrom nodefit.neural_sde import NeuralSDE\n\n\n###\n# DEFINE NETWORKS\n###\n\n# Neural ODE parameters\nndim, drift_nhidden, diffusion_nhidden = 2, 10, 2\n\ndrift_nn = nn.Sequential(\n    nn.Linear(ndim+1, drift_nhidden),\n    nn.Sigmoid(),\n    nn.Linear(drift_nhidden, ndim)\n).double().to(DEVICE)\n\ndiffusion_nn = nn.Sequential(\n    nn.Linear(ndim+1, diffusion_nhidden),\n    nn.Sigmoid(),\n    nn.Linear(diffusion_nhidden, ndim)\n).double().to(DEVICE)\n\n###\n# PROVIDE DATA\n###\n\n# Training between data for 0 and 5 seconds\nt = np.linspace(0, 5, 10)\n# Provide data as list of lists with starting condition\ndata = np.array([[...]])\n\n###\n# FIT USING NEURALODE\n###\nprint('Performing fit using Neural ODE...')\n\nneural_ode = NeuralODE(drift_nn, t, data)\nneural_ode.train(2000)\n\n# # Extrapolate the training data to 10 seconds\nextra_data = neural_ode.extrapolate(10)\nneural_ode.plot(extra_data)\n\n###\n# FIT USING NEURALSDE\n###\nprint('Performing fit using Neural SDE...')\n\nneural_sde = NeuralSDE(drift_nn, diffusion_nn, t, data)\nneural_sde.train(1)\n\n# # Extrapolate the training data to 10 seconds\nextra_data = neural_sde.extrapolate(10)\nneural_sde.plot(extra_data)\n\n```\n\n## Sample Output\n\n![Sample Output](anim/output.gif)\n\n\n## Whom to contact?\n\nPlease direct your queries to [gpavanb1](http://github.com/gpavanb1)\nfor any questions.\n\n## Acknowledgements\n\nThis package would not be possible without the supporting packages - [torchdiffeq](https://github.com/rtqichen/torchdiffeq) and [torchsde](https://github.com/google-research/torchsde)",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Fit time-series data with a Neural Differential Equation",
    "version": "0.1",
    "project_urls": {
        "Bug Reports": "https://github.com/gpavanb1/NODEFit/issues",
        "Homepage": "https://github.com/gpavanb1/NODEFit",
        "Source": "https://github.com/gpavanb1/NODEFit/"
    },
    "split_keywords": [
        "python",
        "neural-network",
        "pytorch",
        "numerical-methods",
        "neural-ode"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "247d1cf1a2cfbcd48378ea6505c38f48a6d5adbab04e29ceb86fd85dc24d3ecc",
                "md5": "81333145dadd1ab532e00a80f675e242",
                "sha256": "c36790b0d374fd156d178e93b72a6d76f5c8f98f56fa0820a43cd1c09f6446d9"
            },
            "downloads": -1,
            "filename": "NODEFit-0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "81333145dadd1ab532e00a80f675e242",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5427,
            "upload_time": "2023-12-17T10:11:25",
            "upload_time_iso_8601": "2023-12-17T10:11:25.716778Z",
            "url": "https://files.pythonhosted.org/packages/24/7d/1cf1a2cfbcd48378ea6505c38f48a6d5adbab04e29ceb86fd85dc24d3ecc/NODEFit-0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-17 10:11:25",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "gpavanb1",
    "github_project": "NODEFit",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "nodefit"
}
        
Elapsed time: 0.15637s