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

Adds env_stats to record_tb_stats #98

Merged
merged 2 commits into from
Dec 12, 2020

Conversation

prabhatnagarajan
Copy link
Contributor

@prabhatnagarajan prabhatnagarajan commented Nov 24, 2020

Currently, environment statistics are not being incorporated into the tensorboard output.

I modified train_dqn_ale.py by adding a dummy wrapper:

import gym
class ComputeSuccessRate(gym.Wrapper):
    def __init__(self, env):
        super().__init__(env)
        self.success_record = []

    def reset(self):
        return self.env.reset()

    def step(self, action):
        obs, r, done, info = self.env.step(action)
        return obs, r, done, info

    def get_statistics(self):
        return [("success_rate", 0.75)]

    def clear_statistics(self):
        self.success_record = []

The wrapper itself is useless, but it returns environment statistics. I've confirmed they appear in tensorboard when I run an experiment withuse_tensorboard:

image

@prabhatnagarajan prabhatnagarajan marked this pull request as ready for review November 24, 2020 09:02
@prabhatnagarajan
Copy link
Contributor Author

/test

@pfn-ci-bot
Copy link

Successfully created a job for commit 79a512e:

@prabhatnagarajan
Copy link
Contributor Author

/test

@pfn-ci-bot
Copy link

Successfully created a job for commit f57b3d2:

Copy link

@justindujardin justindujardin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would love to use this functionality for recording custom metrics. The changes look good to me!

@prabhatnagarajan
Copy link
Contributor Author

Thanks! Glad that you find this change useful. Currently these custom statistics should actually be available in scores.txt so you should already be able to use them. Though this PR makes it visible in Tensorboard.

@ummavi ummavi merged commit 7026ca8 into pfnet:master Dec 12, 2020
@muupan muupan added the enhancement New feature or request label Dec 14, 2020
@muupan muupan added this to the v0.2.0 milestone Dec 14, 2020
@prabhatnagarajan prabhatnagarajan deleted the env_stats_tb branch December 16, 2020 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants