tasklog
These loggers are designed to handle the logging and analysis for a whole task.
- class MinervaTaskLogger(task_name: str, n_batches: int, batch_size: int, input_size: tuple[int, int, int], output_size: tuple[int, ...], step_logger_params: dict[str, Any] | None = None, record_int: bool = True, record_float: bool = False, writer: None | Run = None, **params)
Abstract class for metric logging within the
minerva
framework.- metrics
Dictionary to hold the metrics to assess the model with for each mode of fitting.
- Parameters:
n_batches (dict[str, int]) – Dictionary of the number of batches in each mode of fitting.
batch_size (int) – Batch size.
data_size (tuple[int, int, int]) – Shape of the input data in
C x H x W
.logger_params (dict[str, Any]) – Optional; Parameters for a logger other than the default for these metrics.
Added in version 0.27.
- calc_metrics(epoch_no: int) None
Updates metrics with epoch results.
- Parameters:
epoch_no (int) – Epoch number to log.
- property get_logs: dict[str, Any]
Get the logs of each step from the latest epoch of the task.
Added in version 0.27.
- property get_results: dict[str, Any]
Get the results of each step from the latest epoch of the task.
Added in version 0.27.
- get_sub_metrics(pattern: tuple[str, ...] = ('train', 'val')) dict[str, Any]
Gets a subset of the metrics dictionary with keys containing strings in the pattern.
Useful for getting the train and validation metrics for plotting for example.
- log_epoch_number(epoch_no: int) None
Logs the epoch number to
metrics
.- Parameters:
epoch_no (int) – Epoch number to log.
- log_null() None
Log
numpy.NAN
for this epoch.Useful for logging null when a validation epoch was skipped so that the length of the logs remains the same as the training logs.
- abstract print_epoch_results(epoch_no: int) None
Prints the results from an epoch to
stdout
.- Parameters:
epoch_no (int) – Epoch number to print results from.
- step(global_step_num: int, local_step_num: int, loss: Tensor, x: Tensor | None = None, y: Tensor | None = None, z: Tensor | None = None, index: BoundingBox | None = None, *args, **kwargs) None
Abstract method to log a step, using the logger. Must be overwritten.
- Parameters:
global_step_num (int) – The global step number of the model fitting.
local_step_num (int) – The local step number for this logger.
loss (Tensor) – Loss from this step of model fitting.
x (Tensor) – Optional; Images supplied to the model.
y (Tensor) – Optional; Labels to assess model output against.
z (Tensor) – Optional; Output tensor from the model.
index (int | BoundingBox) – Optional; Bounding boxes or index of the input samples.
- Returns:
None
- class SSLTaskLogger(task_name: str, n_batches: int, batch_size: int, input_size: tuple[int, int, int], output_size: tuple[int, ...], step_logger_params: dict[str, Any] | None = None, record_int: bool = True, record_float: bool = False, writer: None | Run = None, model_type: str = 'segmentation', sample_pairs: bool = False, **params)
Metric logging for self-supervised models.
- metrics
Dictionary to hold the metrics to assess the model with for each mode of fitting.
- Parameters:
Added in version 0.27.
- class SupervisedTaskLogger(task_name: str, n_batches: int, batch_size: int, input_size: tuple[int, int, int], output_size: tuple[int, ...], step_logger_params: dict[str, Any] | None = None, record_int: bool = True, record_float: bool = False, writer: None | Run = None, model_type: str = 'segmentation', **params)
Metric logging for supervised models.
- metrics
Dictionary to hold the metrics to assess the model with for each mode of fitting.
- Parameters:
Added in version 0.27.