Skip to content

Instantly share code, notes, and snippets.

@ViniTheSwan
Last active January 29, 2022 18:42
Show Gist options
  • Save ViniTheSwan/f74403451db16ae4508f4d3b1f2ffddc to your computer and use it in GitHub Desktop.
Save ViniTheSwan/f74403451db16ae4508f4d3b1f2ffddc to your computer and use it in GitHub Desktop.
from stable_baselines3 import PPO
from stable_baselines3.common.env_util import make_vec_env
# Parallel environments
env = make_vec_env("CartPole-v1", n_envs=4)
model = PPO("MlpPolicy", env, verbose=1)
model.learn(total_timesteps=25000)
model.save("ppo_cartpole")
obs = env.reset()
for i in range(1000):
action, _state = model.predict(obs, deterministic=True)
obs, reward, done, info = env.step(action)
env.render()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment