loss_kaggle_2018
loss_kaggle_2018 copied to clipboard
the focal loss doesn't feel right
# 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.
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.