Regarding the error, that’s because CrossEntropyLoss expects integer arrays as input. In particular, an array or type Long (which means 64-bit integer). Here’s a handy cheatsheet:

Screen Shot 2019-02-09 at 3.27.15 AM.png709×447 50.1 KB

btw. to save you from some trouble later

#BinaryCrossEntropy formula
loss = criterion(output, labels)

you actually used CrossEntropy, which is the multi-category cross-entropy in PyTorch; for the binary cross entropy, you probably want the BCELoss (note that it takes the sigmoid outputs instead of the logits as inputs though).