LOGGERS#

This module contains the Logger class and related functions for logging accuracy values and other metrics.

Classes#

class utils.loggers.Logger(args, setting_str, dataset_str, model_str)[source]#

Bases: object

add_bwt(results, results_mask_classes)[source]#

Adds backward transfer values.

Parameters:
  • results – The results.

  • results_mask_classes – The results for masked classes.

add_forgetting(results, results_mask_classes)[source]#

Adds forgetting values.

Parameters:
  • results – The results.

  • results_mask_classes – The results for masked classes.

add_fwt(results, accs, results_mask_classes, accs_mask_classes)[source]#

Adds forward transfer values.

Parameters:
  • results – The results.

  • accs – The accuracy values.

  • results_mask_classes – The results for masked classes.

  • accs_mask_classes – The accuracy values for masked classes.

dump()[source]#

Dumps the state of the logger in a dictionary.

Returns:

A dictionary containing the logged values.

load(dic)[source]#

Loads the state of the logger from a dictionary.

Parameters:

dic – The dictionary containing the logged values.

log(mean_acc)[source]#

Logs a mean accuracy value.

Parameters:

mean_acc (ndarray) – mean accuracy value

log_fullacc(accs)[source]#

Logs all the accuracy of the classes from the current and past tasks.

Parameters:

accs – the accuracy values

log_system_stats(cpu_res, gpu_res)[source]#

Logs the system stats. Supported only if the psutil and torch libraries are installed.

Parameters:
  • cpu_res – the CPU memory usage

  • gpu_res – the GPU memory usage

rewind(num)[source]#

Rewinds the logger by a given number of values.

Parameters:

num – The number of values to rewind.

write(args)[source]#

Writes out the logged value along with its arguments in the default path (data/results). The default path can be changed with the –results_path argument.

Parameters:

args (Dict[str, Any]) – the namespace of the current experiment

Functions#

utils.loggers.log_accs(args, logger, accs, t, setting, epoch=None, prefix='RESULT', future=False)[source]#

Logs the accuracy values and other metrics.

All metrics are prefixed with prefix to be logged on wandb.

Parameters:
  • args – The arguments for logging.

  • logger – The Logger object.

  • accs – The accuracy values.

  • t (int) – The task index.

  • setting (str) – The setting of the benchmark (e.g., class-il).

  • epoch – The epoch number (optional).

  • prefix – The prefix for the metrics (default=”RESULT”).

utils.loggers.log_extra_metrics(args, metric, metric_mask_class, metric_name, t, prefix='RESULT')[source]#

Logs the accuracy values and other metrics.

All metrics are prefixed with prefix to be logged on wandb.

Parameters:
  • args – The arguments for logging.

  • metric (float) – Class-IL version of the metric metric_name.

  • metric_mask_class (float) – Task-IL version of the metric metric_name.

  • metric_name (str) – The name of the metric.

  • t (int) – The task index.

  • epoch – The epoch number (optional).

  • prefix – The prefix for the metrics (default=”RESULT”).

utils.loggers.print_mean_accuracy(accs, task_number, setting, joint=False, epoch=None, future=False)[source]#

Prints the mean accuracy on stderr.

Parameters:
  • accs (ndarray) – accuracy values per task

  • task_number (int) – task index

  • setting (str) – the setting of the benchmark

  • joint – whether it’s joint accuracy or not

  • epoch – the epoch number (optional)

Returns:

The mean accuracy value.

Return type:

None