nll_loss

dragon.losses.nll_loss(
  inputs,
  axis=1,
  ignore_index=None,
  reduction='valid',
  **kwargs
)[source]

Compute the negative likelihood loss with sparse labels.

The NLLLoss function is defined as:

\[\text{NLLLoss}(p_{t}) = -\log(p_{t}) \]
Parameters:
  • inputs (Sequence[dragon.Tensor]) – The tensor logit and label.
  • axis (int, optional, default=1) – The reduce axis, can be negative.
  • ignore_index (int, optional) – The label index to ignore.
  • reduction ({'none', 'sum', 'mean', 'valid'}, optional) – The reduction method.
Returns:

dragon.Tensor – The output tensor.