You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2017/11/03 00:26:31 UTC

[GitHub] szha closed pull request #7118: wrong definition of cross entropy in make_loss

szha closed pull request #7118: wrong definition of cross entropy in make_loss
URL: https://github.com/apache/incubator-mxnet/pull/7118
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/operator/make_loss.cc b/src/operator/make_loss.cc
index 1be93def5e..6f45ff3ec8 100644
--- a/src/operator/make_loss.cc
+++ b/src/operator/make_loss.cc
@@ -37,7 +37,7 @@ The output of this function is the gradient of loss with respect to the input da
 For example, if you are a making a cross entropy loss function. Assume ``out`` is the
 predicted output and ``label`` is the true label, then the cross entropy can be defined as::
 
-  cross_entropy = label * log(out) + (1 - label) * log(1 - out)
+  cross_entropy = -mean(label * log(out) + (1 - label) * log(1 - out))
   loss = MakeLoss(cross_entropy)
 
 We will need to use ``MakeLoss`` when we are creating our own loss function or we want to


 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services