d3rlpy

An offline deep reinforcement learning library

https://github.com/takuseno/d3rlpy

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 1 DOI reference(s) in README
  • Academic publication links
    Links to: arxiv.org, springer.com, nature.com
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (17.5%) to scientific vocabulary

Keywords

deep-learning deep-reinforcement-learning offline-rl pytorch

Keywords from Contributors

cryptocurrency cryptography jax transformer
Last synced: 6 months ago · JSON representation ·

Repository

An offline deep reinforcement learning library

Basic Info
Statistics
  • Stars: 1,534
  • Watchers: 25
  • Forks: 256
  • Open Issues: 55
  • Releases: 34
Topics
deep-learning deep-reinforcement-learning offline-rl pytorch
Created almost 6 years ago · Last pushed 9 months ago
Metadata Files
Readme Contributing License Code of conduct Citation Roadmap

README.md

d3rlpy: An offline deep reinforcement learning library

test Documentation Status codecov Maintainability MIT

d3rlpy is an offline deep reinforcement learning library for practitioners and researchers.

```py import d3rlpy

dataset, env = d3rlpy.datasets.get_dataset("hopper-medium-v0")

prepare algorithm

sac = d3rlpy.algos.SACConfig(compile_graph=True).create(device="cuda:0")

train offline

sac.fit(dataset, n_steps=1000000)

train online

sac.fitonline(env, nsteps=1000000)

ready to control

actions = sac.predict(x) ```

  • Documentation: https://d3rlpy.readthedocs.io
  • Paper: https://arxiv.org/abs/2111.03788

[!IMPORTANT] v2.x.x introduces breaking changes. If you still stick to v1.x.x, please explicitly install previous versions (e.g. pip install d3rlpy==1.1.1).

Key features

:zap: Most Practical RL Library Ever

  • offline RL: d3rlpy supports state-of-the-art offline RL algorithms. Offline RL is extremely powerful when the online interaction is not feasible during training (e.g. robotics, medical).
  • online RL: d3rlpy also supports conventional state-of-the-art online training algorithms without any compromising, which means that you can solve any kinds of RL problems only with d3rlpy.

:beginner: User-friendly API

  • zero-knowledge of DL library: d3rlpy provides many state-of-the-art algorithms through intuitive APIs. You can become a RL engineer even without knowing how to use deep learning libraries.
  • extensive documentation: d3rlpy is fully documented and accompanied with tutorials and reproduction scripts of the original papers.

:rocket: Beyond State-of-the-art

  • distributional Q function: d3rlpy is the first library that supports distributional Q functions in the all algorithms. The distributional Q function is known as the very powerful method to achieve the state-of-the-performance.
  • data-prallel distributed training: d3rlpy is the first library that supports data-parallel distributed offline RL training, which allows you to scale up offline RL with multiple GPUs or nodes. See example.

Installation

d3rlpy supports Linux, macOS and Windows.

Dependencies

Installing d3rlpy package will install or upgrade the following packages to satisfy requirements: - torch>=2.5.0 - tqdm>=4.66.3 - gym>=0.26.0 - gymnasium==1.0.0 - click - colorama - dataclasses-json - h5py - structlog - typing-extensions - scikit-learn

PyPI (recommended)

PyPI version PyPI - Downloads $ pip install d3rlpy

Anaconda

Anaconda-Server Badge Anaconda-Server Badge $ conda install conda-forge/noarch::d3rlpy

Docker

Docker Pulls $ docker run -it --gpus all --name d3rlpy takuseno/d3rlpy:latest bash

Supported algorithms

| algorithm | discrete control | continuous control | |:-|:-:|:-:| | Behavior Cloning (supervised learning) | :whitecheckmark: | :whitecheckmark: | | Neural Fitted Q Iteration (NFQ) | :whitecheckmark: | :noentry: | | Deep Q-Network (DQN) | :whitecheckmark: | :noentry: | | Double DQN | :whitecheckmark: | :noentry: | | Deep Deterministic Policy Gradients (DDPG) | :noentry: | :whitecheckmark: | | Twin Delayed Deep Deterministic Policy Gradients (TD3) | :noentry: | :whitecheckmark: | | Soft Actor-Critic (SAC) | :whitecheckmark: | :whitecheckmark: | | Batch Constrained Q-learning (BCQ) | :whitecheckmark: | :whitecheckmark: | | Bootstrapping Error Accumulation Reduction (BEAR) | :noentry: | :whitecheckmark: | | Conservative Q-Learning (CQL) | :whitecheckmark: | :whitecheckmark: | | Advantage Weighted Actor-Critic (AWAC) | :noentry: | :whitecheckmark: | | Critic Reguralized Regression (CRR) | :noentry: | :whitecheckmark: | | Policy in Latent Action Space (PLAS) | :noentry: | :whitecheckmark: | | TD3+BC | :noentry: | :whitecheckmark: | | Policy Regularization with Dataset Constraint (PRDC) | :noentry: | :whitecheckmark: | | Implicit Q-Learning (IQL) | :noentry: | :whitecheckmark: | | Calibrated Q-Learning (Cal-QL) | :noentry: | :whitecheckmark: | | ReBRAC | :noentry: | :whitecheckmark: | | Decision Transformer | :whitecheckmark: | :whitecheckmark: | | Q-learning Decision Transformer (QDT) | :noentry: | :whitecheckmark: | | Transformer Actor-Critic with Regularization (TACR) | :noentry: | :whitecheckmark: | | Gato | :construction: | :construction: |

