I tried this and got

TypeError: FloatClassNLLCriterion_updateOutput received an invalid combination of arguments - got (int, torch.FloatTensor, torch.FloatTensor, torch.FloatTensor, bool, NoneType, torch.FloatTensor), but expected (int state, torch.FloatTensor input, torch.LongTensor target, torch.FloatTensor output, bool sizeAverage, [torch.FloatTensor weights or None], torch.FloatTensor total_weight)

then I tried changing forward to return x.long() as well
and now get,

Traceback (most recent call last):
File “”, line 1, in 
File “mymodelc.py”, line 170, in 
train(epoch)
File “mymodelc.py”, line 140, in train
loss = F.cross_entropy(output, data)#F.nll_loss(output, data)
File “/home/slava/dev/miniconda2/lib/python2.7/site-packages/torch/nn/functional.py”, line 533, in cross_entropy
return nll_loss(log_softmax(input), target, weight, size_average)
File “/home/slava/dev/miniconda2/lib/python2.7/site-packages/torch/nn/functional.py”, line 434, in log_softmax
return _functions.thnn.LogSoftmax()(input)
File “/home/slava/dev/miniconda2/lib/python2.7/site-packages/torch/nn/_functions/thnn/auto.py”, line 110, in forward
self._backend = type2backend[type(input)]
File “/home/slava/dev/miniconda2/lib/python2.7/site-packages/torch/_thnn/init.py”, line 15, in getitem
return self.backends[name].load()
KeyError: <class ‘torch.LongTensor’>