steplog
Loggers to handle the logging from each step of a task.
- class KNNStepLogger(task_name: str, n_batches: int, batch_size: int, record_int: bool = True, record_float: bool = False, writer: None | Run = None, model_type: str = '', **kwargs)
Logger specifically designed for use with the KNN validation in
trainer.Trainer.weighted_knn_validation()
.- logs
The main logs from the KNN with these metrics:
batch_num
total_loss
total_correct
total_top5
- Parameters:
n_batches (int) – Number of batches in the epoch.
batch_size (int) – Size of the batch.
n_samples (int) – Total number of samples in the epoch.
record_int (bool) – Optional; Whether to record the integer values from an epoch of model fitting. Defaults to
True
.record_float (bool) – Optional; Whether to record the floating point values from an epoch of model fitting. Defaults to
False
.writer (SummaryWriter | Run) – Optional; Writer object from
tensorboard
, awandb
Run
object orNone
.
Added in version 0.27.
- log(global_step_num: int, local_step_num: int, loss: Tensor, x: Tensor | None = None, y: Tensor | None = None, z: Tensor | None = None, index: int | BoundingBox | None = None, *args, **kwargs) None
Logs the outputs and results from a step of model fitting. Overwrites abstract method.
- 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 MinervaStepLogger(task_name: str, n_batches: int, batch_size: int, input_size: tuple[int, int, int], output_size: tuple[int, ...], record_int: bool = True, record_float: bool = False, writer: None | Run = None, model_type: str = '', **kwargs)
Base abstract class for all
minerva
step logger classes to ensure intercompatibility withTrainer
.- record_float
Whether to record the floating point values from an epoch of model fitting.
- Type:
- logs
Dictionary to hold the logs from the epoch. Logs should be more lightweight than
results
.
- Parameters:
n_batches (int) – Number of batches in the epoch.
batch_size (int) – Size of the batch.
n_samples (int) – Total number of samples in the epoch.
record_int (bool) – Optional; Whether to record the integer values from an epoch of model fitting. Defaults to
True
.record_float (bool) – Optional; Whether to record the floating point values from an epoch of model fitting. Defaults to
False
.writer (SummaryWriter | Run) – Optional; Writer object from
tensorboard
, awandb
Run
object orNone
.
Added in version 0.27.
- abstract log(global_step_num: int, local_step_num: int, loss: Tensor, x: Tensor | None = None, y: Tensor | None = None, z: Tensor | None = None, index: int | BoundingBox | None = None, *args, **kwargs) None
Abstract logging method, the core functionality of a logger. Must be overwritten.
- Parameters:
global_step_num (int) – The global step number of for the mode of model fitting.
local_step_num (int) – The local step number of for the mode of model fitting.
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
- write_metric(key: str, value: SupportsFloat, step_num: int | None = None)
Write metric values to logging backends after calculation.
- class SSLStepLogger(task_name: str, n_batches: int, batch_size: int, input_size: tuple[int, int, int], output_size: tuple[int, int], record_int: bool = True, record_float: bool = False, writer: None | Run = None, model_type: str = '', **kwargs)
Logger designed for self-supervised learning.
- logs
Dictionary to hold these logged metrics:
batch_num
total_loss
total_correct
total_top5
avg_loss
avg_output_std
- collapse_level
Adds calculation and logging of the collapse level to the metrics. Only to be used with Siamese type models.
- Type:
- euclidean
Adds calculation and logging of the euclidean distance to the metrics. Only to be used with Siamese type models.
- Type:
- Parameters:
n_batches (int) – Number of batches in the epoch.
batch_size (int) – Size of the batch.
n_samples (int) – Total number of samples in the epoch.
n_classes (int) – Number of classes in dataset.
record_int (bool) – Optional; Whether to record the integer values from an epoch of model fitting. Defaults to
True
.record_float (bool) – Optional; Whether to record the floating point values from an epoch of model fitting. Defaults to
False
.writer (SummaryWriter | Run) – Optional; Writer object from
tensorboard
, awandb
Run
object orNone
.
Added in version 0.27.
- log(global_step_num: int, local_step_num: int, loss: Tensor, x: Tensor | None = None, y: Tensor | None = None, z: Tensor | None = None, index: int | BoundingBox | None = None, *args, **kwargs) None
Logs the outputs and results from a step of model fitting. Overwrites abstract method.
- 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 SupervisedStepLogger(task_name: str, n_batches: int, batch_size: int, input_size: tuple[int, int, int], output_size: tuple[int, int], record_int: bool = True, record_float: bool = False, writer: None | Run = None, model_type: str = '', n_classes: int | None = None, **kwargs)
Logger designed for supervised learning using
torchgeo
datasets.- logs
The main logs with these metrics:
batch_num
total_loss
total_correct
total_top5
- results
Hold these additional, full results from the KNN:
y
z
probs
ids
index
images
- calc_miou
Activates the calculating and logging of MIoU for segmentation models. Places the metric in the
total_miou
key oflogs
.- Type:
- Parameters:
n_batches (int) – Number of batches in the epoch.
batch_size (int) – Size of the batch.
n_samples (int) – Total number of samples in the epoch.
out_shape (int | tuple[int, ...]) – Shape of the model output.
n_classes (int) – Number of classes in dataset.
record_int (bool) – Optional; Whether to record the integer values from an epoch of model fitting. Defaults to
True
.record_float (bool) – Optional; Whether to record the floating point values from an epoch of model fitting. Defaults to
False
.writer (SummaryWriter | Run) – Optional; Writer object from
tensorboard
, awandb
Run
object orNone
.
- Raises:
MemoryError – If trying to allocate memory to hold the probabilites of predictions from the model exceeds capacity.
MemoryError – If trying to allocate memory to hold the bounding boxes of samples would exceed capacity.
Added in version 0.27.
- log(global_step_num: int, local_step_num: int, loss: Tensor, x: Tensor | None = None, y: Tensor | None = None, z: Tensor | None = None, index: int | BoundingBox | None = None, *args, **kwargs) None
Logs the outputs and results from a step of model fitting. Overwrites abstract method.
- 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