Views
No views yet
1from huggingface_sb3 import load_from_hub
2repo_id = "zhiweiyoung/ppo-LunarLander-v2" # The repo_id
3filename = "zhiwei_ppo.zip" # The model filename.zip
4
5# When the model was trained on Python 3.8 the pickle protocol is 5
6# But Python 3.6, 3.7 use protocol 4
7# In order to get compatibility we need to:
8# 1. Install pickle5 (we done it at the beginning of the colab)
9# 2. Create a custom empty object we pass as parameter to PPO.load()
10custom_objects = {
11 "learning_rate": 0.0,
12 "lr_schedule": lambda _: 0.0,
13 "clip_range": lambda _: 0.0,
14}
15
16checkpoint = load_from_hub(repo_id, filename)
17model = PPO.load(checkpoint, custom_objects=custom_objects, print_system_info=True)