Logger¶
- class daart.train.Logger(n_datasets: int = 1, save_path: str | None = None)[source]¶
Bases:
objectBase class for logging loss metrics.
Loss metrics are tracked for the aggregate dataset (potentially spanning multiple datasets) as well as dataset-specific metrics for easier downstream plotting.
Methods Summary
create_metric_row(dtype, epoch, batch, ...)Export metrics and other data (e.g.
get_loss(dtype)Return loss aggregated over all datasets.
reset_metrics(dtype)Reset all metrics.
update_metrics(dtype, loss_dict[, dataset, ...])Update metrics for a specific dtype/dataset.
Methods Documentation
- create_metric_row(dtype: str, epoch: int, batch: int, dataset: int, trial: int | None, best_epoch: int | None = None, by_dataset: bool = False) dict[source]¶
Export metrics and other data (e.g. epoch) for logging train progress.
- Parameters:
dtype (str) – ‘train’ | ‘val’ | ‘test’
epoch (int) – current training epoch
batch (int) – current training batch
dataset (int) – dataset id for current batch
trial (int or NoneType) – trial id within the current dataset
best_epoch (int, optional) – best current training epoch
by_dataset (bool, optional) – True to return metrics for a specific dataset, False to return metrics aggregated over multiple datasets
- Returns:
aggregated metrics for current epoch/batch
- Return type:
dict
- get_loss(dtype: str) float[source]¶
Return loss aggregated over all datasets.
- Parameters:
dtype (str) – datatype to calculate loss for (e.g. ‘train’, ‘val’, ‘test’)
- Return type:
float
- reset_metrics(dtype: str)[source]¶
Reset all metrics.
- Parameters:
dtype (str) – datatype to reset metrics for (e.g. ‘train’, ‘val’, ‘test’)
- update_metrics(dtype: str, loss_dict: dict, dataset: int | list | None = None, batches: int = 1) None[source]¶
Update metrics for a specific dtype/dataset.
- Parameters:
dtype (str) – dataset type to update metrics for (e.g. ‘train’, ‘val’, ‘test’)
loss_dict (dict) – key-value pairs correspond to all quantities that should be logged throughout training; dictionary returned by loss attribute of models
dataset (int or NoneType, optional) – if NoneType, updates the aggregated metrics; if int, updates the associated dataset
batches (int, optional) – number of sequences in batch