Solved by LeviViana in post #2 
              
              
                The error comes from the use of CrossEntropyLoss. It expects a LongTensor of the shape BATCH_SIZE having the indices of targets, take a look at the documentation.