Solved by Nikronic in post #2 
              
              
                Hi, 
It seems you misunderstood the BCEWithLogitsLoss. It uses sigmoid function on its inputs not on outputs. Here is pipeline: x->BCEWithLogitsLoss = x-> sigmoid -> BCELoss (Note that BCELoss is a standalone function in PyTorch too.) 
If you look at the documentation of torch.nn.BCEWithLogitsLoss, …