-
Most likely your model is predicting the majority class only, so I guess it’s predicting the
Falseclass. You can check it by printing the unique predictions for the datasets. -
You could use
nn.BCEWithLogitsLoss, remove thesigmoid, and set thepos_weightasnumber_negative_samples / number_positive_samples. If that doesn’t work, try to useWeightedRandomSampleras described here. -
see 2.
Also, note that the accuracy can be misleading for an imbalanced dataset as described in the Accuracy paradox.