kinkpunk commited on
Commit
4947a47
·
1 Parent(s): 9d9a6de

Update README.md

Browse files

Update usage code

Files changed (1) hide show
  1. README.md +22 -1
README.md CHANGED
@@ -33,5 +33,26 @@ TODO: Add your code
33
  from stable_baselines3 import ...
34
  from huggingface_sb3 import load_from_hub
35
 
36
- ...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  ```
 
33
  from stable_baselines3 import ...
34
  from huggingface_sb3 import load_from_hub
35
 
36
+ from stable_baselines3 import PPO
37
+ from stable_baselines3.common.evaluation import evaluate_policy
38
+ from stable_baselines3.common.env_util import make_vec_env
39
+
40
+ repo_id = "kinkpunk/Lunar-Landing-Program"
41
+ filename = "LunarProgram-PPO.zip"
42
+
43
+ custom_objects = {
44
+ "learning_rate": 0.0,
45
+ "lr_schedule": lambda _: 0.0,
46
+ "clip_range": lambda _: 0.0,
47
+ }
48
+
49
+ checkpoint = load_from_hub(repo_id, filename)
50
+ model = PPO.load(checkpoint, custom_objects=custom_objects, print_system_info=True)
51
+
52
+ env = make_vec_env('LunarLander-v2', n_envs=1)
53
+
54
+ # Evaluate the model
55
+ mean_reward, std_reward = evaluate_policy(model, env, n_eval_episodes=10, deterministic=True)
56
+ # Print the results
57
+ print('mean_reward={:.2f} +/- {:.2f}'.format(mean_reward, std_reward))
58
  ```