stable-baselines3


Namestable-baselines3 JSON
Version 2.3.2 PyPI version JSON
download
home_pagehttps://github.com/DLR-RM/stable-baselines3
SummaryPytorch version of Stable Baselines, implementations of reinforcement learning algorithms.
upload_time2024-04-27 13:09:14
maintainerNone
docs_urlNone
authorAntonin Raffin
requires_python>=3.8
licenseMIT
keywords reinforcement-learning-algorithms reinforcement-learning machine-learning gymnasium gym openai stable baselines toolbox python data-science
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            

# 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](https://github.com/hill-a/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:

```python
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](https://gymnasium.farama.org/tutorials/gymnasium_basics/environment_creation/) and if [the policy is registered](https://stable-baselines3.readthedocs.io/en/master/guide/custom_policy.html):

```python
from stable_baselines3 import PPO

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


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/DLR-RM/stable-baselines3",
    "name": "stable-baselines3",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "reinforcement-learning-algorithms reinforcement-learning machine-learning gymnasium gym openai stable baselines toolbox python data-science",
    "author": "Antonin Raffin",
    "author_email": "antonin.raffin@dlr.de",
    "download_url": "https://files.pythonhosted.org/packages/ea/bd/8b6fd663cca67793c7a651b7929f987cee021e72a8d910e8851ea0b4d9c2/stable_baselines3-2.3.2.tar.gz",
    "platform": null,
    "description": "\n\n# Stable Baselines3\n\nStable Baselines3 is a set of reliable implementations of reinforcement learning algorithms in PyTorch. It is the next major version of [Stable Baselines](https://github.com/hill-a/stable-baselines).\n\nThese 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.\n\n\n## Links\n\nRepository:\nhttps://github.com/DLR-RM/stable-baselines3\n\nBlog post:\nhttps://araffin.github.io/post/sb3/\n\nDocumentation:\nhttps://stable-baselines3.readthedocs.io/en/master/\n\nRL Baselines3 Zoo:\nhttps://github.com/DLR-RM/rl-baselines3-zoo\n\nSB3 Contrib:\nhttps://github.com/Stable-Baselines-Team/stable-baselines3-contrib\n\n## Quick example\n\nMost of the library tries to follow a sklearn-like syntax for the Reinforcement Learning algorithms using Gym.\n\nHere is a quick example of how to train and run PPO on a cartpole environment:\n\n```python\nimport gymnasium\n\nfrom stable_baselines3 import PPO\n\nenv = gymnasium.make(\"CartPole-v1\", render_mode=\"human\")\n\nmodel = PPO(\"MlpPolicy\", env, verbose=1)\nmodel.learn(total_timesteps=10_000)\n\nvec_env = model.get_env()\nobs = vec_env.reset()\nfor i in range(1000):\n    action, _states = model.predict(obs, deterministic=True)\n    obs, reward, done, info = vec_env.step(action)\n    vec_env.render()\n    # VecEnv resets automatically\n    # if done:\n    #   obs = vec_env.reset()\n\n```\n\nOr just train a model with a one liner if [the environment is registered in Gymnasium](https://gymnasium.farama.org/tutorials/gymnasium_basics/environment_creation/) and if [the policy is registered](https://stable-baselines3.readthedocs.io/en/master/guide/custom_policy.html):\n\n```python\nfrom stable_baselines3 import PPO\n\nmodel = PPO(\"MlpPolicy\", \"CartPole-v1\").learn(10_000)\n```\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Pytorch version of Stable Baselines, implementations of reinforcement learning algorithms.",
    "version": "2.3.2",
    "project_urls": {
        "Changelog": "https://stable-baselines3.readthedocs.io/en/master/misc/changelog.html",
        "Code": "https://github.com/DLR-RM/stable-baselines3",
        "Documentation": "https://stable-baselines3.readthedocs.io/",
        "Homepage": "https://github.com/DLR-RM/stable-baselines3",
        "RL-Zoo": "https://github.com/DLR-RM/rl-baselines3-zoo",
        "SB3-Contrib": "https://github.com/Stable-Baselines-Team/stable-baselines3-contrib",
        "SBX": "https://github.com/araffin/sbx"
    },
    "split_keywords": [
        "reinforcement-learning-algorithms",
        "reinforcement-learning",
        "machine-learning",
        "gymnasium",
        "gym",
        "openai",
        "stable",
        "baselines",
        "toolbox",
        "python",
        "data-science"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "066ac3098a78a63b5a48e18c11d80b8c532f8b7785d6abb1329cfe3034572161",
                "md5": "116eb07fa7b17abd2140f4d0c7917804",
                "sha256": "a1cafff6ec23bd4e8f4f20dd829008dc1af58ec2d5d8fc0cd0929b4b4544c9b2"
            },
            "downloads": -1,
            "filename": "stable_baselines3-2.3.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "116eb07fa7b17abd2140f4d0c7917804",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 182272,
            "upload_time": "2024-04-27T13:09:10",
            "upload_time_iso_8601": "2024-04-27T13:09:10.367368Z",
            "url": "https://files.pythonhosted.org/packages/06/6a/c3098a78a63b5a48e18c11d80b8c532f8b7785d6abb1329cfe3034572161/stable_baselines3-2.3.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "eabd8b6fd663cca67793c7a651b7929f987cee021e72a8d910e8851ea0b4d9c2",
                "md5": "e7d8ea2da32036dc04b36ad5b61c474b",
                "sha256": "2f8188916e607571c4c24f88a9ff6f84edafb2cf22d5d24f9c199563c12ff168"
            },
            "downloads": -1,
            "filename": "stable_baselines3-2.3.2.tar.gz",
            "has_sig": false,
            "md5_digest": "e7d8ea2da32036dc04b36ad5b61c474b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 209821,
            "upload_time": "2024-04-27T13:09:14",
            "upload_time_iso_8601": "2024-04-27T13:09:14.825720Z",
            "url": "https://files.pythonhosted.org/packages/ea/bd/8b6fd663cca67793c7a651b7929f987cee021e72a8d910e8851ea0b4d9c2/stable_baselines3-2.3.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-27 13:09:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "DLR-RM",
    "github_project": "stable-baselines3",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "stable-baselines3"
}
        
Elapsed time: 0.24658s