我不明白这个错误在告诉我什么。在a different post中,同样的问题也得到了解决,但没有有效的解决办法。在Traceback (most recent call last):
File "train.py", line 252, in
main()
File "train.py", line 231, in main
train(net, training_dataset, targets, device, criterion, optimizer, epoch, args.epochs)
File "train.py", line 103, in train
loss.backward()
File "/home/hb119056/.local/lib/python3.6/site-packages/torch/tensor.py", line 107, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph)
File "/home/hb119056/.local/lib/python3.6/site-packages/torch/autograd/__init__.py", line 93, in backward
allow_unreachable=True) # allow_unreachable flag
RuntimeError: Function MulBackward0 returned an invalid gradient at index 0 - expected type torch.cuda.FloatTensor but got torch.FloatTensor
这是我代码中对应的段。在
^{pr2}$
非常感谢您的帮助,谢谢!在