未验证 提交 e24575c8 编写于 作者: L Liufang Sang 提交者: GitHub

fix error message in accuracy_op.h test=develop (#24416)

上级 f9a4f9f4
...@@ -50,7 +50,11 @@ class AccuracyKernel : public framework::OpKernel<T> { ...@@ -50,7 +50,11 @@ class AccuracyKernel : public framework::OpKernel<T> {
int num_correct = 0; int num_correct = 0;
// assume inference is already the topk of the output // assume inference is already the topk of the output
for (size_t i = 0; i < num_samples; ++i) { for (size_t i = 0; i < num_samples; ++i) {
PADDLE_ENFORCE_GE(label_data[i], 0, "label must >= 0"); PADDLE_ENFORCE_GE(
label_data[i], 0,
platform::errors::InvalidArgument(
"label of AccuracyOp must >= 0, But received label[%d] is %d", i,
label_data[i]));
for (size_t j = 0; j < class_dim; ++j) { for (size_t j = 0; j < class_dim; ++j) {
if (indices_data[i * class_dim + j] == label_data[i]) { if (indices_data[i * class_dim + j] == label_data[i]) {
++num_correct; ++num_correct;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册