Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
revert acc changes (#9731)
Browse files Browse the repository at this point in the history
* Revert "avoid per-batch blocking in metric (#9636)"

This reverts commit 3fe694e.

* Revert "proper flatten in acc (#9619)"

This reverts commit ed823b2.

* Revert "use nd for accuracy calculation (#9583)"

This reverts commit f5f1b91.

* keep doc change
  • Loading branch information
szha authored and eric-haibin-lin committed Feb 7, 2018
1 parent c19f506 commit ad3f0d8
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions python/mxnet/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ad3f0d8

Please sign in to comment.