Views
No views yet
1from stable_baselines3 import PPO
2from stable_baselines3.common.monitor import Monitor
3from huggingface_sb3 import load_from_hub
4
5repo_id = "potello/ppo-LunarLander-v2"
6filename = "ppo-LunarLander-v2.zip"
7
8custom_objects = {
9 "learning_rate": 0.0,
10 "lr_schedule": lambda _: 0.0,
11 "clip_range": lambda _: 0.0,
12}
13
14checkpoint = load_from_hub(repo_id, filename)
15model = PPO.load(checkpoint, custom_objects=custom_objects, print_system_info=True)
16
17eval_env = Monitor(gym.make("LunarLander-v2"))
18mean_reward, std_reward = evaluate_policy(model, eval_env, n_eval_episodes=10, deterministic=True)
19print(f"mean_reward={mean_reward:.2f} +/- {std_reward}")