-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Support single array input for metric #9930
Conversation
@@ -793,6 +793,8 @@ def update(self, labels, preds): | |||
|
|||
if len(label.shape) == 1: | |||
label = label.reshape(label.shape[0], 1) | |||
if len(pred.shape) == 1: | |||
pred = pred.reshape(pred.shape[0], 1) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can also revise the check_label_shapes
above to be check_label_shapes(labels, preds, 1)
to force the labels and preds have the same shape. Currently the default behavior is to just match the ndim
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to set shape=0
by default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure. I think shape=1 is more suitable to be the default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@piiswrong can we have your input?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the check_label_shapes function should be redesigned.
- it should test if labels is a single NDArray instead of a list, and wrap it with a list
labels=[labels]
- 0/1 is not pythonic. Use boolean switches
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we check both length and shape? I assume they shoud always match.
when labels and preds are NDArray instead of list NDArray, the for loop is superfluous |
@piiswrong The for loop is fixed. |
Hi, the community has passed to vote about associating the code changes with JIRA (https://lists.apache.org/thread.html/ab22cf0e35f1bce2c3bf3bec2bc5b85a9583a3fe7fd56ba1bbade55f@%3Cdev.mxnet.apache.org%3E) We have updated the guidelines for contributors in https://cwiki.apache.org/confluence/display/MXNET/Development+Process, please ensure that you have created a JIRA at https://issues.apache.org/jira/projects/MXNET/issues/ to describe your work in this pull request and include the JIRA title in your PR as [MXNET-xxxx] your title where MXNET-xxxx is the JIRA id Thanks! |
* fix apache#9865 * add unittest * fix format * fix format * fix superfluous loop in metric * fix lint
* fix apache#9865 * add unittest * fix format * fix format * fix superfluous loop in metric * fix lint
* fix apache#9865 * add unittest * fix format * fix format * fix superfluous loop in metric * fix lint
Description
Fix #9865 by reshaping both
label
andpred
.Checklist
Essentials
make lint
)Changes
Comments