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

Commit

Permalink
fix acc metric shape miss match
Browse files Browse the repository at this point in the history
  • Loading branch information
roywei committed Apr 6, 2018
1 parent 590ec3f commit 4232318
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions python/mxnet/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,11 +417,14 @@ def update(self, labels, preds):
pred_label = ndarray.argmax(pred_label, axis=self.axis)
pred_label = pred_label.asnumpy().astype('int32')
label = label.asnumpy().astype('int32')
# flatten before checking shapes to avoid shape miss match
label = label.flat
pred_label = pred_label.flat

labels, preds = check_label_shapes(label, pred_label)

self.sum_metric += (pred_label.flat == label.flat).sum()
self.num_inst += len(pred_label.flat)
self.sum_metric += (pred_label == label).sum()
self.num_inst += len(pred_label)


@register
Expand Down

0 comments on commit 4232318

Please sign in to comment.