DLR-RM / DLR-RM/stable-baselines3
[Feature Request] add_scalars to wirte func in TensorBoardOutputFormat in logger
- Dominant language
- Python
- Stars
- 13.8k
- Forks
- 2.2k
- Avg merge
- 1h 35m
- Merged PRs (30d)
- 2
Description
### 🚀 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
- [X] I have checked that there is no similar [issue](https://github.com/DLR-RM/stable-baselines3/issues) in the repo
- [X] If I'm requesting a new feature, I have proposed alternatives
Contributor guide
Research direction
Start in the logger module by reading TensorBoardOutputFormat.writer and tracing how record passes values to it. Check the existing logger tests or TensorBoard logging behavior, then verify that one record can handle the related scalar values described in the issue without breaking single-value logging.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100