AttributeError: 'Accuracy' object has no attribute 'num'
Opened this issue · 1 comments
Deleted user commented
hi,can you help me address the problem?
run train.py
come across this wrong:AttributeError: 'Accuracy' object has no attribute 'num'
yangyangHu commented
The newest mx.metric.EvalMetric has no attribute 'num': https://mxnet.incubator.apache.org/_modules/mxnet/metric.html. The solve method: in center_loss.py, delete the 'num', for example:
define metric of accuracy
class Accuracy(mx.metric.EvalMetric):
def init(self):
super(Accuracy, self).init('accuracy')
def update(self, labels, preds):
mx.metric.check_label_shapes(labels, preds)
#if self.num is not None:
# assert len(labels) == self.num
pred_label = mx.nd.argmax_channel(preds[0]).asnumpy().astype('int32')
label = labels[0].asnumpy().astype('int32')
mx.metric.check_label_shapes(label, pred_label)
self.sum_metric += (pred_label.flat == label.flat).sum()
self.num_inst += len(pred_label.flat)