Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monitor CartPole-v0 not recording every episode #494

Closed
cpatyn opened this issue Feb 9, 2017 · 4 comments
Closed

Monitor CartPole-v0 not recording every episode #494

cpatyn opened this issue Feb 9, 2017 · 4 comments

Comments

@cpatyn
Copy link

@cpatyn cpatyn commented Feb 9, 2017

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?

@tlbtlbtlb
Copy link
Contributor

@tlbtlbtlb tlbtlbtlb commented Feb 9, 2017

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)

@fuxianh
Copy link

@fuxianh fuxianh commented Oct 18, 2018

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

@tlbtlbtlb
Copy link
Contributor

@tlbtlbtlb tlbtlbtlb commented Oct 18, 2018

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

@aliamiri1380
Copy link

@aliamiri1380 aliamiri1380 commented Jan 20, 2020

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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants