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?
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()
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:
Or if you want to record every 10th: