Negative learning implementation in pytorch I have read a paper on Negative Learning: https://arxiv.org/abs/1908.07387.
The idea is that you can train a network not only by telling what label of the sample is, but by telling what it surely is not.
Let's call the latter a &quot;negative&quot; label.
An excerpt from the paper says (top formula is for usual &quot;positive&quot; label loss (PL), bottom - for &quot;negative&quot; label loss (NL):

I have a problem where &quot;negative&quot; labels collection is much easier than labeling each sample. So it is tempting to use it.
Is there some implementation of such a loss function in pytorch? Or should I write a custom loss layer code? If so, how should I do it?
One implementation is
( (loss+loss_neg) / (float((labels&gt;=0).sum())+float((labels_neg[:,0]&gt;=0).sum())) ).backward()

from NLNL-Negative-Learning-for-Noisy-Labels GitHub repo.