nn.NLLLoss expects the target to have the shape [batch_size] for a multi-class classification and contain the class indices in the range [0, nb_classes-1].
Your target tensor seems to be one-hot encoded. If that’s the case, you can transform it to the right shape via target = torch.argmax(target, dim=1).