From 8137dd9b5ed0cab202006e2b7d0ab6ff4bee34df Mon Sep 17 00:00:00 2001 From: wanghaox Date: Fri, 2 Feb 2018 16:53:33 +0800 Subject: [PATCH] update mine_hard_examples_op --- paddle/operators/mine_hard_examples_op.cc | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/paddle/operators/mine_hard_examples_op.cc b/paddle/operators/mine_hard_examples_op.cc index 2a3bd139ed2..051cc24706d 100644 --- a/paddle/operators/mine_hard_examples_op.cc +++ b/paddle/operators/mine_hard_examples_op.cc @@ -117,7 +117,7 @@ class MineHardExamplesKernel : public framework::OpKernel { std::vector neg_indices; std::transform(loss_idx.begin(), loss_idx.begin() + neg_sel, std::inserter(sel_indices, sel_indices.begin()), - [](std::pair l) -> int { + [](std::pair& l) -> int { return static_cast(l.second); }); @@ -134,12 +134,8 @@ class MineHardExamplesKernel : public framework::OpKernel { } } } else { - for (int m = 0; m < prior_num; ++m) { - if (match_indices(n, m) == -1 && - sel_indices.find(m) != sel_indices.end()) { - neg_indices.push_back(m); - } - } + neg_indices.resize(sel_indices.size()); + std::copy(sel_indices.begin(), sel_indices.end(), neg_indices.begin()); } all_neg_indices.push_back(neg_indices); -- GitLab