Yet another zoo of (Deep) Reinforcment Learning methods in Python using PyTorch
Project description
ai-traineree
The intention is to have a zoo of Deep Reinforcment Learning methods and showcasing their application on some environments.
Read more in the doc: ReadTheDocs AI-Traineree.
Why another?
The main reason is the implemention philosophy. We strongly believe that agents should be emerged in the environment and not the other way round. Majority of the popular implementations pass environment instance to the agent as if the agent was the focus point. This might ease implementation of some algorithms but it isn't representative of the world; agents want to control the environment but that doesn't mean they can/should.
That, and using PyTorch instead of Tensorflow or JAX.
Quick start
To get started with training your RL agent you need three things: an agent, an environment and a runner. Let's say you want to train a DQN agent on OpenAI CartPole-v1:
from ai_traineree.agents.dqn import DQNAgent
from ai_traineree.runners.env_runner import EnvRunner
from ai_traineree.tasks import GymTask
task = GymTask('CartPole-v1')
agent = DQNAgent(task.obs_space, task.action_space)
env_runner = EnvRunner(task, agent)
scores = env_runner.run()
or execute one of provided examples
$ python -m examples.cart_dqn
That's it.
Installation
PyPi (recommended)
The quickest way to install package is through pip
.
$ pip install ai-traineree
Git repository clone
As usual with Python, the expectation is to have own virtual environment and then pip install requirements. For example,
> python -m venv .venv
> git clone git@github.com:laszukdawid/ai-traineree.git
> source .venv/bin/activate
> python setup.py install
Current state
Playing gym
One way to improve learning speed is to simply show them how to play or, more researchy/creepy, provide a proper seed.
This isn't a general rule, since some algorithms train better without any human interaction, but since you're on GitHub... that's unlikely your case.
Currently there's a script interact.py
which uses OpenAI Gym's play API to record moves and AI Traineree to store them
in a buffer. Such buffers can be loaded by agents on initiation.
This is just a beginning and there will be more work on these interactions.
Requirement: Install pygame
.
Agents
Short | Progress | Link | Full name | Doc |
---|---|---|---|---|
DQN | Implemented | DeepMind, Nature | Deep Q-learning Network | Doc |
DDPG | Implemented | arXiv | Deep Deterministic Policy Gradient | Doc |
D4PG | Implemented | arXiv | Distributed Distributional Deterministic Policy Gradients | Doc |
TD3 | Implemented | arXiv | Twine Delayed Deep Deterministic policy gradient | Doc |
PPO | Implemented | arXiv | Proximal Policy Optimization | Doc |
SAC | Implemented | arXiv | Soft Actor Critic | Doc |
TRPO | arXiv | Trust Region Policy Optimization | ||
RAINBOW | Implemented | arXiv | DQN with a few improvements | Doc |
Multi agents
We provide both Multi Agents agents entities and means to execute them against supported (below) environements. However, that doesn't mean one can be used without the other.
Short | Progress | Link | Full name | Doc |
---|---|---|---|---|
IQL | Implemented | Independent Q-Learners | Doc | |
MADDPG | Implemented | arXiv | Multi agent DDPG | Doc |
Loggers
Supports using Tensorboard (via PyTorch's SummaryWriter) and Neptune to display metrics. Wrappers are provided as TensorboardLogger
and NeptuneLogger
.
Note: In order to use Neptune one needs to install neptune-client (pip install neptune-client
).
Environments
Name | Progress | Link |
---|---|---|
OpenAI Gym - Classic | Done | |
OpenAI Gym - Atari | Done | |
OpenAI Gym - MuJoCo | Not interested. | |
PettingZoo | Initial support | Page / GitHub |
Unity ML | Somehow supported. | Page |
MAME Linux emulator | Interested. | Official page |
Development
We are open to any contributions. If you want to contribute but don't know what then feel free to reach out (see Contact below). The best way to start is through updating documentation and adding tutorials. In addition there are many other things that we know of which need improvement but also plenty that we don't know of.
Setting up development environment requires installing dev
and test
extra packages.
The dev
extras are for mainly for linting and formatting, and the test
is for running tests.
We recommend using pip
so to install everything requires for development run
$ pip install -e .[dev,test]
Once installed, please configure your IDE to use black
as formatter, pycodestyle
as linter,
and isort
for sorting imports. All these are included in the dev
extra packages.
Contact
Should we focus on something specificallly? Let us know by opening a feature request GitHub issue or contacting through ai-traineree@dawid.lasz.uk.
Citing project
@misc{ai-traineree,
author = {Laszuk, Dawid},
title = {AI Traineree: Reinforcement learning toolset},
year = {2020},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/laszukdawid/ai-traineree}},
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ai-traineree-0.4.4.tar.gz
.
File metadata
- Download URL: ai-traineree-0.4.4.tar.gz
- Upload date:
- Size: 86.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9fd7ebe1be70aa5ba7e4375cc4f9c5ddee4a54943e4d126d33a09d3b7fe7df0a |
|
MD5 | ed1e4d47d54bc9e01763c731cc7f6dc6 |
|
BLAKE2b-256 | d8c689eb3c040c2c91887bd10c2c3797135f1dd0bb1769ab76463480eb7f8eb7 |
File details
Details for the file ai_traineree-0.4.4-py3-none-any.whl
.
File metadata
- Download URL: ai_traineree-0.4.4-py3-none-any.whl
- Upload date:
- Size: 128.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2c819dd4fb82bd350bbbcc0b623c06ba0d9a3c0a988d108e17ba10c0623d902 |
|
MD5 | 236cb8a94a6e2ff89f8a160ce65951b6 |
|
BLAKE2b-256 | 6e7ff93190987a54ac2379058b648f759d048bcdf4554db9b4b5af9eb7b8cafb |