ConfidencePenaltyLoss#

class torch_uncertainty.losses.ConfidencePenaltyLoss(reg_weight=1, reduction='mean', eps=1e-06)[source]#

The Confidence Penalty Loss.

Parameters:
  • reg_weight (float, optional) – The weight of the regularization term.

  • reduction (str, optional) – specifies the reduction to apply to the output:'none' | 'mean' | 'sum'. Defaults to “mean”.

  • eps (float, optional) – A small value to avoid numerical instability. Defaults to 1e-6.

References

[1] Gabriel Pereyra: Regularizing neural networks by penalizing confident output distributions.

forward(logits, targets)[source]#

Compute the Confidence Penalty loss.

Parameters:
  • logits (Tensor) – The inputs of the Bayesian Neural Network

  • targets (Tensor) – The target values

Returns:

The Confidence Penalty loss

Return type:

Tensor