Skip to main content

An offline deep reinforcement learning library

Project description

d3rlpy: An offline deep reinforcement learning library

test build Documentation Status codecov Maintainability Gitter MIT

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

import d3rlpy

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

# prepare algorithm
sac = d3rlpy.algos.SAC()

# train offline
sac.fit(dataset, n_steps=1000000)

# train online
sac.fit_online(env, n_steps=1000000)

# ready to control
actions = sac.predict(x)

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.
  • advanced engineering: d3rlpy is designed to implement the faster and efficient training algorithms. For example, you can train Atari environments with x4 less memory space and as fast as the fastest RL library.

: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.
  • many tweek options: d3rlpy is also the first to support N-step TD backup and ensemble value functions in the all algorithms, which lead you to the place no one ever reached yet.

installation

d3rlpy supports Linux, macOS and Windows.

PyPI (recommended)

PyPI version PyPI - Downloads

$ pip install d3rlpy

Anaconda

Anaconda-Server Badge Anaconda-Server Badge Anaconda-Server Badge

$ conda install -c conda-forge d3rlpy

Docker

Docker Pulls

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

supported algorithms

algorithm discrete control continuous control offline RL?
Behavior Cloning (supervised learning) :white_check_mark: :white_check_mark:
Neural Fitted Q Iteration (NFQ) :white_check_mark: :no_entry: :white_check_mark:
Deep Q-Network (DQN) :white_check_mark: :no_entry:
Double DQN :white_check_mark: :no_entry:
Deep Deterministic Policy Gradients (DDPG) :no_entry: :white_check_mark:
Twin Delayed Deep Deterministic Policy Gradients (TD3) :no_entry: :white_check_mark:
Soft Actor-Critic (SAC) :white_check_mark: :white_check_mark:
Batch Constrained Q-learning (BCQ) :white_check_mark: :white_check_mark: :white_check_mark:
Bootstrapping Error Accumulation Reduction (BEAR) :no_entry: :white_check_mark: :white_check_mark:
Conservative Q-Learning (CQL) :white_check_mark: :white_check_mark: :white_check_mark:
Advantage Weighted Actor-Critic (AWAC) :no_entry: :white_check_mark: :white_check_mark:
Critic Reguralized Regression (CRR) :no_entry: :white_check_mark: :white_check_mark:
Policy in Latent Action Space (PLAS) :no_entry: :white_check_mark: :white_check_mark:
TD3+BC :no_entry: :white_check_mark: :white_check_mark:
Implicit Q-Learning (IQL) :no_entry: :white_check_mark: :white_check_mark:

supported Q functions

experimental features

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

import d3rlpy

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

# prepare algorithm
cql = d3rlpy.algos.CQL(use_gpu=True)

# train
cql.fit(
    dataset,
    eval_episodes=dataset,
    n_epochs=100,
    scorers={
        'environment': d3rlpy.metrics.evaluate_on_environment(env),
        'td_error': d3rlpy.metrics.td_error_scorer,
    },
)

See more datasets at d4rl.

Atari 2600

import d3rlpy
from sklearn.model_selection import train_test_split

# prepare dataset
dataset, env = d3rlpy.datasets.get_atari('breakout-expert-v0')

# split dataset
train_episodes, test_episodes = train_test_split(dataset, test_size=0.1)

# prepare algorithm
cql = d3rlpy.algos.DiscreteCQL(
    n_frames=4,
    q_func_factory='qr',
    scaler='pixel',
    use_gpu=True,
)

# start training
cql.fit(
    train_episodes,
    eval_episodes=test_episodes,
    n_epochs=100,
    scorers={
        'environment': d3rlpy.metrics.evaluate_on_environment(env),
        'td_error': d3rlpy.metrics.td_error_scorer,
    },
)

See more Atari datasets at d4rl-atari.

Online Training

import d3rlpy
import gym

# prepare environment
env = gym.make('HopperBulletEnv-v0')
eval_env = gym.make('HopperBulletEnv-v0')

# prepare algorithm
sac = d3rlpy.algos.SAC(use_gpu=True)

# prepare replay buffer
buffer = d3rlpy.online.buffers.ReplayBuffer(maxlen=1000000, env=env)

# start training
sac.fit_online(env, buffer, n_steps=1000000, eval_env=eval_env)

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.

The release planning can be checked at milestones.

community

Channel Link
Chat Gitter
Issues GitHub Issues

family projects

Project Description
d4rl-pybullet An offline RL datasets of PyBullet tasks
d4rl-atari A d4rl-style library of Google's Atari 2600 datasets
MINERVA An out-of-the-box GUI tool for offline RL

roadmap

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

citation

The paper is available here.

@InProceedings{seno2021d3rlpy,
  author = {Takuma Seno, Michita Imai},
  title = {d3rlpy: An Offline Deep Reinforcement Library},
  booktitle = {NeurIPS 2021 Offline Reinforcement Learning Workshop},
  month = {December},
  year = {2021}
}

acknowledgement

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

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