Supported Q functions

Benchmark results

d3rlpy is benchmarked to ensure the implementation quality. The benchmark scripts are available reproductions directory. The benchmark results are available d3rlpy-benchmarks repository.

Examples

MuJoCo

```py import d3rlpy

prepare dataset

dataset, env = d3rlpy.datasets.get_d4rl('hopper-medium-v0')

prepare algorithm

cql = d3rlpy.algos.CQLConfig(compile_graph=True).create(device='cuda:0')

train

cql.fit( dataset, n_steps=100000, evaluators={"environment": d3rlpy.metrics.EnvironmentEvaluator(env)}, ) ```

See more datasets at d4rl.

Atari 2600

```py import d3rlpy

prepare dataset (1% dataset)

dataset, env = d3rlpy.datasets.getataritransitions( 'breakout', fraction=0.01, num_stack=4, )

prepare algorithm

cql = d3rlpy.algos.DiscreteCQLConfig( observationscaler=d3rlpy.preprocessing.PixelObservationScaler(), rewardscaler=d3rlpy.preprocessing.ClipRewardScaler(-1.0, 1.0), compile_graph=True, ).create(device='cuda:0')

start training

cql.fit( dataset, n_steps=1000000, evaluators={"environment": d3rlpy.metrics.EnvironmentEvaluator(env, epsilon=0.001)}, ) ```

See more Atari datasets at d4rl-atari.

Online Training

```py import d3rlpy import gym

prepare environment

env = gym.make('Hopper-v3') eval_env = gym.make('Hopper-v3')

prepare algorithm

sac = d3rlpy.algos.SACConfig(compile_graph=True).create(device='cuda:0')

prepare replay buffer

buffer = d3rlpy.dataset.createfiforeplay_buffer(limit=1000000, env=env)

start training

sac.fitonline(env, buffer, nsteps=1000000, evalenv=evalenv) ```

Tutorials

Try cartpole examples on Google Colaboratory!

  • offline RL tutorial: Open In Colab
  • online RL tutorial: Open In Colab

More tutorial documentations are available here.

Contributions

Any kind of contribution to d3rlpy would be highly appreciated! Please check the contribution guide.

Community

| Channel | Link | |:-|:-| | Issues | GitHub Issues |

[!IMPORTANT] Please do NOT email to any contributors including the owner of this project to ask for technical support. Such emails will be ignored without replying to your message. Use GitHub Issues to report your problems.

Projects using d3rlpy

| Project | Description | |:-:|:-| | MINERVA | An out-of-the-box GUI tool for offline RL | | SCOPE-RL | An off-policy evaluation and selection library |

Roadmap

The roadmap to the future release is available in ROADMAP.md.

Citation

