Gym: Monitor CartPole-v0 not recording every episode

Created on 9 Feb 2017  路  4Comments  路  Source: openai/gym

In the documentation it says that every episode will be recorded as long as the environment returns done = True. However my Monitor only seems to record episodes sporadically. Is this intentional? And if so, is there a way to record all episodes?

Most helpful comment

The statistics recorder records all episodes, but by default the video recorder only captures a sampling of episodes (those with episodes numbers which are perfect cubes: 1, 8, 27, 64, ... and then every 1000th). Otherwise, videos get huge during long training runs. But if you want to record everything, create the monitor with:

   env = gym.wrappers.Monitor(env, directory, video_callable=lambda episode_id: True)

Or if you want to record every 10th:

   env = gym.wrappers.Monitor(env, directory, video_callable=lambda episode_id: episode_id%10==0)

All 4 comments

The statistics recorder records all episodes, but by default the video recorder only captures a sampling of episodes (those with episodes numbers which are perfect cubes: 1, 8, 27, 64, ... and then every 1000th). Otherwise, videos get huge during long training runs. But if you want to record everything, create the monitor with:

   env = gym.wrappers.Monitor(env, directory, video_callable=lambda episode_id: True)

Or if you want to record every 10th:

   env = gym.wrappers.Monitor(env, directory, video_callable=lambda episode_id: episode_id%10==0)

@tlbtlbtlb It seems record cannot be used in a newest version of baseline. Do you have any suggestions? Thank you.

@fuxianh I'm no longer working on Gym. I suggest reporting a bug complete with an example.

this works for me

env = gym.make(ENV_NAME)
env = gym.wrappers.Monitor(env, "./vid", video_callable=lambda episode_id: True,force=True)
done = False
for i in range(1):
    observation = env.reset()
    while not done:
        # env.render()
        action = env.observation_space.sample()
        observation_, reward, done, info = env.step(action)
        observation = observation_
env.close()
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Baichenjia picture Baichenjia  路  3Comments

hipoglucido picture hipoglucido  路  4Comments

reaIws picture reaIws  路  4Comments

pickittwice picture pickittwice  路  4Comments

pdoongarwal picture pdoongarwal  路  4Comments