I am trying custom the binary cross entropy loss from the paper by Pytroch, but I meet some problems here. I am not sure how can I use Pytorch here to get the target y when I let predict label (sigmoid(input)) == 1. Can someone help me with that? Or is there any method we can get the matched target value like the numpy or list used index function? The modified cross entropy used here:
loss1 = (t/(t+1)) * cross_entropy (only when predicted label==1)
loss2 = (1/(t+1)) * cross_entropy (only when predicted label==0)
total loss = loss1 + loss2```
which is to say, cross_entropy for loss1 is log(P(predicted label==1|x_i, theta)) * target_y(when predicted label == 1)