DistributionNLLLoss#
- class torch_uncertainty.losses.DistributionNLLLoss(reduction='mean')[source]#
Negative Log-Likelihood loss using given distributions as inputs.
- Parameters:
reduction (
Optional[Literal['mean','sum']]) – Specifies the reduction to apply to the output. Must be one of'none','mean'or'sum'. Defaults to"mean".
- forward(dist, targets, padding_mask=None)[source]#
Compute the NLL of the targets given predicted distributions.
- Parameters:
dist (
Distribution) – The predicted distributions.targets (
Tensor) – The target values.padding_mask (
Tensor|None) – The padding mask. Sets the loss to0for padded values. Defaults toNone.
- Return type:
Tensor