nll_loss

dragon.vm.torch.nn.functional.nll_loss(
  input,
  target,
  weight=None,
  size_average=None,
  ignore_index=None,
  reduce=None,
  reduction='mean'
)[source]

Compute the negative likelihood loss with sparse labels.

The NLLLoss function is defined as:

\[\text{NLLLoss}(p_{t}) = -\log(p_{t}) \]
Parameters:
  • input (dragon.vm.torch.Tensor) – The input tensor.
  • target (dragon.vm.torch.Tensor) – The target tensor.
  • weight (dragon.vm.torch.Tensor, optional) – The weight for each class.
  • size_average (bool, optional) – Whether to average the loss.
  • ignore_index (int, optional) – The label index to ignore.
  • reduce (bool, optional) – Whether to reduce the loss.
  • reduction ({'none', 'mean', 'sum', 'valid'}, optional) – The reduce method.
Returns:

dragon.vm.torch.Tensor – The loss.