Hi,
I think the problem is that labels need to be in long dtype not float.
This may help the problem:
loss = F.cross_entropy(out, labels.long())
This post is related RuntimeError: Expected object of scalar type Long but got scalar type Float when using CrossEntropyLoss - #2 by ptrblck.
Bests