I am a little confused by what a Loss function produces.
I was looking at this post: Multi Label Classification in pytorch - #45 by ptrblck
And tried to recreate it to understand the loss value calculated. So I constructed a perfect output for a given target:
from torch.nn.modules.loss import BCEWithLogitsLoss loss_function = BCEWithLogitsLoss() # Given are 2 classes output_tensor = Tensor([[0.0, 1.0]]) # Output of my nn target_tensor = Tensor([[0.0, 1.0]]) # Target result which is identical to output loss = loss_function(output_tensor, target_tensor) # Shouldn't this yield no loss at all? print(loss.item()) # Output: 0.5032044053077698
If I understand correctly, then this should yield a loss of
0.0, because the target is identical to the output.
But I get:
Did I miss something?
With best regards,