Solved by ptrblck in post #2 
              
              
                The raised error points towards an invalid index in the target: 
IndexError: Target 2 is out of bounds.

In a multi-class classification using nn.CrossEntropyLoss the model output is expected to have the shape [batch_size, nb_classes] while the target should have the shape [batch_size] and contain c…