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

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, metric_values, **kwargs)

Called after criterion.backward() by the BaseStrategy.

after_eval(strategy, metric_values, **kwargs)

Called after eval by the BaseStrategy.

after_eval_dataset_adaptation(strategy, ...)

Called after eval_dataset_adaptation by the BaseStrategy.

after_eval_exp(strategy, metric_values, **kwargs)

Called after eval_exp by the BaseStrategy.

after_eval_forward(strategy, metric_values, ...)

Called after model.forward() by the BaseStrategy.

after_eval_iteration(strategy, ...)

Called after the end of an iteration by the BaseStrategy.

after_forward(strategy, metric_values, **kwargs)

Called after model.forward() by the BaseStrategy.

after_train_dataset_adaptation(strategy, ...)

Called after train_dataset_adapatation by the BaseStrategy.

after_training(strategy, metric_values, **kwargs)

Called after train by the BaseStrategy.

after_training_epoch(strategy, ...)

Called after train_epoch by the BaseStrategy.

after_training_exp(strategy, metric_values, ...)

Called after train_exp by the BaseStrategy.

after_training_iteration(strategy, ...)

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

after_update(strategy, metric_values, **kwargs)

Called after optimizer.update() by the BaseStrategy.

before_backward(strategy, metric_values, ...)

Called before criterion.backward() by the BaseStrategy.

before_eval(strategy, metric_values, **kwargs)

Manage the case in which eval is first called before train

before_eval_dataset_adaptation(*args, **kwargs)

Called before eval_dataset_adaptation by the BaseStrategy.

before_eval_exp(strategy, metric_values, ...)

Called before eval_exp by the BaseStrategy.

before_eval_forward(strategy, metric_values, ...)

Called before model.forward() by the BaseStrategy.

before_eval_iteration(strategy, ...)

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

before_forward(strategy, metric_values, **kwargs)

Called before model.forward() by the BaseStrategy.

before_train_dataset_adaptation(*args, **kwargs)

Called before train_dataset_adapatation by the BaseStrategy.

before_training(strategy, metric_values, ...)

Called before train by the BaseStrategy.

before_training_epoch(strategy, ...)

Called before train_epoch by the BaseStrategy.

before_training_exp(strategy, metric_values, ...)

Called before train_exp by the BaseStrategy.

before_training_iteration(strategy, ...)

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

before_update(strategy, metric_values, **kwargs)

Called before optimizer.update() by the BaseStrategy.


log_metric(metric_value, callback)

This method will be invoked on each callback.

log_single_metric(name, value, x_plot)

This abstract method will have to be implemented by each subclass.

print_eval_metrics(eval_exp, training_exp, ...)

print_train_metrics(training_exp, epoch, ...)