Skip to main content

ai-traineree

DocStatus codecov Codacy Badge Conda

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.

CartPole-v1 Snek

Why another Deep Reinforcement Learning framework?

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 Gymnasium CartPole-v1:

from aitraineree.agents.dqn import DQNAgent
from aitraineree.runners.env_runner import EnvRunner
from aitraineree.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

The quickest way to install package is through pip.

pip install ai-traineree

In case you're using uv which is recommended as it makes building environments much faster, use

uv add ai-traineree
# or
# uv pip install ai-traineree

Conda

AI Traineree is also available in Conda via conda-forge channel

conda install -c conda-forge ai-traineree

Source: https://anaconda.org/conda-forge/ai-traineree

Git repository clone

As usual with Python, the expectation is to have own virtual environment and then install project dependencies. For example,

git clone git@github.com:laszukdawid/ai-traineree.git
cd ai-traineree
python -m venv .venv
source .venv/bin/activate
pip install -e .
# or, with uv
# uv sync

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 Gymnasium'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 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) to display metrics. A lightweight FileLogger is also available for local experiment data.

Environments

Name Progress Link
Gymnasium - Classic Done
Gymnasium - Atari Done
Gymnasium - 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 is easiest with uv, using the dev dependency group:

uv sync --dev

Typical development commands:

uvx ruff@0.3.0 check
uv run pytest

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}},
}

Metadata

Release files for ai-traineree 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ai-traineree 0.9.0
File Size Uploaded
ai_traineree-0.9.0.tar.gz 264.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ai-traineree 0.9.0
File Interpreter ABI Platform
ai_traineree-0.9.0-py3-none-any.whl Python 3 none any Details

Total release size: 373.3 kB

Release files / ai_traineree-0.9.0.tar.gz

Download URL ai_traineree-0.9.0.tar.gz
Size 264.6 kB
Tags Source
SHA-256 checksum
How to use checksums
d9c1fabbf39833450b21705e0146f53c2388d253e5f4a1910df41691b241b08f
BLAKE2b-256 checksum
How to use checksums
58a11e0dd046b63ae9a62af5d182086f206e8cf4df55c1ee937cd81faf5c61ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.5.13

Release files / ai_traineree-0.9.0-py3-none-any.whl

Download URL ai_traineree-0.9.0-py3-none-any.whl
Size 108.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
917569cc6f4d4385f957900455042b601409e163d37d7b36d6494bc556a6f89c
BLAKE2b-256 checksum
How to use checksums
b09573fbcbfa4012fcb318f7e7a70d64b222f18d0bad7ff98f043a060f5c9ace
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.5.13

Release history Release notifications | RSS feed

This release

0.9.0 This release

2 release files

0.7.1

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.0

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.0.14

2 release files

0.0.13

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page