Code Monkey home page Code Monkey logo

stable-dynamics-models's Introduction

Stable Dynamics Models

This repo contains an implementation of the method introduced in "Learning Stable Deep Dynamics Models" with PyTorch. This includes a PyTorch implementation of an Input Convex Neural Network.

The goal with this repo is to extend the results to account for controlled systems.

To get started with this library, install like so:

git clone https://github.com/harwiltz/stable-dynamics-models.git
cd stable-dynamics-models
pip install -r --user requirements.txt
python setup.py install --user

You can then instantiate an instance of a stable dynamics model with

from stablemodels import StableDynamicsModel
model = StableDynamicsModel((4,),                 # input shape
                            control_size=2,       # action size
                            alpha=0.9,            # lyapunov constant
                            layer_sizes=[64, 64], # NN layer sizes for lyapunov
                            lr=3e-4,              # learning rate for dynamics model
                            lyapunov_lr=3e-4,     # learning rate for lyapunov function
                            lyapunov_eps=1e-3)    # penalty for equilibrium away from 0

prediction = model(state, action)

stable-dynamics-models's People

Contributors

destructivereasoning avatar harwiltz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

csufangyu lmflrb

stable-dynamics-models's Issues

can you share the experiment?

hi,thanks very much.I am reading the code,but I feel fused.the lr of LyapunovFunction may not use in class LyapunovFunction,if not it it well work.so can you share some experiment?

class LyapunovFunction(nn.Module):
    def __init__(self,
                 input_shape,
                 smooth_relu_thresh=0.1,
                 layer_sizes=[64, 64],
                 lr=3e-4,
                 eps=1e-3):
        super(LyapunovFunction, self).__init__()
        self._d = smooth_relu_thresh
        self._icnn = ICNN(input_shape, layer_sizes, self.smooth_relu)
        self._eps = eps

    def forward(self, x):
        g = self._icnn(x)
        g0 = self._icnn(torch.zeros_like(x))
        return self.smooth_relu(g - g0) + self._eps * x.pow(2).sum()

    def smooth_relu(self, x):
        relu = x.relu()
        # TODO: Is there a clean way to avoid computing both of these on all elements?
        sq = x.pow(2) / (2 * self._d)
        lin = x - self._d/2

        return torch.where(relu < self._d, sq, lin)

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.