Skip to content

Commit

Permalink
Updated example doc for SubprocVecEnv (#531)
Browse files Browse the repository at this point in the history
* Wrapped SubprocVecEnv example with main check

* Update examples.rst
  • Loading branch information
rusu24edward authored and Miffyli committed Oct 30, 2019
1 parent 22c0753 commit dae212b
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions docs/guide/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,20 @@ Multiprocessing: Unleashing the Power of Vectorized Environments
set_global_seeds(seed)
return _init
env_id = "CartPole-v1"
num_cpu = 4 # Number of processes to use
# Create the vectorized environment
env = SubprocVecEnv([make_env(env_id, i) for i in range(num_cpu)])
model = ACKTR(MlpPolicy, env, verbose=1)
model.learn(total_timesteps=25000)
obs = env.reset()
for _ in range(1000):
action, _states = model.predict(obs)
obs, rewards, dones, info = env.step(action)
env.render()
if __name__ == '__main__':
env_id = "CartPole-v1"
num_cpu = 4 # Number of processes to use
# Create the vectorized environment
env = SubprocVecEnv([make_env(env_id, i) for i in range(num_cpu)])
model = ACKTR(MlpPolicy, env, verbose=1)
model.learn(total_timesteps=25000)
obs = env.reset()
for _ in range(1000):
action, _states = model.predict(obs)
obs, rewards, dones, info = env.step(action)
env.render()
Expand Down

0 comments on commit dae212b

Please sign in to comment.