Update README.md
Browse files
README.md
CHANGED
|
@@ -30,21 +30,23 @@ Numbers on X axis are average over 40 episodes, each lasting for about 500 times
|
|
| 30 |
Learning rate decay schedule: <code>torch.optim.lr_scheduler.StepLR(opt, step_size=4000, gamma=0.7)</code>
|
| 31 |
|
| 32 |
Minimal code to use the agent:</br>
|
| 33 |
-
|
| 34 |
-
import gym
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
| 30 |
Learning rate decay schedule: <code>torch.optim.lr_scheduler.StepLR(opt, step_size=4000, gamma=0.7)</code>
|
| 31 |
|
| 32 |
Minimal code to use the agent:</br>
|
| 33 |
+
```
|
| 34 |
+
import gym
|
| 35 |
+
from agent_class import ParameterisedPolicy
|
| 36 |
+
|
| 37 |
+
env_name = 'LunarLanderContinuous-v2'
|
| 38 |
+
env = gym.make(env_name)
|
| 39 |
+
agent = torch.load('best_reinforce_lunar_lander_cont_model_269.402.pt')
|
| 40 |
+
render = True
|
| 41 |
+
|
| 42 |
+
observation = env.reset()
|
| 43 |
+
while True:
|
| 44 |
+
if render:
|
| 45 |
+
env.render()
|
| 46 |
+
action = agent.act(observation)
|
| 47 |
+
observation, reward, done, info = env.step(action)
|
| 48 |
+
|
| 49 |
+
if done:
|
| 50 |
+
break
|
| 51 |
+
env.close()
|
| 52 |
+
```
|