Dabe commited on
Commit
71d5140
·
1 Parent(s): 8bf18ae

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +27 -6
README.md CHANGED
@@ -22,16 +22,37 @@ model-index:
22
  ---
23
 
24
  # **PPO** Agent playing **LunarLander-v2**
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
- ```
 
22
  ---
23
 
24
  # **PPO** Agent playing **LunarLander-v2**
25
+ This is a trained model of a **PPO** agent playing **LunarLander-v2**, trained for 1e6 time steps, obtaining:
26
+ **mean_reward** = 241.85 +/- 48.02
27
+
28
  using the [stable-baselines3 library](https://github.com/DLR-RM/stable-baselines3).
29
 
30
  ## Usage (with Stable-baselines3)
 
31
 
32
 
33
  ```python
34
+ import gym
35
+
36
+ from stable_baselines3 import PPO # Modelo que vamos a usar
37
+ from stable_baselines3.common.evaluation import evaluate_policy # Evaluación de los resultados del modelo entrenado
38
+ from stable_baselines3.common.env_util import make_vec_env
39
+
40
+ # Creo el env
41
+ env = gym.make('LunarLander-v2')
42
+
43
+ # Selecciono el modelo, en este caso el PPO, y lo ponemos a entrenar
44
+ model = PPO('MlpPolicy',env,verbose=1).learn(total_timesteps=1000000,progress_bar=True)
45
+
46
+ # Lo guardamos
47
+ model.save('Lunar_Lander')
48
+
49
+ # Creamos un nuevo env en el que probamos el modelo (valdría el mismo pero reseteado)
50
+ eval_env = gym.make('LunarLander-v2')
51
+
52
+ # Evaluamos el modelo
53
+ mean_reward, std_reward = evaluate_policy(model, eval_env, n_eval_episodes=10, deterministic=True)
54
+
55
+ # Print the results
56
+ print(f"mean_reward={mean_reward:.2f} +/- {std_reward}")
57
 
58
+ ```