GOATmessi8/RFBNet

A probrem about the multibox_layer.py

Closed this issue · 0 comments

In mutliloss_layer.py, following codes seems to find the neg_sample with greater loss. But I found the line _, idx_rank = loss_idx.sort(1) is wrong and it may confus the mining result.

Hard Negative Mining

    loss_c[pos.view(-1, 1)] = 0  # filter out pos boxes for now
    loss_c = loss_c.view(num, -1)
    _, loss_idx = loss_c.sort(1, descending=True)
    _, idx_rank = loss_idx.sort(1)
    num_pos = pos.long().sum(1, keepdim=True)
    num_neg = torch.clamp(self.negpos_ratio * num_pos, max=pos.size(1) - 1)
    neg = idx_rank < num_neg.expand_as(idx_rank)

I wrote a toy example as follows:
屏幕快照 2019-07-11 上午11 13 56