NLLLoss’s target should be a torch.LongTensor. See here for more details: http://pytorch.org/docs/master/nn.html?highlight=nllloss#torch.nn.NLLLoss 1.5k
This means you should change your code to:
y = torch.autograd.Variable(batch[1]).long(). However, I’m not 100% sure you have the right target shape (see the docs).