kaira.losses.image.FocalLoss

Inheritance diagram for FocalLoss
- class kaira.losses.image.FocalLoss(alpha=None, gamma=2.0, reduction='mean')[source]
Bases:
BaseLossFocal Loss Module for dealing with class imbalance.
This implementation works for both binary and multi-class problems. Focal loss addresses class imbalance by down-weighting well-classified examples, focusing training on difficult examples [Lin et al., 2017].
Methods
Initialize the FocalLoss module.
Forward pass through the FocalLoss module.
- forward(inputs: Tensor, targets: Tensor) Tensor[source]
Forward pass through the FocalLoss module.
- Parameters:
inputs (torch.Tensor) – The input logits tensor.
targets (torch.Tensor) – The target tensor.
- Returns:
The focal loss between the input and the target.
- Return type: