AdrienLE / loss_kaggle_2018

Investigation of focal and dice loss for the Kaggle 2018 data science bowl.
19 stars 11 forks source link

the focal loss doesn't feel right #2

Open XushengLee opened 5 years ago

XushengLee commented 5 years ago
# 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 commented 5 years ago

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.