项目场景:
手搓神经网络
问题描述:
RuntimeError: Input type (torch.cuda.DoubleTensor) and weight type (torch.cuda.FloatTensor) should be the same
原因分析:
没有把输入数据类型转为float类型
解决方案:
x = x.type(torch.cuda.FloatTensor)
注意,加上 .cuda
我参考的文章给了我思路,在我实践的时候,发现还需要添加.cuda
参考链接
链接: link.