GithubHelp home page GithubHelp logo

vatsal-iitb / dlkoopman Goto Github PK

View Code? Open in Web Editor NEW

This project forked from galoisinc/dlkoopman

0.0 0.0 0.0 10.51 MB

Koopman theory implemented using deep learning

License: MIT License

Python 99.73% Dockerfile 0.27%

dlkoopman's Introduction

A Python package for Koopman theory using deep learning.

Overview

Koopman theory is a mathematical technique to achieve data-driven approximations of nonlinear dynamical systems by encoding them into a linear space. dlkoopman uses deep learning to learn such an encoding, while simultaneously learning the linear dynamics.

Key features

  • State prediction (StatePred) - Train on individual states (snapshots) of a system, then predict unknown states.
    • E.g: What is the pressure vector on this aircraft for $23.5^{\circ}$ angle of attack?
  • Trajectory prediction (TrajPred) - Train on generated trajectories of a system, then predict unknown trajectories for new initial states.
    • E.g: What is the behavior of this pendulum if I start from the point $[1,-1]$?
  • General and reusable - supports data from any dynamical system.
  • Novel error function Average Normalized Absolute Error (ANAE) for visualizing performance.
  • Extensive options and a ready-to-use hyperparameter search module to improve performance.
  • Built using Pytorch, supports both CPU and GPU platforms.

Why dlkoopman?

We bridge the gap between a) software packages that restrict the learning of a good linearizable encoding (e.g. pykoopman), and b) efforts that learn encodings for specific applications instead of being a general tool (e.g. DeepKoopman).

Installation

With pip (for regular users)

pip install dlkoopman

From source (for development)

git clone https://github.com/GaloisInc/dlkoopman.git
cd dlkoopman
pip install .

Running as a Docker container

DLKoopman can also be run as a docker container by pulling the image from galoisinc/dlkoopman:<version>, e.g. docker pull galoisinc/dlkoopman:v1.0.2.

Tutorials and examples

Available in the examples folder.

Documentation and API Reference

Available at https://galoisinc.github.io/dlkoopman/.

Description

Koopman theory

Assume a dynamical system $x_{i+1} = F(x_i)$, where $x$ is the (genrally multi-dimensional) state of the system at index $i$, and $F$ is the (generally nonlinear) evolution rule describing the dynamics of the system. Koopman theory attempts to encode $x$ into a different space $y = g(x)$ where the dynamics are linear, i.e. $y_{i+1} = Ky_i$, where $K$ is the Koopman matrix. This is incredibly powerful since the state $y_i$ at any index $i$ can be predicted from the initial state $y_0$ as $y_i = K^iy_0$. This is then decoded back into the original space as $x = g^{-1}(y)$.

For a thorough mathematical treatment, see this technical report.

dlkoopman training

This is a small example with three input states $\left[x_0, x_1, x_2\right]$. These are passed through an encoder neural network to get encoded states $\left[y_0, y_1, y_2\right]$. These are passed through a decoder neural network to get $\left[\hat{x}_0, \hat{x}_1, \hat{x}_2\right]$, and also used to learn $K$. This is used to derive predicted encoded states $\left[\mathsf{y}_1, \mathsf{y}_2\right]$, which are then passed through the same decoder to get predicted approximations $\left[\hat{\mathsf{x}}_1, \hat{\mathsf{x}}_2\right]$ to the original input states.

Errors mimimized during training:

  • Train the autoencoder - Reconstruction recon between $x$ and $\hat{x}$.
  • Train the Koopman matrix - Linearity lin between $y$ and $\mathsf{y}$.
  • Combine the above - Prediction pred between $x$ and $\hat{\mathsf{x}}$.

dlkoopman prediction

Prediction happens after training.

(a) State prediction - Compute predicted states for new indexes such as $i'$. This uses the eigendecomposition of $K$, so $i'$ can be any real number - positive (forward extapolation), negative (backward extrapolation), or fractional (interpolation).

(b) Trajectory prediction - Generate predicted trajectories $j'$ for new starting states such as $x^{j'}_0$. This uses a linear neural net layer to evolve the initial state.

Known issues

Some common issues and ways to overcome them are described in the known issues.

How to cite

Please cite the accompanying paper:

@article{Dey2022_dlkoopman,
    author = {Sourya Dey and Eric William Davis},
    title = {DLKoopman: A deep learning software package for Koopman theory},
    journal = {arXiv preprint arXiv:2211.08992},
    year = {2022},
    note = {Submitted to 5th Annual Learning for Dynamics & Control (L4DC) Conference}
}

References

  • B. O. Koopman - Hamiltonian systems and transformation in Hilbert space
  • J. Nathan Kutz, Steven L. Brunton, Bingni Brunton, Joshua L. Proctor - Dynamic Mode Decomposition
  • Bethany Lusch, J. Nathan Kutz & Steven L. Brunton - Deep learning for universal linear embeddings of nonlinear dynamics

Distribution Statement

This material is based upon work supported by the United States Air Force and DARPA under Contract No. FA8750-20-C-0534. Any opinions, findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the United States Air Force and DARPA. Distribution Statement A, "Approved for Public Release, Distribution Unlimited."

dlkoopman's People

Contributors

crdollar avatar souryadey avatar sykloid avatar

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.