Solved by KFrank in post #3 
              
              
                Hi Bram! 
Two comments: 

First, as you’ve seen, BCEWithLogitsLoss requires its target to 
be a float tensor, not long (or a double tensor, if the input is 
double).  And yes, converting to float (labels.float()) is the 
correct solution. 

Second, as to why:  Unlike pytorch’s CrossEntropyLoss, 
BCE…