Shortcuts

Entropy

class torch_uncertainty.metrics.Entropy(reduction='mean', **kwargs)[source]

The Shannon Entropy Metric to estimate the confidence of a single model or the mean confidence across estimators.

Parameters:
  • reduction (str, optional) –

    Determines how to reduce over the \(B\)/batch dimension:

    • 'mean' [default]: Averages score across samples

    • 'sum': Sum score across samples

    • 'none' or None: Returns score per sample

  • kwargs – Additional keyword arguments, see Advanced metric settings.

Inputs:
  • probs: \((B, C)\) or \((B, N, C)\)

where \(B\) is the batch size, \(C\) is the number of classes and \(N\) is the number of estimators.

Note

A higher entropy means a lower confidence.

Raises:

ValueError – If reduction is not one of 'mean', 'sum', 'none' or None.

compute()[source]

Computes Entropy based on inputs passed in to update previously.

update(probs)[source]

Update the current entropy with a new tensor of probabilities.

Parameters:

probs (torch.Tensor) – Probabilities from the model.