Solved by KFrank in post #3 
              
              
                Hello Rui An! 

It appears that you have switched the order of your inputs to 
BCEWithLogitsLoss. 
BCEWithLogitsLoss (like 
binary_cross_entropy_with_logits()) expects to be 
called with predictions that are logits (-infinity to infinity) and 
targets that are probabilities (0 to 1), in that order. 
…