Views
No views yet
1import gymnasium as gym
2
3from huggingface_sb3 import load_from_hub
4from stable_baselines3 import PPO
5from stable_baselines3.common.evaluation import evaluate_policy
6
7# Retrieve the model from the hub
8checkpoint = load_from_hub(
9 repo_id="ash-171/ppo-LunarLander-v3",
10 filename="ppo-LunarLander-v3.zip",
11)
12model = PPO.load(checkpoint)
13
14# Evaluate the agent and watch it
15eval_env = gym.make("LunarLander-v3")
16mean_reward, std_reward = evaluate_policy(
17 model, eval_env, render=False, n_eval_episodes=10, deterministic=True, warn=False
18)
19print(f"mean_reward={mean_reward:.2f} +/- {std_reward}").