I build a net, I used cross entropy loss, the forward is success, but the backward failed! I don’t know why it doesn’t work.
RuntimeErrorTraceback (most recent call last)
<ipython-input-3-c3211f22ae0b> in <module>()
132 print "loss: {}, train_acc: {}".format(loss.data[0], train_acc)
133
--> 134 loss.backward()
135 opt.step()
136
/root//lib/python2.7/site-packages/torch/autograd/variable.pyc in backward(self, gradient, retain_variables)
144 'or with gradient w.r.t. the variable')
145 gradient = self.data.new().resize_as_(self.data).fill_(1)
--> 146 self._execution_engine.run_backward((self,), (gradient,), retain_variables)
147
148 def register_hook(self, hook):
/root//lib/python2.7/site-packages/torch/autograd/_functions/tensor.pyc in backward(self, grad_output)
307 def backward(self, grad_output):
308 return tuple(grad_output.narrow(self.dim, end - size, size) for size, end
--> 309 in zip(self.input_sizes, _accumulate(self.input_sizes)))
310
311
/root//lib/python2.7/site-packages/torch/autograd/_functions/tensor.pyc in <genexpr>((size, end))
306
307 def backward(self, grad_output):
--> 308 return tuple(grad_output.narrow(self.dim, end - size, size) for size, end
309 in zip(self.input_sizes, _accumulate(self.input_sizes)))
310
RuntimeError: out of range at /data/users/soumith/miniconda2/conda-bld/pytorch-cuda80-0.1.10_1488756735684/work/torch/lib/TH/generic/THTensor.c:367