Hello atl!



 atl:

I figured there must be a mistake somewhere in my accuracy calculation.
# define accuracy function
def binary_acc(pred, target):
    pred_tag = torch.round(pred)

    correct_results_sum = (pred_tag == target).sum().float()
    acc = correct_results_sum/target.shape[0]
    acc = acc*100
    
    return acc



Based on what you have said, you have taken the sigmoid()
out of your network.  (Correct, because you changed your loss
function to BCEWithLogitsLoss().)  But you have also taken
the sigmoid() out of your accuracy calculation.
Without the network sigmoid() the tensor pred will contain
values that can range from -inf to inf.  (We generally call
these kinds of predictions logits.)  So pred_tag will be integers
that also range, in principle, from -inf to inf, and will rarely
match your target of 0 or 1.
You could put the sigmoid() back in your accuracy calculation.
Or, probably a little bit nicer, compare
(pred > 0.0).long() == target

to test for correct predictions.  (And make sure you understand
what this is doing, and why it works.)
Good luck.
K. Frank