Why does my CNN for a Binary Classification problem have a constant 50% accuracy with BCELoss vs 80%+ with Cross Entropy Loss?
I am creating a CNN from scratch with Pytorch. I have a balanced dataset of images, split in half for both classes. I am trying to use the BCEwithLogitsLoss function from torch.nn as I have read that is typically the best for use-cases like mine. However, for some reason it seems like my network does not learn anything at all when I use this loss function! It remains at a stagnant ~50% accuracy where it is only ever guessing one class. When I use the regular CrossEntropyLoss function instead and expand my final layer’s output nodes to 2, my network actually begins learning! Whereas with the “correct” loss function my network doesn’t ever reach even 1% accuracy for the target class, using Cross Entropy Loss I can reach even 90%+ after a few epochs.