Shortcuts

FocalLoss

class torch_uncertainty.losses.FocalLoss(gamma, alpha=None, reduction='mean')[source]

Focal-Loss for classification tasks.

Parameters:
  • gamma (float, optional) – A constant, as described in the paper.

  • alpha (Tensor, optional) – Weights for each class. Defaults to None.

  • reduction (str, optional) – ‘mean’, ‘sum’ or ‘none’. Defaults to ‘mean’.

Reference:

Lin, T.-Y., Goyal, P., Girshick, R., He, K., & Dollár, P. (2017). Focal Loss for Dense Object Detection. TPAMI 2020.

Implementation:

Inspired by github.com/AdeelH/pytorch-multi-class-focal-loss.