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

save the info #28

Closed
ChenyangRan opened this issue Apr 10, 2020 · 2 comments
Closed

save the info #28

ChenyangRan opened this issue Apr 10, 2020 · 2 comments
Assignees
Labels
enhancement Feature that is not a new algorithm or an algorithm enhancement

Comments

@ChenyangRan
Copy link

ChenyangRan commented Apr 10, 2020

Hi, the info includes a flag which represents succ or fail to grasp.
How can I save the info by tensorboard?
I don't see the env.step and save the info.

@Trinkle23897 Trinkle23897 added the enhancement Feature that is not a new algorithm or an algorithm enhancement label Apr 10, 2020
@Trinkle23897 Trinkle23897 self-assigned this Apr 10, 2020
Trinkle23897 added a commit that referenced this issue Apr 10, 2020
@Trinkle23897
Copy link
Collaborator

Trinkle23897 commented Apr 10, 2020

Here it is: I add a log_fn in both collector and trainer. This hook receives each step's env info.

class Logger(object):
    def __init__(self, writer):
        self.cnt = 0
        self.writer = writer

    def log(self, info):
        self.writer.add_scalar('key', info['key'], global_step=self.cnt)
        self.cnt += 1

and in trainer (or collector, if you don't use trainer), add an argument log_fn=logger.log.

@ChenyangRan
Copy link
Author

Here it is: I add a log_fn in both collector and trainer. This hook receives each step's env info.

class Logger(object):
    def __init__(self, writer):
        self.cnt = 0
        self.writer = writer

    def log(self, info):
        self.writer.add_scalar('key', info['key'], global_step=self.cnt)
        self.cnt += 1

and in trainer (or collector, if you don't use trainer), add an argument log_fn=logger.log.

Thanks, I'll try it.

BFAnas pushed a commit to BFAnas/tianshou that referenced this issue May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature that is not a new algorithm or an algorithm enhancement
Projects
No open projects
Development

No branches or pull requests

2 participants