xnn.common.train.loggers.TensorBoardLogger#

class xnn.common.train.loggers.TensorBoardLogger(save_dir=None, **writer_kwargs)[source]#

Bases: Logger

Writes the metrics as TensorBoard scalars through torch.utils.tensorboard.SummaryWriter.

Needs the tensorboard package (pip install "xnns[tensorboard]"). The writer is created on first use, so constructing the logger on every rank of a distributed run creates no files.

Parameters:
  • save_dir (str or None, optional) – The writer’s log directory; defaults to <output_dir>/tensorboard.

  • **writer_kwargs – Passed to SummaryWriter (flush_secs, comment, …).

setup(output_dir)[source]#

Default save_dir to <output_dir>/tensorboard.

Parameters:

output_dir (str)

Return type:

None

property experiment#

The SummaryWriter, for logging histograms, images or text directly.

log_hyperparams(params)[source]#

Show params as YAML in TensorBoard’s text tab.

Parameters:

params (dict)

Return type:

None

log_metrics(metrics, step)[source]#

Add one scalar per metric at step.

Parameters:
Return type:

None

finalize(status)[source]#

Flush and close the writer.

Parameters:

status (str)

Return type:

None