Last active
August 19, 2018 15:14
-
-
Save araffin/7a3a83ca19c990dda2bc12e152485b41 to your computer and use it in GitHub Desktop.
This file contains 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_baselines.common.cmd_util import make_atari_env | |
from stable_baselines.common.policies import CnnPolicy | |
from stable_baselines.common.vec_env import VecFrameStack | |
from stable_baselines import ACER | |
# There already exists an environment generator | |
# that will make and wrap atari environments correctly. | |
# Here we are also multiprocessing training (num_env=4 => 4 processes) | |
env = make_atari_env('PongNoFrameskip-v4', num_env=4, seed=0) | |
# Frame-stacking with 4 frames | |
env = VecFrameStack(env, n_stack=4) | |
model = ACER(CnnPolicy, env, verbose=1) | |
model.learn(total_timesteps=25000) | |
obs = env.reset() | |
while True: | |
action, _states = model.predict(obs) | |
obs, rewards, dones, info = env.step(action) | |
env.render() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment