Views
No views yet
1from stable_baselines3 import PPO
2from stable_baselines3.common.env_util import make_vec_env
3
4env = make_vec_env("LunarLander-v2", n_envs=16)
5model = PPO('MlpPolicy',
6 env=env,
7 n_steps=1024,
8 batch_size=64,
9 n_epochs=4,
10 gamma=0.999,
11 gae_lambda=0.98,
12 ent_coef=0.01,
13 verbose=1)
14model.learn(total_timesteps=10000000, progress_bar=True)1from stable_baselines3 import PPO
2from huggingface_sb3 import load_from_hub
3
4repo_id = "zhuqi/PPO_LunarLander-v2_steps10M" # The repo_id
5filename = "PPO_LunarLander-v2_steps10000000.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)