Reinforcement Learning
stable-baselines3
Pendulum-v1
deep-reinforcement-learning
Eval Results (legacy)
Instructions to use sb3/ppo-Pendulum-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- stable-baselines3
How to use sb3/ppo-Pendulum-v1 with stable-baselines3:
from huggingface_sb3 import load_from_hub checkpoint = load_from_hub( repo_id="sb3/ppo-Pendulum-v1", filename="{MODEL FILENAME}.zip", ) - Notebooks
- Google Colab
- Kaggle
Antonin Raffin commited on
Commit ·
7ee9df9
1
Parent(s): 91234a1
Add code
Browse files
README.md
CHANGED
|
@@ -24,5 +24,27 @@ model-index:
|
|
| 24 |
This is a trained model of a **PPO** agent playing **Pendulum-v1** using the [stable-baselines3 library](https://github.com/DLR-RM/stable-baselines3).
|
| 25 |
|
| 26 |
## Usage (with Stable-baselines3)
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
|
|
|
| 24 |
This is a trained model of a **PPO** agent playing **Pendulum-v1** using the [stable-baselines3 library](https://github.com/DLR-RM/stable-baselines3).
|
| 25 |
|
| 26 |
## Usage (with Stable-baselines3)
|
| 27 |
+
```python
|
| 28 |
+
from stable_baselines3 import PPO
|
| 29 |
+
from stable_baselines3.common.env_util import make_vec_env
|
| 30 |
+
|
| 31 |
+
# Create the environment
|
| 32 |
+
env_id = "Pendulum-v1"
|
| 33 |
+
env = make_vec_env(env_id, n_envs=1)
|
| 34 |
+
|
| 35 |
+
# Instantiate the agent
|
| 36 |
+
model = PPO(
|
| 37 |
+
"MlpPolicy",
|
| 38 |
+
env,
|
| 39 |
+
gamma=0.98,
|
| 40 |
+
use_sde=True,
|
| 41 |
+
sde_sample_freq=4,
|
| 42 |
+
learning_rate=1e-3,
|
| 43 |
+
verbose=1,
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
# Train the agent
|
| 47 |
+
model.learn(total_timesteps=int(1e5))
|
| 48 |
+
|
| 49 |
+
```
|
| 50 |
|