Update README.md
Browse files
README.md
CHANGED
|
@@ -26,12 +26,25 @@ This is a trained model of a **A2C** agent playing **AntBulletEnv-v0**
|
|
| 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 |
-
|
|
|
|
|
|
|
| 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 |
|
| 31 |
```python
|
| 32 |
+
import gym
|
| 33 |
+
|
| 34 |
+
from stable_baselines3 import A2C
|
| 35 |
from huggingface_sb3 import load_from_hub
|
| 36 |
|
| 37 |
+
checkpoint = load_from_hub(
|
| 38 |
+
repo_id="AntBulletEnv-v0",
|
| 39 |
+
filename="a2c-AntBulletEnv-v0.zip",
|
| 40 |
+
)
|
| 41 |
+
model = A2C.load(checkpoint)
|
| 42 |
+
|
| 43 |
+
# Evaluate the agent and watch it
|
| 44 |
+
eval_env = gym.make("AntBulletEnv-v0")
|
| 45 |
+
mean_reward, std_reward = evaluate_policy(
|
| 46 |
+
model, eval_env, render=True, n_eval_episodes=5, deterministic=True, warn=False
|
| 47 |
+
)
|
| 48 |
+
print(f"mean_reward={mean_reward:.2f} +/- {std_reward}")
|
| 49 |
+
|
| 50 |
```
|