zhuqi commited on
Commit
9fea0e4
1 Parent(s): 8dbbb75

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +37 -3
README.md CHANGED
@@ -25,13 +25,47 @@ model-index:
25
  This is a trained model of a **PPO** agent playing **LunarLander-v2**
26
  using the [stable-baselines3 library](https://github.com/DLR-RM/stable-baselines3).
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  ## Usage (with Stable-baselines3)
29
- TODO: Add your code
30
 
31
 
32
  ```python
33
- from stable_baselines3 import ...
34
  from huggingface_sb3 import load_from_hub
35
 
36
- ...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  ```
 
25
  This is a trained model of a **PPO** agent playing **LunarLander-v2**
26
  using the [stable-baselines3 library](https://github.com/DLR-RM/stable-baselines3).
27
 
28
+ ## Training
29
+
30
+ ```python
31
+ from stable_baselines3 import PPO
32
+ from stable_baselines3.common.env_util import make_vec_env
33
+
34
+ env = make_vec_env("LunarLander-v2", n_envs=16)
35
+ model = PPO('MlpPolicy',
36
+ env=env,
37
+ n_steps=1024,
38
+ batch_size=64,
39
+ n_epochs=4,
40
+ gamma=0.999,
41
+ gae_lambda=0.98,
42
+ ent_coef=0.01,
43
+ verbose=1)
44
+ model.learn(total_timesteps=10000000, progress_bar=True)
45
+ ```
46
+
47
+
48
  ## Usage (with Stable-baselines3)
 
49
 
50
 
51
  ```python
52
+ from stable_baselines3 import PPO
53
  from huggingface_sb3 import load_from_hub
54
 
55
+ repo_id = "zhuqi/PPO_LunarLander-v2_steps10M" # The repo_id
56
+ filename = "PPO_LunarLander-v2_steps10000000.zip" # The model filename.zip
57
+
58
+ # When the model was trained on Python 3.8 the pickle protocol is 5
59
+ # But Python 3.6, 3.7 use protocol 4
60
+ # In order to get compatibility we need to:
61
+ # 1. Install pickle5 (we done it at the beginning of the colab)
62
+ # 2. Create a custom empty object we pass as parameter to PPO.load()
63
+ custom_objects = {
64
+ "learning_rate": 0.0,
65
+ "lr_schedule": lambda _: 0.0,
66
+ "clip_range": lambda _: 0.0,
67
+ }
68
+
69
+ checkpoint = load_from_hub(repo_id, filename)
70
+ model = PPO.load(checkpoint, custom_objects=custom_objects, print_system_info=True)
71
  ```