If you are dealing with a multi-class classification and would like to use nn.CrossEntropyLoss (or nn.NLLLoss) as your criterion, the output of your model should contain the logits (or log probabilities) as [batch_size, nb_classes, height, width], while your target should be a LongTensor containing the class indices as [batch_size, height, width].
If your target already contains these indices, you can just call target = target.squeeze(1) on it to remove the channel dimension.