yzhliu closed pull request #8245: Use argmax instead of argmax_channel in 
Accuracy to keep dimention
URL: https://github.com/apache/incubator-mxnet/pull/8245
 
 
   

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/scala-package/core/src/main/scala/ml/dmlc/mxnet/EvalMetric.scala 
b/scala-package/core/src/main/scala/ml/dmlc/mxnet/EvalMetric.scala
index 98a09d2250..ed99a1f90e 100644
--- a/scala-package/core/src/main/scala/ml/dmlc/mxnet/EvalMetric.scala
+++ b/scala-package/core/src/main/scala/ml/dmlc/mxnet/EvalMetric.scala
@@ -107,7 +107,11 @@ class Accuracy extends EvalMetric("accuracy") {
       "labels and predictions should have the same length.")
 
     for ((pred, label) <- preds zip labels) {
-      val predLabel = NDArray.argmax_channel(pred)
+      val predLabel = if (pred.shape == label.shape) {
+        NDArray.argmax(Map("axis" -> 1, "keepdims" -> true))(pred)
+      } else {
+        NDArray.argmax_channel(pred)
+      }
       require(label.shape == predLabel.shape,
         s"label ${label.shape} and prediction ${predLabel.shape}" +
         s"should have the same length.")


 

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


With regards,
Apache Git Services

Reply via email to