avalanche.training.MaskedCrossEntropy
- class avalanche.training.MaskedCrossEntropy(classes=None, mask='seen', reduction='mean')[source]
Masked Cross Entropy
This criterion can be used for instance in Class Incremental Learning Problems when no examplars are used (i.e LwF in Class Incremental Learning would need to use mask=”new”).
- __init__(classes=None, mask='seen', reduction='mean')[source]
param: classes: Initial value for current classes param: mask: “all” normal cross entropy, uses all the classes seen so far
“old” cross entropy only on the old classes “new” cross entropy only on the new classes
param: reduction: “mean” or “none”, average or per-sample loss
Methods
__init__
([classes, mask, reduction])param: classes: Initial value for current classes param: mask: "all" normal cross entropy, uses all the classes seen so far "old" cross entropy only on the old classes "new" cross entropy only on the new classes param: reduction: "mean" or "none", average or per-sample loss
adaptation
(new_classes)Warning: Deprecated (removal in version 0.7: Please switch to the pre_adapt`or `_adaptation methods.)
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, *args, **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, *args, **kwargs)Called after train by the BaseTemplate.
after_training_epoch
(strategy, *args, **kwargs)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, *args, **kwargs)Called before eval by the BaseTemplate.
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, *args, **kwargs)Called before train by the BaseTemplate.
before_training_epoch
(strategy, *args, **kwargs)Called before train_epoch by the BaseTemplate.
before_training_exp
(strategy, **kwargs)Warning: Deprecated (removal in version 0.7: Please switch to the pre_adapt method.)
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.
current_mask
(logit_shape)pre_adapt
(agent, exp)Attributes
supports_distributed
A flag describing whether this plugin supports distributed training.