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

[Feature Request] add_scalars to wirte func in TensorBoardOutputFormat in logger #1994

Open
2 tasks done
shimonShouei opened this issue Aug 19, 2024 · 2 comments
Open
2 tasks done
Labels
enhancement New feature or request

Comments

@shimonShouei
Copy link

shimonShouei commented Aug 19, 2024

🚀 Feature

Add support for multi-variable logging in the logger module using add_scalars.
Enable the logger to record and visualize multiple related scalar values simultaneously using a single record call. For example:

self.logger.record('run_14h', {'xsinx': i*np.sin(i/r),
                               'xcosx': i*np.cos(i/r),
                               'tanx': np.tan(i/r)}, i)

Motivation

Currently, the logger module only supports recording single scalar values per call. When working with complex experiments where multiple related metrics need to be tracked and compared, the lack of multi-variable logging can be limiting. Allowing multi-variable logging would provide a clearer, more organized way to monitor and visualize these metrics, enhancing the experiment analysis process.

Pitch

Introduce an option in the logger module to use the add_scalars function, enabling the recording of multiple related scalar values with a single record call. This feature will simplify the process of logging and visualizing multiple metrics in TensorBoard or similar tools, improving the monitoring and analysis of DRL experiments.
To implement this, add the following code to the writer method in the TensorBoardOutputFormat class within the logger module:

if isinstance(value, dict):
    self.writer.add_scalars(key, value, step)

Alternatives

Getting through the SummaryWriter to the writer

Additional context

Including this feature would help users who track multiple metrics to maintain cleaner and more organized logs. It would also align the logger module with the capabilities of TensorBoard's add_scalars function, offering a more consistent user experience.

Checklist

  • I have checked that there is no similar issue in the repo
  • If I'm requesting a new feature, I have proposed alternatives
@shimonShouei shimonShouei added the enhancement New feature or request label Aug 19, 2024
@araffin
Copy link
Member

araffin commented Sep 10, 2024

Hello,

what you are proposing only works for tensorboard logger, right?
what do you propose as behavior for the other loggers?

Getting through the SummaryWriter to the writer

Sounds like a simple enough alternative? (3 lines change: https://stable-baselines3.readthedocs.io/en/master/guide/tensorboard.html#directly-accessing-the-summary-writer)

@shimonShouei
Copy link
Author

shimonShouei commented Sep 10, 2024

What you are proposing only works for tensorboard logger, right?
what do you propose as behavior for the other loggers?

It works for me in stdout too. I don't use the others.

Sounds like a simple enough alternative?

The Record func is very convenient and powerful and I would rather use it than involve the writer. though, even that solution isn't good enough for my problem because it doesn't dump them (the scalars) under the same run.

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

No branches or pull requests

2 participants