Reinforcement learning framework and algorithms implemented in PyTorch.
Some implemented algorithms:
- Reinforcement Learning with Imagined Goals (RIG)
- Temporal Difference Models (TDMs)
- Hindsight Experience Replay (HER)
- Deep Deterministic Policy Gradient (DDPG)
- (Double) Deep Q-Network (DQN)
- Soft Actor Critic (SAC)
- Twin Delayed Deep Determinstic Policy Gradient (TD3)
- Twin Soft Actor Critic (Twin SAC)
- example script
- Combination of SAC and TD3
To get started, checkout the example scripts, linked above.
12/04/2018
- Add RIG implementation
12/03/2018
- Add HER implementation
- Add doodad support
10/16/2018
- Upgraded to PyTorch v0.4
- Added Twin Soft Actor Critic Implementation
- Various small refactor (e.g. logger, evaluate code)
- Copy
config_template.py
toconfig.py
:
cp rlkit/launchers/config_template.py rlkit/launchers/config.py
- Install and use the included Ananconda environment
$ conda env create -f environment/[linux-cpu|linux-gpu|mac]-env.yml
$ source activate rlkit
(rlkit) $ python examples/ddpg.py
Choose the appropriate .yml
file for your system.
These Anaconda environments use MuJoCo 1.5 and gym 0.10.5.
You'll need to get your own MuJoCo key if you want to use MuJoCo.
DISCLAIMER: the mac environment has only been tested without a GPU.
For an even more portable solution, try using the docker image provided in environment/docker
.
The Anaconda env should be enough, but this docker image addresses some of the rendering issues that may arise when using MuJoCo 1.5 and GPUs.
The docker image supports GPU, but it should work without a GPU.
To use a GPU with the image, you need to have nvidia-docker installed.
During training, the results will be saved to a file called under
LOCAL_LOG_DIR/<exp_prefix>/<foldername>
LOCAL_LOG_DIR
is the directory set byrlkit.launchers.config.LOCAL_LOG_DIR
. Default name is 'output'.<exp_prefix>
is given either tosetup_logger
.<foldername>
is auto-generated and based off ofexp_prefix
.- inside this folder, you should see a file called
params.pkl
. To visualize a policy, run
(rlkit) $ python scripts/sim_policy.py LOCAL_LOG_DIR/<exp_prefix>/<foldername>/params.pkl
If you have rllab installed, you can also visualize the results
using rllab
's viskit, described at
the bottom of this page
tl;dr run
python rllab/viskit/frontend.py LOCAL_LOG_DIR/<exp_prefix>/
to visualize all experiments with a prefix of exp_prefix
. To only visualize a single run, you can do
python rllab/viskit/frontend.py LOCAL_LOG_DIR/<exp_prefix>/<folder name>
Alternatively, if you don't want to clone all of rllab
, a repository containing only viskit can be found here. You can similarly visualize results with.
python viskit/viskit/frontend.py LOCAL_LOG_DIR/<exp_prefix>/
This viskit
repo also has a few extra nice features, like plotting multiple Y-axis values at once, figure-splitting on multiple keys, and being able to filter hyperparametrs out.
To visualize a TDM policy, run
(rlkit) $ python scripts/sim_tdm_policy.py LOCAL_LOG_DIR/<exp_prefix>/<foldername>/params.pkl
To visualize a HER policy, run
(rlkit) $ python scripts/sim_goal_conditioned_policy.py
LOCAL_LOG_DIR/<exp_prefix>/<foldername>/params.pkl
The run_experiment
function makes it easy to run Python code on Amazon Web
Services (AWS) or Google Cloud Platform (GCP) by using
doodad.
It's as easy as:
from rlkit.launchers.launcher_util import run_experiment
def function_to_run(variant):
learning_rate = variant['learning_rate']
...
run_experiment(
function_to_run,
exp_prefix="my-experiment-name",
mode='ec2', # or 'gcp'
variant={'learning_rate': 1e-3},
)
You will need to set up parameters in config.py (see step one of Installation).
This requires some knowledge of AWS and/or GCP, which is beyond the scope of
this README.
To learn more, more about doodad
, go to the repository.
A lot of the coding infrastructure is based on rllab. The serialization and logger code are basically a carbon copy of the rllab versions.
The Dockerfile is based on the OpenAI mujoco-py Dockerfile.
- Include policy-gradient algorithms.
- Include model-based algorithms.