Giter Club home page Giter Club logo

vinci's Introduction

Vinci

Build Status Documentation Status PyPI Python versions

This is a generic, easy to use, and keras-compatible deep RL framework.

It began as a fork of keras-rl but is now a separated project.

Features

  • Define your Deep Nets using Keras
  • Simulate on the OpenAI Gym Environments
  • Easy to implement a new algorithm, using a well-defined API
  • Advanced training capabilities: Offline training, critic-only (or actor-only) training...
  • Easy logging : Tensorboard, Terminal...

Here's an example of the evolution of the policy during learning on the ContinuousMountainCar environment:

Documentation

An online documentation can be found at:

http://vinci.readthedocs.io/en/latest/

Installation

Run :

pip install  git+ssh://[email protected]/Phylliade/vinci.git

Creating the Deep Networks with Keras

Vinci is designed to seamlessy use Keras's networks. You can design your networks as always, using the Sequential or Functional API.

Environment-agnostic networks

Vinci also adds some utilities to make the network creation environment agnostic, which can be nice!

To do this, the env object (a wrapper around a gym env, of type rl.EnvWrapper) provides different utilities, depending if you're using the Sequential or Functional APIs.

Using the functional API

You just have to design your Keras model using the functional API and the state and action placeholders of the env object.

For example, for a simple critic:

# Inputs
observation = env.state
action = env.action
# Concatenate the inputs for the critic
inputs = concatenate([observation, action])

# Hidden layer
x = Dense(100)(inputs)
x = Activation('relu')(x)

# Output layer
x = Dense(1)(x)
x = Activation('linear')(x)

# Final model
critic = Model(inputs=[observation, action], outputs=[x])

Using the Sequential API

Since you have to specify the input shapes by hand, you can use the state_space_dim and action_space_dim attributes of the EnvWrapper.

For example of an actor:

actor = Sequential()

# Hidden layers
actor.add(Dense(400, input_shape=(env.state_space_dim,)))
actor.add(Activation("relu"))
actor.add(Dense(300))
actor.add(Activation("relu"))

# Output layer
actor.add(Dense(env.action_space_dim, activation="tanh"))

Efficiency of Keras models

Internally, Keras models are used in a functional fashion:

out = keras_model(in)

Some may wonder about some potential leaks with this usage, and they're right! With a traditional function, each time keras_model(in) is called, a new Tensor is created (and every underlying ops) and added to the Graph.

But, Keras uses a cache for the computations, so each call to keras_model(in) always results in the same variable.

vinci's People

Contributors

amn41 avatar benelot avatar bstriner avatar elsaico avatar jorahn avatar kashif avatar kidzik avatar matthiasplappert avatar osigaud avatar phylliade avatar raopku avatar rmst avatar ryanhope avatar wwxfromtju avatar

Watchers

 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.