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: Easy-To-Use 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.
  • scikit-learn compatibility: d3rlpy is not only easy, but also completely compatible with scikit-learn API, which means that you can maximize your productivity with the useful scikit-learn's utilities.

: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:
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:
Advantage-Weighted Regression (AWR) :white_check_mark: :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.

PyBullet

import d3rlpy

# prepare dataset
dataset, env = d3rlpy.datasets.get_pybullet('hopper-bullet-mixed-v0')

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

# start training
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 PyBullet datasets at d4rl-pybullet.

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 a cartpole example on Google Colaboratory!

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

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.0.0.tar.gz (341.5 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.0.0-cp38-cp38-win_amd64.whl (370.0 kB view details)

Uploaded CPython 3.8Windows x86-64

d3rlpy-1.0.0-cp38-cp38-manylinux1_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.8

d3rlpy-1.0.0-cp38-cp38-macosx_10_14_x86_64.whl (413.6 kB view details)

Uploaded CPython 3.8macOS 10.14+ x86-64

d3rlpy-1.0.0-cp37-cp37m-win_amd64.whl (363.4 kB view details)

Uploaded CPython 3.7mWindows x86-64

d3rlpy-1.0.0-cp37-cp37m-manylinux1_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.7m

d3rlpy-1.0.0-cp37-cp37m-macosx_10_14_x86_64.whl (411.9 kB view details)

Uploaded CPython 3.7mmacOS 10.14+ x86-64

d3rlpy-1.0.0-cp36-cp36m-win_amd64.whl (363.4 kB view details)

Uploaded CPython 3.6mWindows x86-64

d3rlpy-1.0.0-cp36-cp36m-manylinux1_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.6m

d3rlpy-1.0.0-cp36-cp36m-macosx_10_14_x86_64.whl (411.7 kB view details)

Uploaded CPython 3.6mmacOS 10.14+ x86-64

File details

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

File metadata

  • Download URL: d3rlpy-1.0.0.tar.gz
  • Upload date:
  • Size: 341.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for d3rlpy-1.0.0.tar.gz
Algorithm Hash digest
SHA256 bed1ee5b9e74f8373d186df281e19fc2e1fb33291a8999a2cc89c40a2a2d9491
MD5 e56a579cb6204319236c092ccafe81fd
BLAKE2b-256 85aa4ae664b50c87c7d31769059f39fdd75e0106159ba939b47cbc933ce3ac4b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: d3rlpy-1.0.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 370.0 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for d3rlpy-1.0.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 8ba0dca5ed4b0a97aff6c0db0dfc583a21f1be965e2f18745df30c84bcfb513f
MD5 fdfc258b7244c3d0de5d7cd08525a8cf
BLAKE2b-256 0efd0420524a9eef3c9f78f23510300a46791ca2a0ccec56bb27a134b3bdc400

See more details on using hashes here.

File details

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

File metadata

  • Download URL: d3rlpy-1.0.0-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for d3rlpy-1.0.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 e8d6d6e9eb44516e71b714d59c443812d8afe3abe964bc7885ea83c768fb15f2
MD5 00eb40ff2935bf49bb39a6b3ebe25bf3
BLAKE2b-256 26bc4eac06767eec5056c3785a69eb8b0f68c4559a870c89f3625927b6beee11

See more details on using hashes here.

File details

Details for the file d3rlpy-1.0.0-cp38-cp38-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: d3rlpy-1.0.0-cp38-cp38-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 413.6 kB
  • Tags: CPython 3.8, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for d3rlpy-1.0.0-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 acde920ec89d85d631dcac2d0a44b2705a382a1154b738cc8c92d5ba13ed4617
MD5 ea30bf8bbf7d4dd2a31785f38f101201
BLAKE2b-256 eb5956c5c207f2bed5256cafd2c5c3cf5e987352086ab9ac5cd96ab8e01b6931

See more details on using hashes here.

File details

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

File metadata

  • Download URL: d3rlpy-1.0.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 363.4 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for d3rlpy-1.0.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 112e38388bc948dc545597a0af63d533af29e20505d2c9211a8b7d333e02b364
MD5 8dd2e98806e1612fa2ba0893a6f4987b
BLAKE2b-256 5fea9da33615aa0d9337af970387195b196e65dfcf3e63a1ae83ee364d9333f9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: d3rlpy-1.0.0-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for d3rlpy-1.0.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 fa5548cec8748ba633811f3b377ab2fab27f2fbb27cadd41658b711113c53a9f
MD5 a0c4e513cdb44e1f3abba7326c283ee8
BLAKE2b-256 ee5c4958665c1d7eeac5aafa9c87ef9e25abd178054e736a32740f7b9de12936

See more details on using hashes here.

File details

Details for the file d3rlpy-1.0.0-cp37-cp37m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: d3rlpy-1.0.0-cp37-cp37m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 411.9 kB
  • Tags: CPython 3.7m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for d3rlpy-1.0.0-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 543a835dd58b7f0cac2f64208d386eb1273a6590bb3ae4c2f1137abaa259ab2d
MD5 52e74750e4b06854196d691dbae468b1
BLAKE2b-256 133f551889f7de5efc0c0da56c31d0d86350df97c9a38da0dca1ebf0b234bc26

See more details on using hashes here.

File details

Details for the file d3rlpy-1.0.0-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: d3rlpy-1.0.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 363.4 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for d3rlpy-1.0.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 7eab5dfa365c8624a4a0b6d18cdc43c595dcc9573e30a21faedf4695c14a2e5f
MD5 a4718871db8e7564bc6e88f8dd52f404
BLAKE2b-256 b295d24a3d2433b897ca5ad2d856f6ccd01e316cf727775bec3bb6890fa3e819

See more details on using hashes here.

File details

Details for the file d3rlpy-1.0.0-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: d3rlpy-1.0.0-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for d3rlpy-1.0.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 0c6c8844471f9dfaeed6a5602690d87f15293df6389e28275c0ba9612fc6087c
MD5 9eeaf0c9d6ce5325521ea4613e501984
BLAKE2b-256 2c38757a4e3cebcfd1c279181f59ddd766455dc01c706ee0685f99d7488f3af3

See more details on using hashes here.

File details

Details for the file d3rlpy-1.0.0-cp36-cp36m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: d3rlpy-1.0.0-cp36-cp36m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 411.7 kB
  • Tags: CPython 3.6m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for d3rlpy-1.0.0-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 a7b051abe9da701c8066bdc79ed49ec67c5f6da502b4c74771cbd442f65e0ca6
MD5 8c8256e4b19ad863b738ddff19b986a1
BLAKE2b-256 1af0e413370cfd292aebc1ccd686c329fe33d8f30ff16b15e1e36c30629b4cc6

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