RuntimeError: Expected object of type torch.cuda.FloatTensor but found type torch.FloatTensor for ar

Posted wind-chaser

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了RuntimeError: Expected object of type torch.cuda.FloatTensor but found type torch.FloatTensor for ar相关的知识,希望对你有一定的参考价值。

这行报错predict = model(Variable(x_train))

RuntimeError: Expected object of type torch.cuda.FloatTensor but found type torch.FloatTensor for argument #4 ‘mat1‘

意思是要求的目标类型是torch.cuda.FloatTensor,但是找到的数据类型是torch.FloatTensor,所以需要在数据类型后面加上.cuda()。将predict = model(Variable(x_train)) 改为predict = model(Variable(x_train.cuda()))


————————————————
ref:https://blog.csdn.net/qq_38410428/article/details/82973895

以上是关于RuntimeError: Expected object of type torch.cuda.FloatTensor but found type torch.FloatTensor for ar的主要内容,如果未能解决你的问题,请参考以下文章

RuntimeError:Expected to have finished reduction in the prior iteration

RuntimeError: Expected hidden[0] size (1, 1, 512), got (1, 128, 512) for LSTM pytorch

RuntimeError: Expected a ‘cuda‘ device type for generator but found ‘cpu‘

RuntimeError: Expected object of type torch.cuda.FloatTensor but found type torch.FloatTensor for ar

RuntimeError: Expected all tensors to be on the same device, but found at least two devices

RuntimeError: Expected all tensors to be on the same device,但发现至少有两个设备,cpu和cuda:0!使用我的模型进行预测时