torch.nn.functional.nll_loss用法

2021-10-28  本文已影响0人  鼓鼓06

torch.nn.functional.nll_loss

torch.nn.functional.nll_loss(input, target, weight=None, size_average=None,
                                ignore_index=- 100, reduce=None, reduction='mean')

负对数似然损失

参数解释

Example

input = torch.randn(3,5,requires_grad=True)
target = torch.tensor([1, 0, 4])
output = F.nll_loss(F.log_softmax(input), target)
output.backward()

参考:

  1. https://pytorch.org/docs/stable/generated/torch.nn.functional.nll_loss.html?highlight=torch%20nn%20functional%20nll_loss#torch.nn.functional.nll_loss
  2. https://pytorch.org/docs/stable/nn.functional.html
上一篇 下一篇

猜你喜欢

热点阅读