Views
No views yet
1from huggingface_sb3 import load_from_hub
2repo_id = "buildthemachine/ppo-LunarLander-v2" # The repo_id
3filename = "ppo-LunarLander-v2.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)1model = PPO(policy = 'MlpPolicy',
2 env = env,
3 learning_rate = 3e-4,
4 n_steps = 1024,
5 batch_size = 64,
6 n_epochs = 4,
7 gamma = 0.999,
8 gae_lambda = 0.98,
9 ent_coef = 0.01,
10 verbose=1)
11model_name = "ppo-LunarLander-v2"
12model = PPO.load((f"/content/drive/MyDrive/Colab Notebooks/RL_tutorial_model_save/{model_name}"))
13