Skip to main content

Stable Baselines3

Stable Baselines3 is a set of reliable implementations of reinforcement learning algorithms in PyTorch. It is the next major version of Stable 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.

Repository: https://github.com/DLR-RM/stable-baselines3

Blog post: https://araffin.github.io/post/sb3/

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

RL Baselines3 Zoo: https://github.com/DLR-RM/rl-baselines3-zoo

SB3 Contrib: https://github.com/Stable-Baselines-Team/stable-baselines3-contrib

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 PPO on a cartpole environment:

import gymnasium

from stable_baselines3 import PPO

env = gymnasium.make("CartPole-v1", render_mode="human")

model = PPO("MlpPolicy", env, verbose=1)
model.learn(total_timesteps=10_000)

vec_env = model.get_env()
obs = vec_env.reset()
for i in range(1000):
    action, _states = model.predict(obs, deterministic=True)
    obs, reward, done, info = vec_env.step(action)
    vec_env.render()
    # VecEnv resets automatically
    # if done:
    #   obs = vec_env.reset()

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

from stable_baselines3 import PPO

model = PPO("MlpPolicy", "CartPole-v1").learn(10_000)

Release files for stable-baselines3 2.3.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-baselines3 2.3.2
File Size Uploaded
stable_baselines3-2.3.2.tar.gz 209.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for stable-baselines3 2.3.2
File Interpreter ABI Platform
stable_baselines3-2.3.2-py3-none-any.whl Python 3 none any Details

Total release size: 392.1 kB

Release files / stable_baselines3-2.3.2.tar.gz

Download URL stable_baselines3-2.3.2.tar.gz
Size 209.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2f8188916e607571c4c24f88a9ff6f84edafb2cf22d5d24f9c199563c12ff168
BLAKE2b-256 checksum
How to use checksums
eabd8b6fd663cca67793c7a651b7929f987cee021e72a8d910e8851ea0b4d9c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.9

Release files / stable_baselines3-2.3.2-py3-none-any.whl

Download URL stable_baselines3-2.3.2-py3-none-any.whl
Size 182.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a1cafff6ec23bd4e8f4f20dd829008dc1af58ec2d5d8fc0cd0929b4b4544c9b2
BLAKE2b-256 checksum
How to use checksums
066ac3098a78a63b5a48e18c11d80b8c532f8b7785d6abb1329cfe3034572161
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.9

Release history Release notifications | RSS feed

2.9.0

2 release files

2.8.0

2 release files

2.7.1

2 release files

2.7.0

2 release files

2.6.0

2 release files

2.5.0

2 release files

2.4.1

2 release files

2.4.0

2 release files

This release

2.3.2 This release

2 release files

2.3.1

2 release files

2.3.0

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.8.0

2 release files

1.7.0

2 release files

1.6.2

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0

2 release files

0.11.1

2 release files

0.11.0

2 release files

0.10.0

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

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