Update README.md
Browse files
README.md
CHANGED
@@ -30,8 +30,34 @@ TODO: Add your code
|
|
30 |
|
31 |
|
32 |
```python
|
33 |
-
|
|
|
34 |
from huggingface_sb3 import load_from_hub
|
|
|
|
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
...
|
37 |
```
|
|
|
30 |
|
31 |
|
32 |
```python
|
33 |
+
import gymnasium as gym
|
34 |
+
from stable_baselines3 import PPO
|
35 |
from huggingface_sb3 import load_from_hub
|
36 |
+
from stable_baselines3.common.monitor import Monitor
|
37 |
+
from stable_baselines3.common.evaluation import evaluate_policy
|
38 |
|
39 |
+
repo_id = "Cesoft/ppo-LunarLander-v2"
|
40 |
+
filename = "ppo-LunarLander-v2.zip"
|
41 |
+
|
42 |
+
custom_objects = {
|
43 |
+
"learning_rate": 0.0,
|
44 |
+
"lr_schedule": lambda _: 0.0,
|
45 |
+
"clip_range": lambda _: 0.0,
|
46 |
+
}
|
47 |
+
|
48 |
+
checkpoint = load_from_hub(repo_id, filename)
|
49 |
+
model = PPO.load(checkpoint, custom_objects=custom_objects, print_system_info=True)
|
50 |
+
|
51 |
+
eval_env = Monitor(gym.make("LunarLander-v2", render_mode="human"))
|
52 |
+
|
53 |
+
mean_reward, std_reward = evaluate_policy(
|
54 |
+
model,
|
55 |
+
eval_env,
|
56 |
+
n_eval_episodes=EVAL_EPISODES,
|
57 |
+
deterministic=True,
|
58 |
+
render=True
|
59 |
+
)
|
60 |
+
eval_env.close()
|
61 |
+
print(f"mean_reward={mean_reward:.2f} +/- {std_reward} = {mean_reward - std_reward}")
|
62 |
...
|
63 |
```
|