NLLLoss¶
- class dragon.vm.torch.nn.NLLLoss(
 weight=None,
 size_average=None,
 ignore_index=None,
 reduce=None,
 reduction='mean'
 )[source]¶
- Compute the negative likelihood loss. - The NLL loss function is defined as: \[\text{NLLLoss}(p_{t}) = -\log(p_{t}) \]- Examples: - m1 = torch.nn.LogSoftmax(dim=1) m2 = torch.nn.NLLLoss() loss = m2(m1(torch.randn(2, 2)), torch.tensor([0, 1])) - See also 
__init__¶
- NLLLoss.- __init__(
 weight=None,
 size_average=None,
 ignore_index=None,
 reduce=None,
 reduction='mean'
 )[source]¶
- Create a - NLLLossmodule.- Parameters:
- weight (dragon.vm.torch.Tensor, optional) – The weight for each class.
- size_average (bool, optional) – Trueto set thereductionto ‘mean’.
- ignore_index (int, optional) – The ignored value of target.
- reduce (bool, optional) – Trueto set thereductionto ‘sum’ or ‘mean’.
- reduction ({'none', 'mean', 'sum', 'valid'}, optional) – The reduce method.
 
 
