ConflictualLoss#

class torch_uncertainty.losses.ConflictualLoss(reg_weight=1, reduction='mean')[source]#

The Conflictual Loss.

Combines the standard cross-entropy with a conflictual regulariser that encourages the model to assign non-negligible probability to a uniformly random class \(c^\star\):

\[\mathcal{L} = \text{CE}(\mathbf{z}, y) - \lambda \log p_{c^\star}, \quad c^\star \sim \mathrm{Uniform}(1, C).\]

This counteracts the natural tendency of cross-entropy to collapse all probability mass on a single class and improves the calibration of epistemic uncertainty estimates.

Parameters:
  • reg_weight (float) – The weight \(\lambda\) of the regularization term.

  • reduction (str | None) – Specifies the reduction to apply to the output: 'none' | 'mean' | 'sum'.

References

[1] Fellaji, M., et al. (2024). On the Calibration of Epistemic Uncertainty: Principles, Paradoxes and Conflictual Loss.

forward(logits, targets)[source]#

Compute the conflictual loss.

Parameters:
  • logits (Tensor) – The outputs of the model.

  • targets (Tensor) – The target values.

Returns:

The conflictual loss.

Return type:

Tensor