CrossEntropyLoss needs a 1-dimensional target.
From the docs:

This criterion expects a class index (0 to C-1) as the target for each value of a 1D tensor of size minibatch

Example:
batch_size = 10
n_classes = 5
data = Variable(torch.randn(batch_size, n_classes))
target = Variable(torch.LongTensor(batch_size).random_(n_classes))

criterion = nn.CrossEntropyLoss()
loss = criterion(data, target)