ml.loggers.tensorboard

Defines a Tensorboard logging interface.

This is a pretty vanilla Tensorboard setup. Each phase gets its own SummaryWriter, and scalars are logged to the writer for the current phase. Additionally, when developing locally, we also start a Tensorboard server in a subprocess. This can be disabled by setting DISABLE_TENSORBOARD=1. Also, a specific Tensorboard port can be specified by setting TENSORBOARD_PORT=<port>.

ml.loggers.tensorboard.format_as_string(value: Any) str[source]
ml.loggers.tensorboard.iter_flat(config: dict) Iterator[tuple[list[str | None], str]][source]
ml.loggers.tensorboard.to_markdown_table(config: DictConfig) str[source]
class ml.loggers.tensorboard.TensorboardLoggerConfig(name: str = '???', write_every_n_seconds: float | None = None, write_train_every_n_seconds: float | None = None, write_val_every_n_seconds: float | None = None, flush_seconds: float = 10.0, wait_seconds: float = 0.0, start_in_subprocess: bool = True)[source]

Bases: BaseLoggerConfig

flush_seconds: float = 10.0
wait_seconds: float = 0.0
start_in_subprocess: bool = True
class ml.loggers.tensorboard.TensorboardLogger(config: TensorboardLoggerConfig)[source]

Bases: BaseLogger[TensorboardLoggerConfig]

initialize(log_directory: Path) None[source]
worker_thread() None[source]
cleanup() None[source]
property tensorboard_log_directory: Path
property train_writer: SummaryWriter
property valid_writer: SummaryWriter
property test_writer: SummaryWriter
clear_logs() None[source]
get_writer(phase: Literal['train', 'valid', 'test']) SummaryWriter[source]
log_scalar(key: str, value: Callable[[], int | float | Tensor], state: State, namespace: str) None[source]

Logs a scalar value.

Parameters:
  • key – The key to log

  • value – The value to log

  • state – The current log state

  • namespace – The namespace to be logged

log_string(key: str, value: Callable[[], str], state: State, namespace: str) None[source]

Logs a string value.

Parameters:
  • key – The key to log

  • value – The value to log

  • state – The current log state

  • namespace – The namespace to be logged

log_image(key: str, value: Callable[[], Tensor], state: State, namespace: str) None[source]

Logs a normalized image, with shape (C, H, W).

Parameters:
  • key – The key to log

  • value – The value to log

  • state – The current log state

  • namespace – The namespace to be logged

log_audio(key: str, value: Callable[[], tuple[torch.Tensor, int]], state: State, namespace: str) None[source]

Logs a normalized audio, with shape (T,).

Parameters:
  • key – The key to log

  • value – The value to log

  • state – The current log state

  • namespace – The namespace to be logged

log_video(key: str, value: Callable[[], Tensor], state: State, namespace: str) None[source]

Logs a normalized video, with shape (T, C, H, W).

Parameters:
  • key – The key to log

  • value – The value to log

  • state – The current log state

  • namespace – The namespace to be logged

log_histogram(key: str, value: Callable[[], Tensor], state: State, namespace: str) None[source]

Logs a histogram, with any shape.

Parameters:
  • key – The key to log

  • value – The value to log

  • state – The current log state

  • namespace – The namespace to be logged

log_point_cloud(key: str, value: Callable[[], Tensor], state: State, namespace: str) None[source]

Logs a normalized point cloud, with shape (B, N, 3).

Parameters:
  • key – The key to log

  • value – The value to log

  • state – The current log state

  • namespace – The namespace to be logged

log_config(config: DictConfig) None[source]

Logs a set of metrics and configuration.

This is only called once, when metrics are computed for a whole dataset.

Parameters:

config – The run config

write(state: State) None[source]

Writes the logs.

Parameters:

state – The current log state

clear(state: State) None[source]
default_write_every_n_seconds(state: State) float[source]

Returns the default write interval in seconds.

Parameters:

state – The state to get the default write interval for

Returns:

The default write interval, in seconds