d3rlpy-1.1.1.tar.gz (317.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

d3rlpy-1.1.1-cp39-cp39-win_amd64.whl (341.8 kB view details)

Uploaded CPython 3.9Windows x86-64

d3rlpy-1.1.1-cp39-cp39-manylinux1_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.9

d3rlpy-1.1.1-cp39-cp39-macosx_10_15_x86_64.whl (381.0 kB view details)

Uploaded CPython 3.9macOS 10.15+ x86-64

d3rlpy-1.1.1-cp38-cp38-win_amd64.whl (342.8 kB view details)

Uploaded CPython 3.8Windows x86-64

d3rlpy-1.1.1-cp38-cp38-manylinux1_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.8

d3rlpy-1.1.1-cp38-cp38-macosx_10_15_x86_64.whl (378.7 kB view details)

Uploaded CPython 3.8macOS 10.15+ x86-64

d3rlpy-1.1.1-cp37-cp37m-win_amd64.whl (336.0 kB view details)

Uploaded CPython 3.7mWindows x86-64

d3rlpy-1.1.1-cp37-cp37m-manylinux1_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.7m

d3rlpy-1.1.1-cp37-cp37m-macosx_10_15_x86_64.whl (376.2 kB view details)

Uploaded CPython 3.7mmacOS 10.15+ x86-64

File details

Details for the file d3rlpy-1.1.1.tar.gz.

File metadata

  • Download URL: d3rlpy-1.1.1.tar.gz
  • Upload date:
  • Size: 317.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.5

File hashes

Hashes for d3rlpy-1.1.1.tar.gz
Algorithm Hash digest
SHA256 7970c2c67320e0e619bc851d072f59b949ec4c5b2a8c0d82b83790d96bccd882
MD5 cbf11d8eba7b0b00251a129fcaa90894
BLAKE2b-256 3b0cbba8b546426819a2c297ddd9f2268b5f156180057e8db4a6b66eafa78e9b

See more details on using hashes here.

File details

Details for the file d3rlpy-1.1.1-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: d3rlpy-1.1.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 341.8 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.5

File hashes

Hashes for d3rlpy-1.1.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 49d79f92bfc24ae79b00caf6f8c540e70db940aa2d7ac661c1aa91230df09f08
MD5 ae088bb543e4a9157b4040b5391cf2a0
BLAKE2b-256 56614f6e7963ed122f82cb7b36a603495c8adfcebc39aafecf2db8059b7a5e2c

See more details on using hashes here.

File details

Details for the file d3rlpy-1.1.1-cp39-cp39-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for d3rlpy-1.1.1-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 77c4b6b964d90908fb5e3e9bc44d498c6fbc5ec3aed48bd0625056e98045ce1b
MD5 1d7b11acf94a434f67d5a909d6ca4a31
BLAKE2b-256 f4c3acb384e533ede66c40658f9284f356d2b3f2fadadff4e71987dbcab7e1b7

See more details on using hashes here.

File details

Details for the file d3rlpy-1.1.1-cp39-cp39-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for d3rlpy-1.1.1-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 582a5b876d0ded02c007c674fb829930eec655223166b3f6ece69498ee6d36bc
MD5 d3122c15fd2cee058455bbb10fa0cf7d
BLAKE2b-256 10090eed26a9acf22ad73b81c47a2465557c40037fdac5b1d6cd0056c570b3e1

See more details on using hashes here.

File details

Details for the file d3rlpy-1.1.1-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: d3rlpy-1.1.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 342.8 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.5

File hashes

Hashes for d3rlpy-1.1.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 0b2abc2c8f937f7316b0cb0cb4a207b76529452cdc81bd60de756b664234cd30
MD5 51d867f9a40d7b58499a9df45eadd3ae
BLAKE2b-256 a500acb92968f54671edbc52117077e77e5eec6cd93ca5a64056ce15b53375a5

See more details on using hashes here.

File details

Details for the file d3rlpy-1.1.1-cp38-cp38-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for d3rlpy-1.1.1-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 c710c91702214bb2e20e5ab287c2467781110e451329d4637a0ebebbde73b490
MD5 915adeb65d7e73c5cee4a994665e1a78
BLAKE2b-256 c6fbdbb4a3f7e3b9fa8831d459c353efcda74855cdc43adfa52a9025d9a59dca

See more details on using hashes here.

File details

Details for the file d3rlpy-1.1.1-cp38-cp38-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for d3rlpy-1.1.1-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 cda8feb66a7f39fa858dd17b3ca5ad841cc6fcd7ba0a0da27ed5db0524cc7435
MD5 02973ac56ca486ce2946c07323578941
BLAKE2b-256 77a6964d0fc65710f743017906139e51cf329bf8616e1110d02ca28de1931d51

See more details on using hashes here.

File details

Details for the file d3rlpy-1.1.1-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: d3rlpy-1.1.1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 336.0 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.5

File hashes

Hashes for d3rlpy-1.1.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 343aa5e36fbd3c0eed8f6f8f3438346d7583b68aae6a06ddd05a5839284fe3ef
MD5 cd5b3a4a863cb663b3cfff3d6781eeac
BLAKE2b-256 e7304b700254fcb67b0e39802ad5f8fabf9d8126f8e07fcdafae918496e5dbdc

See more details on using hashes here.

File details

Details for the file d3rlpy-1.1.1-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for d3rlpy-1.1.1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 902e7e3d7aca3bd9a9703ad5c96480fb1ef4d15c0209637b748441f65a9e4e55
MD5 c03f14fbb19fc3031e4b9ae887e2a9aa
BLAKE2b-256 cbfd42a6bc3822036c65b48bef98ba83a5f4321f5b79bbc0d4e96dc502e558a2

See more details on using hashes here.

File details

Details for the file d3rlpy-1.1.1-cp37-cp37m-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for d3rlpy-1.1.1-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 ca05c1798e86f50bdca1af4f0a5e1cf31c0cc123db8d1d306fb88e32accf53de
MD5 c95f393c41af146fdd85c8999df50a1a
BLAKE2b-256 060484adc0fa0f1463f04b1f7e873a1aceafd95dcc7ddb7810d651f6f2228986

See more details on using hashes here.

Supported by

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