Shortcuts

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.

Reference:

Gabriel Pereyra: Regularizing neural networks by penalizing confident output distributions. https://arxiv.org/pdf/1701.06548.

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