focal_loss

probly.losses.torch.focal_loss(inputs: Tensor, targets: Tensor, *, alpha: float = 1, gamma: float = 2) Tensor[source]

Focal Loss based on [LGG+17].

Parameters:
  • inputs – Logits of size (n_instances, n_classes).

  • targets – Class labels of size (n_instances,).

  • alpha – Control importance of minority class.

  • gamma – Control loss for hard instances.

Returns:

The mean loss value.