Last active
January 29, 2022 18:42
-
-
Save ViniTheSwan/f74403451db16ae4508f4d3b1f2ffddc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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