Shortcuts

CrossEntropyLoss

class mmcls.models.CrossEntropyLoss(use_sigmoid=False, use_soft=False, reduction='mean', loss_weight=1.0, class_weight=None, pos_weight=None)[source]

Cross entropy loss.

Parameters
  • 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_sigmoid is True. Default None.

forward(cls_score, label, weight=None, avg_factor=None, reduction_override=None, **kwargs)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Read the Docs v: latest
Versions
master
latest
1.x
dev-1.x
Downloads
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.