loss_kaggle_2018 icon indicating copy to clipboard operation
loss_kaggle_2018 copied to clipboard

the focal loss doesn't feel right

Open XushengLee opened this issue 5 years ago • 1 comments

# This formula gives us the log sigmoid of 1-p if y is 0 and of p if y is 1
invprobs = F.logsigmoid(-input * (target * 2 - 1))

when target=0, invprobs=input, and when target=1, invprobes=-input. These should be values of (1-input) and input according to the formula. But I'm not sure, please tell me where I miss if I'm wrong.

XushengLee avatar Aug 05 '19 10:08 XushengLee

invprobs = torch.log((1-target) + torch.sigmoid(input) * (target * 2 -1)) I change it to this and it works well both on train and val set.

XushengLee avatar Aug 05 '19 11:08 XushengLee