-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Closed
Labels
module: lossProblem is related to loss functionProblem is related to loss functionmodule: nnRelated to torch.nnRelated to torch.nntriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Description
🐛 Bug
When the forward pass of torch.nn.PoissonNLLLoss does not compute the same value as described in the documentation.
To Reproduce
Steps to reproduce the behavior:
import math
import torch
inp = 3.
target = 5.
nll_poisson_math = inp - target * math.log(inp) + math.log(math.factorial(target))
nll_poisson_stirling_math = inp - target * math.log(inp) + target * math.log(target) - target + 0.5 * math.log(2 * math.pi * target)
nll_poisson_loss = torch.nn.PoissonNLLLoss(log_input=False,
full=True,
size_average=None,
eps=0.,
reduce=None,
reduction='none')
inpTensor, targetTensor = torch.as_tensor([inp]), torch.as_tensor([target])
nll_poisson_pytorch = nll_poisson_loss(log_input=inpTensor, target=targetTensor)
print(nll_poisson_math, nll_poisson_stirling_math, nll_poisson_pytorch.item())
2.2944302994414967 2.2777856082516754 -2.4930615425109863
Environment
pytorch 1.3.0
Metadata
Metadata
Assignees
Labels
module: lossProblem is related to loss functionProblem is related to loss functionmodule: nnRelated to torch.nnRelated to torch.nntriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module