Thank you, good find. I put this at the start of the forward call.
Now I am having an error with calculating the loss function:

Traceback (most recent call last):
File “”, line 1, in 
File “mymodel.py 2”, line 147, in 
train(epoch)
File “mymodel.py 2”, line 119, in train
loss = F.nll_loss(output, target)
File “/home/slava/dev/miniconda2/lib/python2.7/site-packages/torch/nn/functional.py”, line 501, in nll_loss
return f(input, target)
File “/home/slava/dev/miniconda2/lib/python2.7/site-packages/torch/nn/_functions/thnn/auto.py”, line 41, in forward
output, *self.additional_args)
RuntimeError: Assertion `cur_target >= 0 && cur_target < n_classes’ failed.  at /b/wheel/pytorch-src/torch/lib/THNN/generic/ClassNLLCriterion.c:57