备注
您正在阅读 MMClassification 0.x 版本的文档。MMClassification 0.x 会在 2022 年末被切换为次要分支。建议您升级到 MMClassification 1.0 版本,体验更多新特性和新功能。请查阅 MMClassification 1.0 的安装教程、迁移教程以及更新日志。
mmcls.models.CrossEntropyLoss¶
- 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_sigmoid
is True. Default None.