Hey everyone, in the lectures Jeremy said that the binary_cross_entropy function and the function
returned by nn.BCEWithLogitsLoss have the same implementation, but when invoking them I am getting different results. Has there been a change in the BCEWithLogitsLoss implementation or am I misunderstanding something?
Nice job on trying to reimplement BCE to understand the inner workings of the loss function. In your definition, in the torch.where clause, you need to either do targets == 0
for your code to work or you can change the conditionals to inputs, 1-inputs
instead of vice-versa and then the two outputs should match.
Hope this helps,
Thanks!
3 Likes
Hey @ElisonSherton, I am very grateful to you for responding to this. I already gave up hope. I’ll try out what you suggested!
1 Like
Thanks, that really helps to clear things up for me too
1 Like