mrm8488 commited on
Commit
fd07be0
1 Parent(s): 31981c3

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +46 -1
README.md CHANGED
@@ -1,7 +1,52 @@
 
1
  ---
2
  tags:
3
  - deep-reinforcement-learning
4
  - reinforcement-learning
5
  - stable-baselines3
6
  ---
7
- # TODO: Fill this model card
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #@title
2
  ---
3
  tags:
4
  - deep-reinforcement-learning
5
  - reinforcement-learning
6
  - stable-baselines3
7
  ---
8
+ # PPO LunarLander-v2
9
+
10
+ This is a pre-trained model of a PPO agent playing LunarLander-v2 using the [stable-baselines3](https://github.com/DLR-RM/stable-baselines3) library.
11
+
12
+ ### Usage (with Stable-baselines3)
13
+ Using this model becomes easy when you have stable-baselines3 and huggingface_sb3 installed:
14
+
15
+ ```
16
+ pip install stable-baselines3
17
+ pip install huggingface_sb3
18
+ ```
19
+
20
+ Then, you can use the model like this:
21
+
22
+ ```python
23
+ import gym
24
+
25
+ from huggingface_sb3 import load_from_hub
26
+ from stable_baselines3 import PPO
27
+ from stable_baselines3.common.evaluation import evaluate_policy
28
+
29
+ # Retrieve the model from the hub
30
+ ## repo_id = id of the model repository from the Hugging Face Hub (repo_id = mrm8488/ppo-LunarLander-v2)
31
+ ## filename = name of the model zip file from the repository
32
+ checkpoint = load_from_hub(repo_id="mrm8488/ppo-LunarLander-v2", filename="ppo-LunarLander-v2")
33
+ model = PPO.load(checkpoint)
34
+
35
+ # Evaluate the agent
36
+ eval_env = gym.make('LunarLander-v2')
37
+ mean_reward, std_reward = evaluate_policy(model, eval_env, n_eval_episodes=10, deterministic=True)
38
+ print(f"mean_reward={mean_reward:.2f} +/- {std_reward}")
39
+
40
+ # Watch the agent play
41
+ obs = env.reset()
42
+ for i in range(1000):
43
+ action, _state = model.predict(obs)
44
+ obs, reward, done, info = env.step(action)
45
+ env.render()
46
+ if done:
47
+ obs = env.reset()
48
+ env.close()
49
+ ```
50
+
51
+ ### Evaluation Results
52
+ Mean_reward: 254.72 +/- 21.70