<jupyter_start><jupyter_text>Create environment<jupyter_code>env_name = "LunarLander-v2"
env_name = "CartPole-v0"
env = gym.make(env_name)
env.seed(0)

state_size =  env.observation_space.shape[0]
action_size = env.action_space.n

print("State size:", state_size, "\nAction size:", action_size)<jupyter_output>State size: 4 
Action size: 2<jupyter_text>ACER Test<jupyter_code>tmax = 200
max_episodes = 100
n_env = mp.cpu_count()

network = models.ACERModel(state_size, action_size)

env_constructor = gym.make
env_args = (env_name,)
# init agent:
agent = ACER(network=network,
             env_name=env_name,
             env_constr=env_constructor,
             env_args=env_args,
             gamma=0.99, 
             replay_n=4,
             lr=3e-4, 
             n_env=n_env,
             polyak_alpha=0.99,
             trpo_theta=1,
             use_trpo=True,
             entropy_coefficient=1e-4,
             memory_size_steps=1_000_000,
             max_episodes=max_episodes,
             max_episode_length=tmax,
             max_traj_length=20,
             start_off_policy=2000,
             clip=10,
             batch_size=64,
             max_grad_norm=None,
             seed=0,
            )
max_score = 195.
model_name = "acer_{}".format(env_name)
# train the agent
scores = agent.train(max_score, alg_name=model_name, tmax=tmax)

# plot the training:
x = np.arange(len(scores))
scores = mean_filter(scores, filter_len=n_env)
plt.plot(x, scores, label = "scores")
plt.show()<jupyter_output>/home/selo/Envs/ml-agent_/gym/gym/logger.py:30: UserWarning: [33mWARN: Box bound precision lowered by casting to float32[0m
  warnings.warn(colorize('%s: %s'%('WARN', msg % args), 'yellow'))<jupyter_text>Trained Agent Demonstration<jupyter_code>agent.test(n_episodes=5, max_t=200, render=True, deterministic=True)<jupyter_output>/home/selo/Envs/ml-agent_/gym/gym/logger.py:30: UserWarning: [33mWARN: Box bound precision lowered by casting to float32[0m
  warnings.warn(colorize('%s: %s'%('WARN', msg % args), 'yellow'))
{'fraction_non_alphanumeric': 0.12371134020618557, 'fraction_numerical': 0.030927835051546393, 'mean_word_length': 3.326963906581741, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '372451', 'license': 'MIT', 'n_tokens_mistral': 803, 'n_tokens_neox': 751, 'n_words': 119, 'path': 'tests/acer_test.ipynb', 'repo_name': 'selim-karaduman/pytorch-drl-algs', 'size': '2037'}