MaskedBCEWithLogitsLoss¶
- class mmocr.models.common.MaskedBCEWithLogitsLoss(eps=1e-06)[源代码]¶
This loss combines a Sigmoid layers and a masked BCE loss in one single class. It’s AMP-eligible.
- forward(pred, gt, mask=None)[源代码]¶
Forward function.
- 参数
pred (torch.Tensor) – The prediction in any shape.
gt (torch.Tensor) – The learning target of the prediction in the same shape as pred.
mask (torch.Tensor, optional) – Binary mask in the same shape of pred, indicating positive regions to calculate the loss. Whole region will be taken into account if not provided. Defaults to None.
- 返回
The loss value.
- 返回类型