Name: torch-twrl
Owner: Twitter, Inc.
Description: Torch-twrl is a package that enables reinforcement learning in Torch.
Created: 2016-09-01 07:10:56.0
Updated: 2017-12-21 18:30:41.0
Pushed: 2017-05-27 16:04:02.0
Size: 172
Language: Lua
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
torch-twrl is an RL framework built in Lua/Torch by Twitter.
Install torch
clone https://github.com/torch/distro.git ~/torch --recursive
/torch; bash install-deps;
stall.sh
Install torch-twrl
clone --recursive https://github.com/twitter/torch-twrl.git
orch-twrl
ocks make
Start a virtual environment, not necessary but it helps keep your installation clean
Download and install OpenAI Gym, gym-http-api requirements, and ffmpeg
install virtualenv
ualenv venv
ce venv/bin/activate
install gym
install -r src/gym-http-api/requirements.txt
install ffmpeg
You should have everything you need:
Start your gym_http_server with
on src/gym-http-api/gym_http_server.py
In a new console window (or tab), run the example script (policy gradient agent in environment CartPole-v0)
xamples
d u+x cartpole-pg.sh
rtpole-pg.sh
This script sets parameters for the experiment, in detail here is what it is calling:
un.lua \
-env 'CartPole-v0' \
-policy categorical \
-learningUpdate reinforce \
-model mlp \
-optimAlpha 0.9 \
-timestepsPerBatch 1000 \
-stepsizeStart 0.3 \
-gamma 1 \
-nHiddenLayerSize 10 \
-gradClip 5 \
-baselineType padTimeDepAvReturn \
-beta 0.01 \
-weightDecay 0 \
-windowSize 10 \
-nSteps 1000 \
-nIterations 1000 \
-video 100 \
-optimType rmsprop \
-verboseUpdate true \
-uploadResults false \
-renderAllSteps false
Your results should look something our results from the OpenAI Gym leaderboard
1) Test the gym-http-api
src/gym-http-api/
2
2) Start a Gym HTTP server in your virtual environment
on src/gym-http-api/gym_http_server.py
3) In a new console window (or tab), run torch-twrl tests
ocks make; th test/test.lua
Testing of RL development is a tricky endeavor, it requires well established, unified, baselines and a large community of active developers. The OpenAI Gym provides a great set of example environments for this purpose. Link: https://github.com/openai/gym
The OpenAI Gym is written in python and it expects algorithms which interact with its various environments to be as well. torch-twrl is compatible with the OpenAI Gym with the use of a Gym HTTP API from OpenAI; gym-http-api is a submodule of torch-twrl.
All Lua dependencies should be installed on your first build.
Note: if you make changes, you will need to recompile with
ocks make
torch-twrl implements several agents, they are located in src/agents. Agents are defined by a model, policy, and learning update.
The OpenAI Gym has many environments and is continuously growing. Some agents may be compatible with only a subset of environments. That is, an agent built for continuous action space environments may not work if the environment expects discrete action spaces.
Here is a useful table of the environments, with details on the different variables that may help to configure agents appropriately.
Continuous integration is accomplished by building with Travis. Testing is done with LUAJIT21, LUA51 and LUA52 with compilers gcc and clang.
Tests are defined in the /tests directory with separate basic unit tests set and a Gym integration test set.
torch-twrl is released under the MIT License. Copyright (c) 2016 Twitter, Inc.