Solved by KFrank in post #2 
              
              
                Hi Barber! 

I assume that by “got this error” you mean the error message 
in your post title, “Expected object of scalar type Long but got 
scalar type Float.”  This was to be expected. 
CrossEntropyLoss takes integer class labels for its target, 
specifically of type LongTensor.  In your code you …