Views
No views yet
1!pip install shimmy
2
3from huggingface_sb3 import load_from_hub
4repo_id = "shunnaidder/ppo-LunarLander-v2" # The repo_id
5filename = "ppo-LunarLander-v2-small.zip" # The model filename.zip
6
7# When the model was trained on Python 3.8 the pickle protocol is 5
8# But Python 3.6, 3.7 use protocol 4
9# In order to get compatibility we need to:
10# 1. Install pickle5 (we done it at the beginning of the colab)
11# 2. Create a custom empty object we pass as parameter to PPO.load()
12custom_objects = {
13 "learning_rate": 0.0,
14 "lr_schedule": lambda _: 0.0,
15 "clip_range": lambda _: 0.0,
16}
17
18checkpoint = load_from_hub(repo_id, filename)
19model = PPO.load(checkpoint, custom_objects=custom_objects, print_system_info=True)
20
21#@title
22eval_env = Monitor(gym.make("LunarLander-v2"))
23mean_reward, std_reward = evaluate_policy(model, eval_env, n_eval_episodes=10, deterministic=True)
24print(f"mean_reward={mean_reward:.2f} +/- {std_reward}")
25...1from stable_baselines3 import ...
2from huggingface_sb3 import load_from_hub
3
4...