Skip to main content

Pytorch version of Stable Baselines, implementations of reinforcement learning algorithms.

Project description

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.

Links

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)

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stable_baselines3-2.5.0a0.tar.gz (211.7 kB view details)

Uploaded Source

Built Distribution

stable_baselines3-2.5.0a0-py3-none-any.whl (183.7 kB view details)

Uploaded Python 3

File details

Details for the file stable_baselines3-2.5.0a0.tar.gz.

File metadata

  • Download URL: stable_baselines3-2.5.0a0.tar.gz
  • Upload date:
  • Size: 211.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.14

File hashes

Hashes for stable_baselines3-2.5.0a0.tar.gz
Algorithm Hash digest
SHA256 c2b8371c16c0ae62a1fd870c8c1bee7ba860657a46bcd00bb2d388ceda5ca014
MD5 7e1a404e7f23b66eb92e5e00cdac362f
BLAKE2b-256 e176beace09741c1a2bab5fdf9ac86f30e6635d16a856900ad0270ed56813cc5

See more details on using hashes here.

File details

Details for the file stable_baselines3-2.5.0a0-py3-none-any.whl.

File metadata

File hashes

Hashes for stable_baselines3-2.5.0a0-py3-none-any.whl
Algorithm Hash digest
SHA256 11dc925f57a361b1238236367e3d5e4a35e47cc3d37587be45b0d2bede0bee28
MD5 e6cac48676fdd3976f935d48754b894e
BLAKE2b-256 87ced6f16ca82055faa45c6986bc35bdb04a80c4e1dd1e23c8b6b719059107d0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page