MaskedSquareDiceLoss¶
- class mmocr.models.common.MaskedSquareDiceLoss(eps=0.001)[source]¶
Masked square dice loss.
- Parameters
eps (float, optional) – Eps to avoid zero-divison error. Defaults to 1e-3.
- Return type
- forward(pred, gt, mask=None)[source]¶
Forward function.
- Parameters
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.
- Returns
The loss value.
- Return type