gaurav-gireesh commented on a change in pull request #12697: [MXNET -1004]
Poisson NegativeLog Likelihood loss
URL: https://github.com/apache/incubator-mxnet/pull/12697#discussion_r223801145
##########
File path: python/mxnet/gluon/loss.py
##########
@@ -706,3 +707,65 @@ def hybrid_forward(self, F, pred, positive, negative):
axis=self._batch_axis, exclude=True)
loss = F.relu(loss + self._margin)
return _apply_weighting(F, loss, self._weight, None)
+
+
+class PoissonNLLLoss(Loss):
+ r"""For a target (Random Variable) in a Poisson distribution, the function
calculates the Negative
+ Log likelihood loss.
+ PoissonNLLLoss measures the loss accrued from a poisson regression
prediction made by the model.
+
+ .. math::
+ L = \text{pred} - \text{target} * \log(\text{pred})
+\log(\text{target!})
Review comment:
@anirudhacharya The "!" is for factorial of the target value. The formula to
calculate the probability of the target value with the mean of the poisson
distribution contains a factorial term in the denominator which is approximated
by computing the Stirling approximation. Taking a log of the formula reduces to
the form mentioned in the documentation.
Some wikipedia pages that I have found helpful are:
[Poisson regression](https://en.wikipedia.org/wiki/Poisson_regression) and
[Poisson distribution](https://en.wikipedia.org/wiki/Poisson_distribution).
Also, I have attached a link for reference to PyTorch's implementation of
the loss function in the description of the PR.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services