class avalanche.logging.TextLogger(file=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)[source]

The TextLogger class provides logging facilities printed to a user specified file. The logger writes metric results after each training epoch, evaluation experience and at the end of the entire evaluation stream.


To avoid an excessive amount of printed lines, this logger will not print results after each iteration. If the user is monitoring metrics which emit results after each minibatch (e.g., MinibatchAccuracy), only the last recorded value of such metrics will be reported at the end of the epoch.


Since this logger works on the standard output, metrics producing images or more complex visualizations will be converted to a textual format suitable for console printing. You may want to add more loggers to your EvaluationPlugin to better support different formats.

__init__(file=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)[source]

Creates an instance of TextLogger class.


file – destination file to which print metrics (default=sys.stdout).



Creates an instance of TextLogger 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)

Called before eval by the BaseStrategy.

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.