DistributionNLL¶
- class torch_uncertainty.metrics.regression.DistributionNLL(reduction='mean', **kwargs)[source]¶
The Negative Log Likelihood Metric.
- 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'
orNone
: Returns score per sample
kwargs – Additional keyword arguments, see Advanced metric settings.
- Inputs:
probs
: \((B, C)\)target
: \((B)\)
where \(B\) is the batch size and \(C\) is the number of classes.
Warning
Make sure that the probabilities in
probs
are normalized to sum to one.- Raises:
ValueError – If
reduction
is not one of'mean'
,'sum'
,'none'
orNone
.
- update(dist, target, padding_mask=None)[source]¶
Update state with the predicted distributions and the targets.
- Parameters:
dist (torch.distributions.Distribution) – Predicted distributions.
target (Tensor) – Ground truth labels.
padding_mask (Tensor, optional) – The padding mask. Defaults to None. Sets the loss to 0 for padded values.