Online Hard Example Mining

How can I do online Hard example Mining?

I compute loss for the whole batch, then compute the squared distances between prediction and target and sort them with topK.

But How could i use the loss.backward() but only for specific indexes? how to implement it in Pytorch?

Have a look at this repository. They have implemented an online loss function that uses a pair selector to find the indices of the examples which are hard and then uses those losses to do a loss.backward()

1 Like