Skip to content

Commit

Permalink
Add log_figure and log_histogram to TensorBoardLogger (#743)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #743

The SummaryWriter supports these just fine, so no reason not to include them here.

Reviewed By: galrotem

Differential Revision: D54958596

fbshipit-source-id: 6b54b015460e51b6672962848fb4f69b72393eaa
  • Loading branch information
alanhdu authored and facebook-github-bot committed Mar 18, 2024
1 parent 0bcbd55 commit af6cead
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions torchtnt/utils/loggers/tensorboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,17 @@ def log_images(self: TensorBoardLogger, *args: Any, **kwargs: Any) -> None:
if writer:
writer.add_images(*args, **kwargs)

def log_figure(self: TensorBoardLogger, *args: Any, **kwargs: Any) -> None:
"""Add matplotlib figure to TensorBoard.
Args:
*args (Any): Positional arguments passed to SummaryWriter.add_figure
**kwargs(Any): Keyword arguments passed to SummaryWriter.add_figure
"""
writer = self._writer
if writer:
writer.add_figure(*args, **kwargs)

def log_audio(self: TensorBoardLogger, *args: Any, **kwargs: Any) -> None:
"""Add audio data to TensorBoard.
Expand Down Expand Up @@ -202,6 +213,16 @@ def log_scalars(
walltime=walltime,
)

def log_histogram(self: TensorBoardLogger, *args: Any, **kwargs: Any) -> None:
"""Add histogram to TensorBoard.
Args:
*args (Any): Positional arguments passed to SummaryWriter.add_histogram
**kwargs(Any): Keyword arguments passed to SummaryWriter.add_histogram
"""
if self._writer:
self._writer.add_histogram(*args, **kwargs)

def flush(self: TensorBoardLogger) -> None:
"""Writes pending logs to disk."""

Expand Down

0 comments on commit af6cead

Please sign in to comment.