nn.CrossEntropyLoss expects a model output containing logits in the shape [batch_size, nb_classes, *] and a target containing class indices in the range [0, nb_classes-1] and the shape [batch_size, *].
The * denotes additional dimensions.
Assuming you are working with 27 classes, you would need to permute the model output such that the class dimension is in dim1.