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的主要内容,如果未能解决你的问题,请参考以下文章