i m totally new to pytorch. I was taking an e-course and was experimenting with pytorch. So i came across the two loss functions(The hypothesis for using these two losses is numerical stability with logits):
nn.BCEWithLogitsLoss()
and
nn.BCELoss()
For appropriate adjustments to the code and these two loss functions, I had quite different accuracy curves! For example with nn.BCELoss() as the below code snippet:
model = nn.Sequential(
nn.Linear(D, 1),
nn.Sigmoid()
)
criterion = nn.BCELoss()
Accuracy plot was: enter image description here
And for nn.BCEWithLogitsLoss(), as below:
model = nn.Linear(D, 1)
criterion = nn.BCEWithLogitsLoss()
Accuracy plot was:enter image description here
The rest of the code is the same for both examples. (Note that, loss curves were similar and decent) The leaning curves for both snippets were something like this: enter image description here I couldn t figure out, what is causing this problem(if there is a bug in my code or something wrong with my pytorch. Thank you for your time, and help in advance.