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 committed Feb 7, 2018
1 parent 8cc5e97 commit 4878fde
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions python/mxnet/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,16 +391,13 @@ def update(self, labels, preds):
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.sum_metric += (pred_label.flatten() == label.flatten()).sum().asscalar()
self.num_inst += numpy.prod(pred_label.shape)
self.sum_metric += (pred_label.flat == label.flat).sum()
self.num_inst += len(pred_label.flat)


@register
Expand Down

0 comments on commit 4878fde

Please sign in to comment.