leezu commented on a change in pull request #18083:
URL: https://github.com/apache/incubator-mxnet/pull/18083#discussion_r414921455
##########
File path: python/mxnet/gluon/metric.py
##########
@@ -617,92 +585,102 @@ def update_binary_stats(self, label, pred):
pred : `NDArray`
Predicted values.
"""
- pred = pred.asnumpy()
- label = label.asnumpy().astype('int32')
- pred_label = numpy.argmax(pred, axis=1)
-
- check_label_shapes(label, pred)
- if len(numpy.unique(label)) > 2:
- raise ValueError("%s currently only supports binary
classification."
- % self.__class__.__name__)
+ pred = pred.as_np_ndarray()
+ label = label.as_np_ndarray().astype('int32')
+ if self.class_type == "binary":
+ self._set(1)
+ if len(numpy.unique(label)) > 2:
Review comment:
This will trigger synchronization (as we need to wait for the result of
the np.unique operator). Could we make error checking that triggers
synchronization optional?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]