我的损失函数是NLL损失,其输入形状为[108416, 3]
,目标形状为[108416]
,我得到的损失值为2.2623
,但是经过损失计算当我进行optimizer.step()
通话时。我得到
AND THIS IS LOSS Variable containing:
2.2623
[torch.cuda.FloatTensor of size 1 (GPU 0)]
Traceback (most recent call last):
File "/mnt/sdc1/project/training/fpr4x_liver_1x_2channel.py", line 336, in <module>
train_fpr4x_liver_1x_2channel_model()
File "/mnt/sdc1/project/training/fpr4x_liver_1x_2channel.py", line 245, in train_fpr4x_liver_1x_2channel_model
est.run_experiment(opts.num_epochs, 5000,50)
File "/media/redible/sdc/project/training/expt_utils.py", line 236, in run_experiment
self.trainer.train()
File "/media/redible/sdc/project/training/expt_utils.py", line 75, in train
loss, outputs = self.net_mgr._forward_backward(network_inputs, loss_inputs)
File "/media/redible/sdc/project/training/network_manager.py", line 19, in _forward_backward
self.optimizer.step()
File "/usr/local/lib/python3.5/dist-packages/torch/optim/adam.py", line 69, in step
exp_avg.mul_(beta1).add_(1 - beta1, grad)
RuntimeError: invalid argument 3: sizes do not match at /pytorch/torch/lib/THC/generated/../generic/THCTensorMathPointwise.cu:271
不知道导致错误的原因是什么,需要任何帮助,谢谢。