You are reading the documentation for MMClassification 0.x, which will soon be deprecated at the end of 2022. We recommend you upgrade to MMClassification 1.0 to enjoy fruitful new features and better performance brought by OpenMMLab 2.0. Check the installation tutorial, migration tutorial and changelog for more details.
- class mmcls.models.CrossEntropyLoss(use_sigmoid=False, use_soft=False, reduction='mean', loss_weight=1.0, class_weight=None, pos_weight=None)¶
Cross entropy loss.
use_sigmoid (bool) – Whether the prediction uses sigmoid of softmax. Defaults to False.
use_soft (bool) – Whether to use the soft version of CrossEntropyLoss. Defaults to False.
reduction (str) – The method used to reduce the loss. Options are “none”, “mean” and “sum”. Defaults to ‘mean’.
loss_weight (float) – Weight of the loss. Defaults to 1.0.
class_weight (List[float], optional) – The weight for each class with shape (C), C is the number of classes. Default None.
pos_weight (List[float], optional) – The positive weight for each class with shape (C), C is the number of classes. Only enabled in BCE loss when
use_sigmoidis True. Default None.
- forward(cls_score, label, weight=None, avg_factor=None, reduction_override=None, **kwargs)¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.