未验证 提交 cc9028b9 编写于 作者: T tangwei12 提交者: GitHub

cherry-pick enforce for auc (#14687) (#14694)

* add enforce for AUC,  test=release/1.2
上级 fa6c2b53
...@@ -75,8 +75,13 @@ class AucKernel : public framework::OpKernel<T> { ...@@ -75,8 +75,13 @@ class AucKernel : public framework::OpKernel<T> {
const auto *label_data = label->data<int64_t>(); const auto *label_data = label->data<int64_t>();
for (size_t i = 0; i < batch_size; i++) { for (size_t i = 0; i < batch_size; i++) {
uint32_t binIdx = static_cast<uint32_t>( auto predict_data = inference_data[i * inference_width + 1];
inference_data[i * inference_width + 1] * num_thresholds); PADDLE_ENFORCE_LE(predict_data, 1,
"The predict data must less or equal 1.");
PADDLE_ENFORCE_GE(predict_data, 0,
"The predict data must gather or equal 0.");
uint32_t binIdx = static_cast<uint32_t>(predict_data * num_thresholds);
if (label_data[i]) { if (label_data[i]) {
(*stat_pos)[binIdx] += 1.0; (*stat_pos)[binIdx] += 1.0;
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册