The paper is available here. @article{d3rlpy, author = {Takuma Seno and Michita Imai}, title = {d3rlpy: An Offline Deep Reinforcement Learning Library}, journal = {Journal of Machine Learning Research}, year = {2022}, volume = {23}, number = {315}, pages = {1--20}, url = {http://jmlr.org/papers/v23/22-0017.html} }

Acknowledgement

This work started as a part of Takuma Seno's Ph.D project at Keio University in 2020.

This work is supported by Information-technology Promotion Agency, Japan (IPA), Exploratory IT Human Resources Project (MITOU Program) in the fiscal year 2020.

Owner

  • Name: Takuma Seno
  • Login: takuseno
  • Kind: user
  • Location: Japan
  • Company: Sony AI

Machine learning engineer at Sony AI

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Seno"
  given-names: "Takuma"
title: "d3rlpy: An offline deep reinforcement learning library"
version: 1.1.1
date-released: 2022-11-26
url: "https://github.com/takuseno/d3rlpy"
preferred-citation:
  type: article
  authors:
  - family-names: "Seno"
    given-names: "Takuma"
  - family-names: "Imai"
    given-names: "Michita"
  journal: "Journal of Machine Learning Research"
  month: 11
  title: "d3rlpy: An Offline Deep Reinforcement Learning Library"
  year: 2022
  url: http://jmlr.org/papers/v23/22-0017.html
  volume: 23
  issue: 315
  start: 1
  end: 20

GitHub Events

Total
  • Create event: 8
  • Commit comment event: 1
  • Release event: 3
  • Issues event: 38
  • Watch event: 200
  • Delete event: 4
  • Issue comment event: 75
  • Push event: 82
  • Pull request review comment event: 2
  • Pull request review event: 7
  • Pull request event: 20
  • Fork event: 19
Last Year
  • Create event: 8
  • Commit comment event: 1
  • Release event: 3
  • Issues event: 38
  • Watch event: 200
  • Delete event: 4
  • Issue comment event: 75
  • Push event: 82
  • Pull request review comment event: 2
  • Pull request review event: 7
  • Pull request event: 20
  • Fork event: 19

Committers

Last synced: 10 months ago

All Time
  • Total Commits: 1,624
  • Total Committers: 23
  • Avg Commits per committer: 70.609
  • Development Distribution Score (DDS): 0.034
Past Year
  • Commits: 84
  • Committers: 4
  • Avg Commits per committer: 21.0
  • Development Distribution Score (DDS): 0.06
Top Committers
Name Email Commits
takuseno t****o@g****m 1,568
ja.martin.h@repsol.com j****h@r****m 24
Joshua Spear 5****r 3
asmith26 a****6 3
hasan-yaman h****n@g****m 3
pstansell p****l@g****m 3
Antonin RAFFIN a****n@e****g 2
Haruka Kiyohara 5****a 2
Navid Madani n****4@g****m 2
Claudius Kienle p****t@c****e 1
Emrul e****l@e****m 1
Hassam Ullah Sheikh h****1@g****m 1
Juan Luis Cano Rodríguez h****o@j****e 1
Kazuki Otao k****o@g****m 1
LucMc 6****c 1
Mohan Zhang M****u 1
Qiushi Pan 1****n 1
Shubhanshu Khatana 8****z 1
Yi-Chen Li y****X@g****m 1
Zhengbang Zhu z****z@g****m 1
graham g****t@g****m 1
takuyamagata 3****a 1
tominku t****u@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 232
  • Total pull requests: 50
  • Average time to close issues: about 2 months
  • Average time to close pull requests: 21 days
  • Total issue authors: 137
  • Total pull request authors: 23
  • Average comments per issue: 3.12
  • Average comments per pull request: 2.26
  • Merged pull requests: 31
  • Bot issues: 0
  • Bot pull requests: 2
Past Year
  • Issues: 27
  • Pull requests: 20
  • Average time to close issues: 7 days
  • Average time to close pull requests: 1 day
  • Issue authors: 20
  • Pull request authors: 5
  • Average comments per issue: 1.67
  • Average comments per pull request: 2.1
  • Merged pull requests: 14
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • jdesman1 (8)
  • Zebin-Li (7)
  • joshuaspear (6)
  • jamartinh (6)
  • ajam74001 (6)
  • XiudingCai (6)
  • lettersfromfelix (4)
  • wenxuhaskell (4)
  • foxAB777 (4)
  • Mamba413 (4)
  • Lucien-Evans-123 (4)
  • 8JasonStatham8 (3)
  • lk1983823 (3)
  • kostas-maersk (3)
  • paulhilders (3)
Pull Request Authors
  • takuseno (12)
  • hasan-yaman (9)
  • joshuaspear (6)
  • takuyamagata (4)
  • asmith26 (4)
  • HateBunnyPlzzz (3)
  • Mamba413 (2)
  • opz (2)
  • qqpann (2)
  • liyc-ai (2)
  • claudius-kienle (2)
  • pstansell (1)
  • dependabot[bot] (1)
  • jamartinh (1)
  • tominku (1)
Top Labels
Issue Labels
bug (108) enhancement (69) question (1)
Pull Request Labels
dependencies (1)

Dependencies

.github/workflows/format_check.yml actions
  • actions/cache v1 composite
  • actions/checkout v2 composite
  • actions/setup-python v1 composite
.github/workflows/test.yml actions
  • actions/cache v1 composite
  • actions/checkout v2 composite
  • actions/setup-python v1 composite
docker/Dockerfile docker
  • pytorch/pytorch 1.9.0-cuda11.1-cudnn8-devel build
docs/requirements.txt pypi
  • Cython ==0.29.21
  • Sphinx ==4.0.2
  • numpy *
  • sphinx-rtd-theme ==0.5.0
  • stable-baselines3 >=0.10.0
requirements.txt pypi
  • Cython ==0.29.21
  • click ==8.0.1
  • colorama ==0.4.4
  • gym ==0.17.2
  • h5py ==2.10.0
  • scikit-learn ==0.23.1
  • scipy ==1.5.4
  • stable-baselines3 >=0.10.0
  • structlog ==20.2.0
  • tensorboardX ==2.0
  • torch ==1.6.0
  • tqdm ==4.47.0
  • typing-extensions ==3.7.4.3
setup.py pypi
  • click *
  • colorama *
  • gym *
  • h5py *
  • scikit-learn *
  • scipy *
  • structlog *
  • tensorboardX *
  • torch *
  • tqdm *
  • typing-extensions *
dev.requirements.txt pypi
  • black * development
  • docformatter * development
  • gymnasium_robotics * development
  • isort * development
  • matplotlib * development
  • minari ==0.4.2 development
  • mypy * development
  • onnx * development
  • onnxruntime * development
  • pylint ==2.13.5 development
  • pytest * development
  • pytest-cov * development
  • tensorboardX * development