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_r223814212
 
 

 ##########
 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!})
+
+    `pred`, `target` can have arbitrary shape as long as they have the same 
number of elements.
+
+    Parameters
+    ----------
+    from_logits : boolean, default True
+        indicating whether log(predicted) value has already been computed. If 
True, the loss is computed as
+        :math:`\exp(\text{pred}) - \text{target} * \text{pred}`, and if False, 
then loss is computed as
+        :math:`\text{pred} - \text{target} * 
\log(\text{pred}+\text{epsislon})`.The default value
 
 Review comment:
   Yes the formulae are different. Following are some points:
   1)  The factorial term gets dropped in most calculations. However, there is 
a way to approximate it using Stirling factor/approximation. We can use 
**_compute_full_** flag to be set to True to incorporate this approximation in 
our loss value computation,
   2) from_logits flag set to true or false can render the formula to change 
depending upon the prediction is already logged ( log pred) or not.

----------------------------------------------------------------
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

Reply via email to