How to implement focal loss in pytorch?

after some checking, the weighing terms (1-p)^gamma and p^gamma are back propagated as well. you can refer to:

https://github.com/zimenglan-sysu-512/paper-note/blob/master/focal_loss.pdf

3 Likes