Skip to main content

WARNING: This package is in maintenance mode, please use Stable-Baselines3 (SB3) for an up-to-date version. You can find a migration guide in SB3 documentation.

Build Status Documentation Status Codacy Badge Codacy Badge

Stable Baselines

Stable Baselines is a set of improved implementations of reinforcement learning algorithms based on OpenAI Baselines.

These algorithms will make it easier for the research community and industry to replicate, refine, and identify new ideas, and will create good baselines to build projects on top of. We expect these tools will be used as a base around which new ideas can be added, and as a tool for comparing a new approach against existing ones. We also hope that the simplicity of these tools will allow beginners to experiment with a more advanced toolset, without being buried in implementation details.

Main differences with OpenAI Baselines

This toolset is a fork of OpenAI Baselines, with a major structural refactoring, and code cleanups:

  • Unified structure for all algorithms
  • PEP8 compliant (unified code style)
  • Documented functions and classes
  • More tests & more code coverage
  • Additional algorithms: SAC and TD3 (+ HER support for DQN, DDPG, SAC and TD3)

Links

Repository: https://github.com/hill-a/stable-baselines

Medium article: https://medium.com/@araffin/df87c4b2fc82

Documentation: https://stable-baselines.readthedocs.io/en/master/

RL Baselines Zoo: https://github.com/araffin/rl-baselines-zoo

Quick example

Most of the library tries to follow a sklearn-like syntax for the Reinforcement Learning algorithms using Gym.

Here is a quick example of how to train and run PPO2 on a cartpole environment:

import gym

from stable_baselines.common.policies import MlpPolicy
from stable_baselines.common.vec_env import DummyVecEnv
from stable_baselines import PPO2

env = gym.make('CartPole-v1')
# Optional: PPO2 requires a vectorized environment to run
# the env is now wrapped automatically when passing it to the constructor
# env = DummyVecEnv([lambda: env])

model = PPO2(MlpPolicy, env, verbose=1)
model.learn(total_timesteps=10000)

obs = env.reset()
for i in range(1000):
    action, _states = model.predict(obs)
    obs, rewards, dones, info = env.step(action)
    env.render()

Or just train a model with a one liner if the environment is registered in Gym and if the policy is registered:

from stable_baselines import PPO2

model = PPO2('MlpPolicy', 'CartPole-v1').learn(10000)

Metadata

Release files for stable-baselines 2.10.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stable-baselines 2.10.2
File Size Uploaded
stable_baselines-2.10.2.tar.gz 199.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for stable-baselines 2.10.2
File Interpreter ABI Platform
stable_baselines-2.10.2-py3-none-any.whl Python 3 none any Details

Total release size: 440.5 kB

Release files / stable_baselines-2.10.2.tar.gz

Download URL stable_baselines-2.10.2.tar.gz
Size 199.6 kB
Tags Source
SHA-256 checksum
How to use checksums
82491c8028edd5ae17186b8c8b3963368b45a37c9a0a00841ce26990b381f556
BLAKE2b-256 checksum
How to use checksums
bae5b59ee753d93632fd28d15acaf5043e8cd1d14385191f0ab843f277c00a5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.10

Release files / stable_baselines-2.10.2-py3-none-any.whl

Download URL stable_baselines-2.10.2-py3-none-any.whl
Size 240.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
59d7657723e73be15f4f3eacf957ffb4954cec03d1a9ee6c3a452bd1b1273191
BLAKE2b-256 checksum
How to use checksums
a2c5a60adb848f86219d19dd2d2bc4223b80e8d42802cc9e816955b6cfeffbdb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.10
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