fhieber commented on a change in pull request #8027: Optional reshape of 
predictions in Perplexity metric
URL: https://github.com/apache/incubator-mxnet/pull/8027#discussion_r140966886
 
 

 ##########
 File path: python/mxnet/metric.py
 ##########
 @@ -646,9 +646,13 @@ def update(self, labels, preds):
         loss = 0.
         num = 0
         for label, pred in zip(labels, preds):
-            assert label.size == pred.size/pred.shape[-1], \
+            k = pred.shape[self.axis]
+            n = int(pred.size/k)
+            assert label.size == n, \
                 "shape mismatch: %s vs. %s"%(label.shape, pred.shape)
             label = label.as_in_context(pred.context).reshape((label.size,))
+            if len(pred.shape) > 2:
+                pred = pred.reshape((n, k))
 
 Review comment:
   I also realized this when making the change. I will try to make some time 
today to look into it, but I will be OOTO for the next 10 days after.
 
----------------------------------------------------------------
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