Usage
The preset includes all the components that are used in the experiment, such as the agent internal components andthe environment to use.It additionally defines general parameters for the experiment itself, such as the training schedule,visualization parameters, and testing parameters.
This is the most common case. Just choose a preset using the -p flag and press enter.To list the available presets, use the -l flag.
Example:
Multi-threaded algorithms are very common these days.They typically achieve the best results, and scale gracefully with the number of threads.In Coach, running such algorithms is done by selecting a suitable preset, and choosing the number of threads to run using the flag.
Example:
- coach -p CartPole_A3C -n 8
Coach supports the multi-node runs in distributed mode. Specifically, the horizontal scale-out of rollout workers is implemented.In Coach, running such algorithms is done by selecting a suitable preset, enabling distributed coach using -dc
flag,passing distributed coach parameters using dcp
and choosing the number of to run using the -n
flag.For more details and instructions on how to use distributed Coach, see Usage - Distributed Coach.
Example:
- coach -p CartPole_ClippedPPO -dc -dcp <path-to-config-file> -n 8
Evaluating an Agent
For multi-threaded runs, an evaluation agent will constantly run in the background and evaluate the model during the training.
Additionally, it is possible to save checkpoints of the agents networks and then run only in evaluation mode.Saving checkpoints can be done by specifying the number of seconds between storing checkpoints using the -s
flag.The checkpoints will be saved into the experiment directory.Loading a model for evaluation can be done by specifying the flag with the experiment directory, and the —evaluate
flag to disable training.
Example:
Interacting with the environment as a human can be useful for understanding its difficulties and for collecting data for imitation learning.In Coach, this can be easily done by selecting a preset that defines the environment to use, and specifying the —play
flag.When the environment is loaded, the available keyboard buttons will be printed to the screen.Pressing the escape key when finished will end the simulation and store the replay buffer in the experiment dir.
Example:
- coach -et rl_coach.environments.gym_environment:Atari -lvl BreakoutDeterministic-v4 --play
Learning Through Imitation Learning
Learning through imitation of human behavior is a nice way to speedup the learning.In Coach, this can be done in two steps -
- Create a dataset of demonstrations by playing with the environment as a human.After this step, a pickle of the replay buffer containing your game play will be stored in the experiment directory.The path to this replay buffer will be printed to the screen.To do so, you should select an environment type and level through the command line, and specify the
—play
flag.
- coach -et rl_coach.environments.doom_environment:DoomEnvironmentParameters -lvl Basic --play
- Next, use an imitation learning preset and set the replay buffer path accordingly.
- The path can be set either from the command line or from the preset itself.
Example:
Rendering the environment can be done by using the -r
flag.When working with multi-threaded algorithms, the rendered image will be representing the game play of the evaluation worker.When working with single-threaded algorithms, the rendered image will be representing the single worker which can be either training or evaluating.Keep in mind that rendering the environment in single-threaded algorithms may slow the training to some extent.When playing with the environment using the flag, the environment will be rendered automatically without the need for specifying the -r
flag.
Example:
- coach -p Atari_DQN -lvl breakout -r
Coach allows storing GIFs of the agent game play.To dump GIF files, use the -dg
flag.The files are dumped after every evaluation episode, and are saved into the experiment directory, under a gifs sub-directory.
Example:
Switching Between Deep Learning Frameworks
Coach uses TensorFlow as its main backend framework, but it also supports MXNet.MXNet is optional, and by default, TensorFlow will be used.If MXNet was installed, it is possible to switch to MXNet using the -f
flag.
Example: