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 2018/02/07 18:08:02 UTC
[GitHub] eric-haibin-lin closed pull request #9731: revert acc changes
eric-haibin-lin closed pull request #9731: revert acc changes
URL: https://github.com/apache/incubator-mxnet/pull/9731
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/python/mxnet/metric.py b/python/mxnet/metric.py
index e91fd3b13e..8bb3f6ee0a 100644
--- a/python/mxnet/metric.py
+++ b/python/mxnet/metric.py
@@ -28,7 +28,6 @@
from .base import numeric_types, string_types
from . import ndarray
from . import registry
-from .context import cpu
def check_label_shapes(labels, preds, shape=0):
@@ -389,22 +388,16 @@ def update(self, labels, preds):
"""
check_label_shapes(labels, preds)
- results = []
for label, pred_label in zip(labels, preds):
if pred_label.shape != label.shape:
pred_label = ndarray.argmax(pred_label, axis=self.axis)
- pred_label = pred_label.astype('int32')
- label = label.astype('int32')
+ pred_label = pred_label.asnumpy().astype('int32')
+ label = label.asnumpy().astype('int32')
check_label_shapes(label, pred_label)
- if pred_label.context != label.context:
- pred_label = pred_label.as_in_context(label.context)
-
- self.num_inst += pred_label.size
- results.append((pred_label.reshape((-1,)) == label.reshape((-1,)))
- .sum().as_in_context(cpu()))
- self.sum_metric += ndarray.add_n(*results).asscalar()
+ self.sum_metric += (pred_label.flat == label.flat).sum()
+ self.num_inst += len(pred_label.flat)
@register
----------------------------------------------------------------
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