update readme
Browse files
README.md
CHANGED
@@ -30,8 +30,34 @@ TODO: Add your code
|
|
30 |
|
31 |
|
32 |
```python
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
...
|
37 |
```
|
|
|
30 |
|
31 |
|
32 |
```python
|
33 |
+
import gym
|
34 |
+
|
35 |
+
from huggingface_sb3 import load_from_hub, package_to_hub, push_to_hub
|
36 |
+
from huggingface_hub import notebook_login # To log to our Hugging Face account to be able to upload models to the Hub.
|
37 |
+
|
38 |
+
from stable_baselines3 import PPO
|
39 |
+
from stable_baselines3.common.evaluation import evaluate_policy
|
40 |
+
from stable_baselines3.common.env_util import make_vec_env
|
41 |
+
|
42 |
+
# Create the environment
|
43 |
+
env = make_vec_env('LunarLander-v2', n_envs=16)
|
44 |
+
|
45 |
+
model = PPO(
|
46 |
+
policy = 'MlpPolicy',
|
47 |
+
env = env,
|
48 |
+
n_steps = 1024,
|
49 |
+
batch_size = 64,
|
50 |
+
n_epochs = 4,
|
51 |
+
gamma = 0.999,
|
52 |
+
gae_lambda = 0.98,
|
53 |
+
ent_coef = 0.01,
|
54 |
+
verbose=1)
|
55 |
+
|
56 |
+
# Train it for 2,000,000 timesteps
|
57 |
+
model.learn(total_timesteps=2000000)
|
58 |
+
# Save the model
|
59 |
+
model_name = "ppo-LunarLander-v2"
|
60 |
+
model.save(model_name)
|
61 |
|
62 |
...
|
63 |
```
|