class avalanche.logging.CSVLogger(log_folder=None)[source]

CSV logger.

The CSVLogger logs accuracy and loss metrics into a csv file. Metrics are logged separately for training and evaluation in files training_results.csv and eval_results.csv, respectively.


This Logger assumes that the user is evaluating on only one experience during training (see below for an example of a train call).

Trough the EvaluationPlugin, the user should monitor at least EpochAccuracy/Loss and ExperienceAccuracy/Loss. If monitored, the logger will also record Experience Forgetting. In order to monitor the performance on held-out experience associated to the current training experience, set eval_every=1 (or larger value) in the strategy constructor and pass the eval experience to the train method:

`for i, exp in enumerate(benchmark.train_stream):`
    `strategy.train(exp, eval_streams=[benchmark.test_stream[i]])`

The strategy.eval method should be called on the entire test stream for consistency, even if this is not strictly required.

When not provided, validation loss and validation accuracy will be logged as zero.

The training file header is composed of: training_exp_id, epoch, training_accuracy, val_accuracy, training_loss, val_loss.

The evaluation file header is composed of: eval_exp, training_exp, eval_accuracy, eval_loss, forgetting


Creates an instance of CSVLogger class.


log_folder – folder in which to create log files. If None, csvlogs folder in the default current directory will be used.



Creates an instance of CSVLogger class.

after_backward(strategy, *args, **kwargs)

Called after criterion.backward() by the BaseTemplate.

after_eval(strategy, *args, **kwargs)

Called after eval by the BaseTemplate.

after_eval_dataset_adaptation(strategy, ...)

Called after eval_dataset_adaptation by the BaseTemplate.

after_eval_exp(strategy, metric_values, **kwargs)

Called after eval_exp by the BaseTemplate.

after_eval_forward(strategy, *args, **kwargs)

Called after model.forward() by the BaseTemplate.

after_eval_iteration(strategy, *args, **kwargs)

Called after the end of an iteration by the BaseTemplate.

after_forward(strategy, *args, **kwargs)

Called after model.forward() by the BaseTemplate.

after_train_dataset_adaptation(strategy, ...)

Called after train_dataset_adapatation by the BaseTemplate.

after_training(strategy, metric_values, **kwargs)

Called after train by the BaseTemplate.

after_training_epoch(strategy, ...)

Called after train_epoch by the BaseTemplate.

after_training_exp(strategy, *args, **kwargs)

Called after train_exp by the BaseTemplate.

after_training_iteration(strategy, *args, ...)

Called after the end of a training iteration by the BaseTemplate.

after_update(strategy, *args, **kwargs)

Called after optimizer.update() by the BaseTemplate.

before_backward(strategy, *args, **kwargs)

Called before criterion.backward() by the BaseTemplate.

before_eval(strategy, metric_values, **kwargs)

Manage the case in which eval is first called before train

before_eval_dataset_adaptation(strategy, ...)

Called before eval_dataset_adaptation by the BaseTemplate.

before_eval_exp(strategy, *args, **kwargs)

Called before eval_exp by the BaseTemplate.

before_eval_forward(strategy, *args, **kwargs)

Called before model.forward() by the BaseTemplate.

before_eval_iteration(strategy, *args, **kwargs)

Called before the start of a training iteration by the BaseTemplate.

before_forward(strategy, *args, **kwargs)

Called before model.forward() by the BaseTemplate.

before_train_dataset_adaptation(strategy, ...)

Called before train_dataset_adapatation by the BaseTemplate.

before_training(strategy, metric_values, ...)

Called before train by the BaseTemplate.

before_training_epoch(strategy, *args, **kwargs)

Called before train_epoch by the BaseTemplate.

before_training_exp(strategy, metric_values, ...)

Called before train_exp by the BaseTemplate.

before_training_iteration(strategy, *args, ...)

Called before the start of a training iteration by the BaseTemplate.

before_update(strategy, *args, **kwargs)

Called before optimizer.update() by the BaseTemplate.



Receive a list of MetricValues to log.

log_single_metric(name, value, x_plot)

Log a metric value.

print_eval_metrics(eval_exp, training_exp, ...)

print_train_metrics(training_exp, epoch, ...)