Solved by ptrblck in post #6 
              
              
                Since you are using nn.CRossEntropyLoss or nn.NLLLoss (based on the stack trace), I assume you are working with a multi-class classification. Based on the output shape of the model, the current batch contains a single sample with logits for 6 classes. 
If that’s the case, the target should have the …