label_relaxation_loss

probly.losses.torch.label_relaxation_loss(inputs: Tensor, targets: Tensor, *, alpha: float = 0.1) Tensor[source]

Label Relaxation Loss from [LHullermeier21].

This loss is used to improve the calibration of a neural network. It works by minimizing the Kullback-Leibler divergence between the predicted probabilities and the target distribution in the credal set defined by the alpha parameter. The target distribution is the distribution in the credal set that minimizes the Kullback-Leibler divergence from the predicted probabilities. If the predicted probability distribution is in the credal set, the loss is zero.

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

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

  • alpha – The parameter that controls the amount of label relaxation. Increasing alpha, increases the size of the credal set and thus the amount of label relaxation.

Returns:

The mean loss value.