Colored Action Noise for Deep RL
This repository contains easy-to-use implementations of pink noise and general colored noise for use as action noise in deep reinforcement learning. Included are the following classes:
ColoredNoiseProcessandPinkNoiseProcessfor general use, based on the colorednoise libraryColoredActionNoiseandPinkActionNoiseto be used with deterministic policy algorithms like DDPG and TD3 in Stable Baselines3, both are subclasses ofstable_baselines3.common.noise.ActionNoiseColoredNoiseDist,PinkNoiseDistto be used with stochastic policy algorithms like SAC in Stable Baselines3MPO_CNfor using colored noise (incl. pink noise) with MPO using the Tonic RL library.
For more information, please see our paper: Pink Noise Is All You Need: Colored Noise Exploration in Deep Reinforcement Learning (ICLR 2023 Spotlight).
Installation
You can install the library via pip:
pip install pink-noise-rl
Note: In Python, the import statement is simply import pink.
Usage
We provide minimal examples for using pink noise on SAC, TD3 and MPO below. An example comparing pink noise with the default action noise of SAC is included in the examples directory.
Stable Baselines3: SAC, TD3
import gym
from stable_baselines3 import SAC, TD3
# All classes mentioned above can be imported from `pink`
from pink import PinkNoiseDist, PinkActionNoise
# Initialize environment
env = gym.make("MountainCarContinuous-v0")
seq_len = env._max_episode_steps
action_dim = env.action_space.shape[-1]
SAC
# Initialize agent
model = SAC("MlpPolicy", env)
# Set action noise
model.actor.action_dist = PinkNoiseDist(seq_len, action_dim)
# Train agent
model.learn(total_timesteps=100_000)
TD3
# Initialize agent
model = TD3("MlpPolicy", env)
# Set action noise
noise_scale = 0.3
model.action_noise = PinkActionNoise(noise_scale, seq_len, action_dim)
# Train agent
model.learn(total_timesteps=100_000)
Tonic: MPO
import gym
from tonic import Trainer
from pink import MPO_CN
# Initialize environment
env = gym.make("MountainCarContinuous-v0")
seq_len = env._max_episode_steps
# Initialize agent with pink noise
beta = 1
model = MPO_CN()
model.initialize(beta, seq_len, env.observation_space, env.action_space)
# Train agent
trainer = tonic.Trainer(steps=100_000)
trainer.initialize(model, env)
trainer.run()
Citing
If you use this code in your research, please cite our paper:
@inproceedings{eberhard-2023-pink,
title = {Pink Noise Is All You Need: Colored Noise Exploration in Deep Reinforcement Learning},
author = {Eberhard, Onno and Hollenstein, Jakob and Pinneri, Cristina and Martius, Georg},
booktitle = {Proceedings of the Eleventh International Conference on Learning Representations (ICLR 2023)},
month = may,
year = {2023},
url = {https://openreview.net/forum?id=hQ9V5QN27eS}
}
If there are any problems, or if you have a question, don't hesitate to open an issue here on GitHub.
Metadata
Release files for pink-noise-rl 2.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pink_noise_rl-2.0.1.tar.gz | 8.9 kB | Without provenance | Details for pink_noise_rl-2.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pink_noise_rl-2.0.1-py3-none-any.whl | Python 3 | none | any | Details for pink_noise_rl-2.0.1-py3-none-any.whl |
Total release size: 17.9 kB
Release files / pink_noise_rl-2.0.1.tar.gz
| Download URL | pink_noise_rl-2.0.1.tar.gz |
|---|---|
| Size | 8.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
50e3ffa2c35e21777f955b61fa9ed96843cf3c76f7ecf8298e7801a07b5cd9dd
|
|
BLAKE2b-256 checksum How to use checksums |
4dcbdc3ed54c7938bdf95f84e3b68e13e7297d6c80e071144f9d77132bfcb1f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.2 CPython/3.11.0 Darwin/22.1.0
|
Release files / pink_noise_rl-2.0.1-py3-none-any.whl
| Download URL | pink_noise_rl-2.0.1-py3-none-any.whl |
|---|---|
| Size | 9.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
15b70e61f4670112769226d08512ccae0bdc1eaa30638b8c4f1ef66176f5ef32
|
|
BLAKE2b-256 checksum How to use checksums |
e932153022cf4374b4bb523d86fd9c9a398555f59cd49b8ca53d16d71e1c5d0c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.2 CPython/3.11.0 Darwin/22.1.0
|
Security for pink-noise-rl 2.0.1
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.