mriusero commited on
Commit ·
16cf163
1
Parent(s): d90f6aa
update card
Browse files
README.md
CHANGED
|
@@ -26,12 +26,28 @@ This is a trained model of a **PPO** agent playing **LunarLander-v2**
|
|
| 26 |
using the [stable-baselines3 library](https://github.com/DLR-RM/stable-baselines3).
|
| 27 |
|
| 28 |
## Usage (with Stable-baselines3)
|
| 29 |
-
TODO: Add your code
|
| 30 |
-
|
| 31 |
|
| 32 |
```python
|
| 33 |
-
from stable_baselines3 import ...
|
| 34 |
from huggingface_sb3 import load_from_hub
|
| 35 |
|
| 36 |
-
..
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
```
|
|
|
|
| 26 |
using the [stable-baselines3 library](https://github.com/DLR-RM/stable-baselines3).
|
| 27 |
|
| 28 |
## Usage (with Stable-baselines3)
|
|
|
|
|
|
|
| 29 |
|
| 30 |
```python
|
|
|
|
| 31 |
from huggingface_sb3 import load_from_hub
|
| 32 |
|
| 33 |
+
from stable_baselines3.common.env_util import make_vec_env
|
| 34 |
+
from stable_baselines3 import PPO
|
| 35 |
+
from stable_baselines3.common.evaluation import evaluate_policy
|
| 36 |
+
|
| 37 |
+
model_checkpoint = load_from_hub( # Download model from the hub
|
| 38 |
+
repo_id="mriusero/ppo-LunarLander-v2",
|
| 39 |
+
filename="ppo-LunarLander-v2.zip",
|
| 40 |
+
)
|
| 41 |
+
env = make_vec_env("LunarLander-v2", n_envs=1) # Create a vectorized environment
|
| 42 |
+
model = PPO.load(model_checkpoint, env=env) # Load the model
|
| 43 |
+
|
| 44 |
+
print("Evaluating model") # Evaluate the model
|
| 45 |
+
mean_reward, std_reward = evaluate_policy(
|
| 46 |
+
model,
|
| 47 |
+
env,
|
| 48 |
+
n_eval_episodes=10,
|
| 49 |
+
deterministic=True,
|
| 50 |
+
)
|
| 51 |
+
print(f"Mean reward = {mean_reward:.2f} +/- {std_reward}")
|
| 52 |
+
|
| 53 |
```
|