|
| 1 | +# Unity Ml-Agents Custom trainers Plugin |
| 2 | + |
| 3 | +As an attempt to bring a wider variety of reinforcement learning algorithms to our users, we have added custom trainers |
| 4 | +capabilities. we introduce an extensible plugin system to define new trainers based on the High level trainer API |
| 5 | +in `Ml-agents` Package. This will allow rerouting `mlagents-learn` CLI to custom trainers and extending the config files |
| 6 | +with hyper-parameters specific to your new trainers. We will expose a high-level extensible trainer (both on-policy, |
| 7 | +and off-policy trainers) optimizer and hyperparameter classes with documentation for the use of this plugin. For more |
| 8 | +infromation on how python plugin system works see [Plugin interfaces](Training-Plugins.md). |
| 9 | + |
| 10 | +## Overview |
| 11 | +To add new custom trainers to ML-agents, you would need to create a new python package. |
| 12 | +To give you an idea of how to structure your package, we have created a [mlagents_trainer_plugin](../ml-agents-trainer-plugin) package ourselves as an |
| 13 | +example, with implementation of `A2c` and `DQN` algorithms. You would need a `setup.py` file to list extra requirements and |
| 14 | +register the new RL algorithm in ml-agents ecosystem and be able to call `mlagents-learn` CLI with your customized |
| 15 | +configuration. |
| 16 | + |
| 17 | + |
| 18 | +```shell |
| 19 | +├── mlagents_trainer_plugin |
| 20 | +│ ├── __init__.py |
| 21 | +│ ├── a2c |
| 22 | +│ │ ├── __init__.py |
| 23 | +│ │ ├── a2c_3DBall.yaml |
| 24 | +│ │ ├── a2c_optimizer.py |
| 25 | +│ │ └── a2c_trainer.py |
| 26 | +│ └── dqn |
| 27 | +│ ├── __init__.py |
| 28 | +│ ├── dqn_basic.yaml |
| 29 | +│ ├── dqn_optimizer.py |
| 30 | +│ └── dqn_trainer.py |
| 31 | +└── setup.py |
| 32 | +``` |
| 33 | +## Installation and Execution |
| 34 | +To install your new package, you need to have `ml-agents-env` and `ml-agents` installed following by the installation of |
| 35 | +plugin package. |
| 36 | + |
| 37 | +```shell |
| 38 | +> pip3 install -e ./ml-agents-envs && pip3 install -e ./ml-agents |
| 39 | +> pip install -e <./ml-agents-trainer-plugin> |
| 40 | +``` |
| 41 | + |
| 42 | +Following the previous installations your package is added as an entrypoint and you can use a config file with new |
| 43 | +trainers: |
| 44 | +```shell |
| 45 | +mlagents-learn ml-agents-trainer-plugin/mlagents_trainer_plugin/a2c/a2c_3DBall.yaml --run-id <run-id-name> |
| 46 | +--env <env-executable> |
| 47 | +``` |
| 48 | + |
| 49 | +## Tutorial |
| 50 | +Here’s a step-by-step [tutorial](.) on how to write a setup file and extend ml-agents trainers, optimizers, and |
| 51 | +hyperparameter settings.To extend ML-agents classes see references on |
| 52 | +[trainers](Python-On-Off-Policy-Trainer-Documentation.md) and [Optimizer](Python-Optimizer-Documentation.md). |
0 commit comments