Coach is a python reinforcement learning research framework containing implementation of many state-of-the-art algorithms.
It exposes a set of easy-to-use APIs for experimenting with new RL algorithms, and allows simple integration of new environments to solve. Basic RL components (algorithms, environments, neural network architectures, exploration policies, ...) are well decoupled, so that extending and reusing existing components is fairly painless.
Training an agent to solve an environment is as easy as running:
python3 coach.py -p CartPole_DQN -r
Blog post from the Intel® Nervana™ website can be found here.
Note: Coach has only been tested on Ubuntu 16.04 LTS, and with Python 3.5.
Coach's installer will setup all the basics needed to get the user going with running Coach on top of OpenAI Gym environments. This can be done by running the following command and then following the on-screen printed instructions:
Coach creates a virtual environment and installs in it to avoid changes to the user's system.
In order to activate and deactivate Coach's virtual environment:
In addition to OpenAI Gym, several other environments were tested and are supported. Please follow the instructions in the Supported Environments section below in order to install more environments.
Coach's installer installs Intel-Optimized TensorFlow, which does not support GPU, by default. In order to have Coach running with GPU, a GPU supported TensorFlow version must be installed. This can be done by overriding the TensorFlow version:
pip3 install tensorflow-gpu
Coach supports both TensorFlow and neon deep learning frameworks.
Switching between TensorFlow and neon backends is possible by using the
Using TensorFlow (default):
There are several available presets in presets.py.
To list all the available presets use the
To run a preset, use:
python3 coach.py -r -p <preset_name>
- CartPole environment using Policy Gradients:
python3 coach.py -r -p CartPole_PG
- Pendulum using Clipped PPO:
python3 coach.py -r -p Pendulum_ClippedPPO -n 8
- MountainCar using A3C:
python3 coach.py -r -p MountainCar_A3C -n 8
- Doom basic level using Dueling network and Double DQN algorithm:
python3 coach.py -r -p Doom_Basic_Dueling_DDQN
- Doom health gathering level using Mixed Monte Carlo:
python3 coach.py -r -p Doom_Health_MMC
It is easy to create new presets for different levels or environments by following the same pattern as in presets.py
Running Coach Dashboard (Visualization)
Training an agent to solve an environment can be tricky, at times.
In order to debug the training process, Coach outputs several signals, per trained algorithm, in order to track algorithmic performance.
While Coach trains an agent, a csv file containing the relevant training signals will be saved to the 'experiments' directory. Coach's dashboard can then be used to dynamically visualize the training signals, and track algorithmic behavior.
To use it, run:
Framework documentation, algoritmic description and instructions on how to contribute a new agent/environment can be found here.
Parallelizing an Algorithm
Since the introduction of A3C in 2016, many algorithms were shown to benefit from running multiple instances in parallel, on many CPU cores. So far, these algorithms include A3C, DDPG, PPO, and NAF, and this is most probably only the begining.
Parallelizing an algorithm using Coach is straight-forward.
The following method of NetworkWrapper parallelizes an algorithm seamlessly:
Once a parallelized run is started, the
train_and_sync_networks API will apply gradients from each local worker's network to the main global network, allowing for parallel training to take place.
Then, it merely requires running Coach with the
-n flag and with the number of workers to run with. For instance, the following command will set 16 workers to work together to train a MuJoCo Hopper:
python3 coach.py -p Hopper_A3C -n 16
Installed by default by Coach's installer.
Follow the instructions described in the ViZDoom repository -
Additionally, Coach assumes that the environment variable VIZDOOM_ROOT points to the ViZDoom installation directory.
Follow the instructions described in the roboschool repository -
Follow the instructions described in the GymExtensions repository -
Additionally, add the installation directory to the PYTHONPATH environment variable.
Follow the instructions described in the Quick Start Guide (basically just - 'pip install pybullet')
- Deep Q Network (DQN)
- Double Deep Q Network (DDQN)
- Dueling Q Network
- Mixed Monte Carlo (MMC)
- Persistent Advantage Learning (PAL)
- Categorical Deep Q Network (C51)
- Quantile Regression Deep Q Network (QR-DQN)
- Bootstrapped Deep Q Network
- N-Step Q Learning | Distributed
- Neural Episodic Control (NEC)
- Normalized Advantage Functions (NAF) | Distributed
- Policy Gradients (PG) | Distributed
- Asynchronous Advantage Actor-Critic (A3C) | Distributed
- Deep Deterministic Policy Gradients (DDPG) | Distributed
- Proximal Policy Optimization (PPO)
- Clipped Proximal Policy Optimization | Distributed
- Direct Future Prediction (DFP) | Distributed
Coach is released as a reference code for research purposes. It is not an official Intel product, and the level of quality and support may not be as expected from an official product. Additional algorithms and environments are planned to be added to the framework. Feedback and contributions from the open source and RL research communities are more than welcome.