Skip to main content

Rainy

Actions Status PyPI version Black

Reinforcement learning utilities and algrithm implementations using PyTorch.

Example

Rainy has a main decorator which converts a function that returns rainy.Config to a CLI app. All function arguments are re-interpreted as command line arguments.

import os

from torch.optim import RMSprop

import rainy
from rainy import Config, net
from rainy.agents import DQNAgent
from rainy.envs import Atari
from rainy.lib.explore import EpsGreedy, LinearCooler


@rainy.main(DQNAgent, script_path=os.path.realpath(__file__))
def main(
    envname: str = "Breakout",
    max_steps: int = int(2e7),
    replay_size: int = int(1e6),
    replay_batch_size: int = 32,
) -> Config:
    c = Config()
    c.set_env(lambda: Atari(envname))
    c.set_optimizer(
        lambda params: RMSprop(params, lr=0.00025, alpha=0.95, eps=0.01, centered=True)
    )
    c.set_explorer(lambda: EpsGreedy(1.0, LinearCooler(1.0, 0.1, int(1e6))))
    c.set_net_fn("dqn", net.value.dqn_conv())
    c.replay_size = replay_size
    c.replay_batch_size = replay_batch_size
    c.train_start = 50000
    c.sync_freq = 10000
    c.max_steps = max_steps
    c.eval_env = Atari(envname)
    c.eval_freq = None
    return c


if __name__ == "__main__":
    main()

Then you can use this script like

python dqn.py --replay-batch-size=64 train --eval-render

See examples directory for more.

API documentation

COMING SOON

Supported python version

Python >= 3.6.1

Implementation Status

Algorithm Multi Worker(Sync) Recurrent Discrete Action Continuous Action MPI support
DQN/Double DQN ✔️ ❌ ✔️ ❌ ❌
BootDQN/RPF ❌ ❌ ✔️ ❌ ❌
DDPG ✔️ ❌ ❌ ✔️ ❌
TD3 ✔️ ❌ ❌ ✔️ ❌
SAC ✔️ ❌ ❌ ✔️ ❌
PPO ✔️ ✔️ ✔️ ✔️ ✔️
A2C ✔️ 🔺(1) ✔️ ✔️ ❌
ACKTR ✔️ ❌(2) ✔️ ✔️ ❌
AOC ✔️ ❌ ✔️ ✔️ ❌
PPOC ✔️ ❌ ✔️ ✔️ ❌
ACTC(3) ✔️ ❌ ✔️ ✔️ ❌

(1): Very unstable
(2): Needs https://openreview.net/forum?id=HyMTkQZAb implemented
(3): Incomplete implementation. β is often too high.

Sub packages

References

DQN (Deep Q Network)

DDQN (Double DQN)

Bootstrapped DQN

RPF(Randomized Prior Functions)

DDPQ(Deep Deterministic Policy Gradient)

TD3(Twin Delayed Deep Deterministic Policy Gradient)

SAC(Soft Actor Critic)

A2C (Advantage Actor Critic)

ACKTR (Actor Critic using Kronecker-Factored Trust Region)

PPO (Proximal Policy Optimization)

AOC (Advantage Option Critic)

PPOC (Proximal Option Critic)

ACTC (Actor Critic Termination Critic)

Implementaions I referenced

Thank you!

https://github.com/openai/baselines

https://github.com/ikostrikov/pytorch-a2c-ppo-acktr

https://github.com/ShangtongZhang/DeepRL

https://github.com/chainer/chainerrl

https://github.com/Thrandis/EKFAC-pytorch (for ACKTR)

https://github.com/jeanharb/a2oc_delib (for AOC)

https://github.com/mklissa/PPOC (for PPOC)

https://github.com/sfujim/TD3 (for DDPG and TD3)

https://github.com/vitchyr/rlkit (for SAC)

License

This project is licensed under Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0).

Metadata

Release files for rainy 0.8.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 rainy 0.8.0
File Size Uploaded Provenance Actions
rainy-0.8.0.tar.gz 70.7 kB Without provenance Details for rainy-0.8.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rainy 0.8.0
File Interpreter ABI Platform Actions
rainy-0.8.0-py3-none-any.whl Python 3 none any Details for rainy-0.8.0-py3-none-any.whl

Total release size: 188.1 kB

Release files / rainy-0.8.0.tar.gz

Download URL rainy-0.8.0.tar.gz
Size 70.7 kB
Tags Source
SHA-256 checksum
How to use checksums
6d5308b6159fc82bfa13cb908d1fd5fba8cb1b581bd112ca8add46296247b5d7
BLAKE2b-256 checksum
How to use checksums
5ec4c018d587a92fc71ba03cc2fcf883c24d54d12d35c33d314c059b1ccf7003
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

Release files / rainy-0.8.0-py3-none-any.whl

Download URL rainy-0.8.0-py3-none-any.whl
Size 117.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
75ed8cd07dc334580892e3446b82b28c6c99e07a3fd8f326d549c03a1b42da6f
BLAKE2b-256 checksum
How to use checksums
839c32639a4a9f39bc70dcb7b633b957e8eca01aef6d273ef47f56c9a4961658
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

Security for rainy 0.8.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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