mednet.engine.loggers

Custom lightning loggers.

Classes

CustomTensorboardLogger(save_dir[, name, ...])

Custom implementation implementation of lightning's TensorboardLogger.

class mednet.engine.loggers.CustomTensorboardLogger(save_dir, name='lightning-logs', version=None, log_graph=False, default_hp_metric=True, prefix='', sub_dir=None, **kwargs)[source]

Bases: TensorBoardLogger

Custom implementation implementation of lightning’s TensorboardLogger.

This implementation puts all logs inside the same directory, instead of a separate “version_n” directories, which is the default lightning behaviour.

Parameters:
  • save_dir (Union[str, Path]) – Directory where to save the logs to.

  • name (str) – Experiment name. Defaults to default. If it is the empty string then no per-experiment subdirectory is used.

  • version (int | str | None) – Experiment version. If version is not specified the logger inspects the save directory for existing versions, then automatically assigns the next available version. If it is a string then it is used as the run-specific subdirectory name, otherwise version_${version} is used.

  • log_graph (bool) – Adds the computational graph to tensorboard. This requires that the user has defined the self.example_input_array attribute in their model.

  • default_hp_metric (bool) – Enables a placeholder metric with key hp_metric when log_hyperparams is called without a metric (otherwise calls to log_hyperparams without a metric are ignored).

  • prefix (str) – A string to put at the beginning of metric keys.

  • sub_dir (Union[str, Path, None]) – Sub-directory to group TensorBoard logs. If a sub_dir argument is passed then logs are saved in /save_dir/name/version/sub_dir/. Defaults to None in which logs are saved in /save_dir/name/version/.

  • **kwargs (dict[str, Any]) – Additional arguments used by tensorboardX.SummaryWriter can be passed as keyword arguments in this logger. To automatically flush to disk, max_queue sets the size of the queue for pending logs before flushing. flush_secs determines how many seconds elapses before flushing.

property log_dir: str

The directory for this run’s tensorboard checkpoint.

By default, it is named 'version_${self.version}' but it can be overridden by passing a string value for the constructor’s version parameter instead of None or an int.