Skip to main content

An easy-to-use reinforcement learning library for research and education

Project description

A Reinforcement Learning Library for Research and Education

pytest Documentation Status contributors Codacy codecov PyPI

Try it on Google Colab! Open In Colab


What is rlberry?

Writing reinforcement learning algorithms is fun! But after the fun, we have lots of boring things to implement: run our agents in parallel, average and plot results, optimize hyperparameters, compare to baselines, create tricky environments etc etc!

rlberry is a Python library that makes your life easier by doing all these things with a few lines of code, so that you can spend most of your time developing agents.

Check our documentation or our getting started section to see how!

Contents

Section Description
Getting started A quick usage guide of rlberry
Citation How to cite this work
Installation How to install rlberry
Contributing A guide for contributing

Getting started

We provide a handful of notebooks on Google colab as examples to show you how to use rlberry.

Content Description Link
Introduction to rlberry How to create an agent, optimize its hyperparameters and compare to a baseline. Open In Colab
RL Experimental Pipeline How to define a configuration, run experiments in parallel and save a config.json for reproducibility. Open In Colab

Compatibility with OpenAI Gym

If you want to use gym environments with rlberry, simply do the following:

from rlberry.envs import gym_make

# for example, let's take CartPole
env = gym_make('CartPole-v1')

This way, env behaves exactly the same as the gym environment, we simply replace the seeding function by env.reseed(), which ensures unified seeding and reproducibility when using rlberry.

Seeding

In rlberry, only one global seed is defined, and all the random number generators used by the agents and environments inherit from this seed, ensuring reproducibility and independence between the generators (see NumPy SeedSequence).

Example:

import rlberry.seeding as seeding

seeding.set_global_seed(seed=123)

# From now on, no more seeds are defined by the user, and all the results are reproducible.
...

# If you need a random number generator (rng), call:
rng = seeding.get_rng()   

# which gives a numpy Generator (https://numpy.org/doc/stable/reference/random/generator.html) 
# that is independent of all the previous generators created by seeding.get_rng()
rng.integers(5)
rng.normal()
# etc

Citing rlberry

If you use rlberry in scientific publications, we would appreciate citations using the following Bibtex entry:

@misc{rlberry,
author = {Domingues, Omar Darwiche and ‪Flet-Berliac, Yannis and Leurent, Edouard and M{\'e}nard, Pierre and Shang, Xuedong and Valko, Michal},
title = {{rlberry - A Reinforcement Learning Library for Research and Education}},
year = {2021},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/rlberry-py/rlberry}},
}

Installation

Cloning & creating virtual environment

It is suggested to create a virtual environment using Anaconda or Miniconda:

git clone https://github.com/rlberry-py/rlberry.git
conda create -n rlberry python=3.7

Basic installation

Install without heavy libraries (e.g. pytorch):

conda activate rlberry
pip install -e .

Full installation

Install with all features:

conda activate rlberry
pip install -e .[full]

which includes:

  • Numba for just-in-time compilation of algorithms based on dynamic programming
  • PyTorch for Deep RL agents
  • Optuna for hyperparameter optimization
  • ffmpeg-python for saving videos
  • PyOpenGL for more rendering options

Tests

To run tests, install test dependencies with pip install -e .[test] and run pytest. To run tests with coverage, install test dependencies and run bash run_testscov.sh. See coverage report in cov_html/index.html.

Contributing

Want to contribute to rlberry? Please check our contribution guidelines. A list of interesting TODO's will be available soon. If you want to add any new agents or environments, do not hesitate to open an issue!

Implementation notes

  • When inheriting from the Agent class, make sure to call Agent.__init__(self, env, **kwargs) using **kwargs in case new features are added to the base class, and to make sure that copy_env and reseed_env are always an option to any agent.

Infos, errors and warnings are printed using the logging library.

  • From gym to rlberry:
    • reseed (rlberry) should be called instead of seed (gym). seed keeps compatilibity with gym, whereas reseed uses the unified seeding mechanism of rlberry.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rlberry-0.0.3.tar.gz (122.1 kB view details)

Uploaded Source

Built Distribution

rlberry-0.0.3-py3-none-any.whl (167.4 kB view details)

Uploaded Python 3

File details

Details for the file rlberry-0.0.3.tar.gz.

File metadata

  • Download URL: rlberry-0.0.3.tar.gz
  • Upload date:
  • Size: 122.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.7.9

File hashes

Hashes for rlberry-0.0.3.tar.gz
Algorithm Hash digest
SHA256 0d3ca87fc58b6f33733df1d7ce1e529092f49d8ce90060a4a5679f3af81264ac
MD5 e1f6db07822f8aaea40d83a92ed8bb79
BLAKE2b-256 b3c55679b88caed502cd72f7921ed7037f9e781bd2488c2ac3971da2a65c071f

See more details on using hashes here.

Provenance

File details

Details for the file rlberry-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: rlberry-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 167.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.7.9

File hashes

Hashes for rlberry-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 203127ec87944fb874f861aac4e198eb34c751783a93f4f3869e4af3f6472e3d
MD5 362c9a77a87d35825dfe344b47ee22d1
BLAKE2b-256 d7ae09b2e918fa99e6904c361ebe9ab24ef7b83f25bd545cdefff7b7863701c4

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page