The code looks fine, besides some minor unnecessary indexing.
What do you mean by “I don’t seem to be getting the proper values”? Could you explain a bit more about the problem?
Here is a small example, which basically computes, what your code does:
batch_size = 10
n_classes = 5
output = F.log_softmax(Variable(torch.randn(batch_size, n_classes)), dim=1)
target = Variable(torch.LongTensor(batch_size).random_(n_classes))

_, pred = torch.max(output, dim=1)

pred.eq(target)