Since you are working with 25 different classes, your model output should also contain logits for these 25 classes and thus should have the shape [batch_size, 25]. Could you check the model output shape before you pass it to the criterion?