Giter Club home page Giter Club logo

constrained-hamiltonian-neural-networks's Introduction

Simplifying Hamiltonian and Lagrangian Neural Networks via Explicit Constraints

This repo contains the implementation and the experiments for the paper

Simplifying Hamiltonian and Lagrangian Neural Networks via Explicit Constraints by Marc Finzi, Alex Wang, and Andrew Gordon Wilson.

Some example systems

Each of these animations were produced by running

from IPython.display import HTML
from biases.systems import ChainPendulum, CoupledPendulum, MagnetPendulum
HTML(CoupledPendulum(3).animate())

Code

Our code in the biases directory relies on some publically available codebases which we package together as a conda environment. Code Climate maintainability ForTheBadge built-with-science

Installation instructions

Install PyTorch>=1.0.0

(Optional) Create a wandb account for experiment tracking

Pip

git clone https://github.com/mfinzi/constrained-hamiltonian-neural-networks.git
cd constrained-hamiltonian-neural-networks
pip install -e .

Conda

git clone https://github.com/mfinzi/constrained-hamiltonian-neural-networks.git
cd constrained-hamiltonian-neural-networks
conda env create -f conda_env.yml
pip install ./

Train Models

We have implemented a variety of challenging benchmarks for modeling physical dynamical systems such as ChainPendulum, CoupledPendulum,MagnetPendulum,Gyroscope,Rotor which can be selected with the --body-class argument.

You can run our models CHNN and CLNN as well as the baseline NN (NeuralODE), DeLaN, and HNN models with the network-class argument as shown below.

python pl_trainer.py --network-class CHNN --body-class Gyroscope --wandb-project "YOUR WANDB PROJECT"
python pl_trainer.py --network-class CLNN --body-class Gyroscope --wandb-project "YOUR WANDB PROJECT"
python pl_trainer.py --network-class HNN --body-class Gyroscope --wandb-project "YOUR WANDB PROJECT"
python pl_trainer.py --network-class DeLaN --body-class Gyroscope --wandb-project "YOUR WANDB PROJECT"
python pl_trainer.py --network-class NN --body-class Gyroscope --wandb-project "YOUR WANDB PROJECT"

Our explicitly constrained CHNN and CLNN outperform the competing methods by several orders of magnitude across the different benchmarks as shown below.

If you find our work helpful, please cite it with

@article{finzi2020simplifying,
  title={Simplifying Hamiltonian and Lagrangian Neural Networks via Explicit Constraints},
  author={Finzi, Marc and Wang, Alex and Wilson, Andrew Gordon},
  journal={NeurIPS},
  year={2020}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.