Solved by ptrblck in post #2 
              
              
                ignore_index will ignore valid as well as invalid target indices. 
E.g. if you are dealing with 10 classes, your model output would have a dimension of [batch_size, 10] in the vanilla multi-class classification setup, while the target will be a LongTensor of shape [batch_size] containing class indic…