KFrank:

Hi Bruno!
I do see what appears to be an error in your conversion from a
multi-class to a binary model (although I can’t explain the entirety
of your results).
Specifically, I believe your use of argmax() to convert your probabilistic
predictions into “hard” yes-no binary predictions is incorrect, and will
always yield 0.


Thank you for the answer, I think you are right.
Obviously when I create the model the number of classes is =1, as you said. I changed the loss from BCELoss to BCEWithLogitsLoss, and I removed Sigmoid, following your advice.
My loaders are these:
# Define dictionary of loaders
loaders = {"train": train_loader,
           "val": val_loader,
           "test": test_loader}

I don’t know that change in batch_size changed the results…
However, what do you suggest?
Do you think is correct writing this?
pred_labels = pred.argmax(1)+1

Edit: no, this solution I proposed is wrong, in this way I will obtain always 1. I don’t know how can I fix…
Can I just remove argmax/max and use simply the output?