RuntimeError: Input type (torch.cuda.DoubleTensor) and weight type (torch.cuda.FloatTensor) should b

1.报错

RuntimeError: Input type (torch.cuda.DoubleTensor) and weight type (torch.cuda.FloatTensor) should be the same

2. 原因分析:

卷积的输入和网络权重类型不一样,实际输入的是DoubleTensor,要求FloatTensor

3. 解决方法:

https://discuss.pytorch.org/t/input-type-torch-cuda-doubletensor-and-weight-type-torch-cuda-floattensor-should-be-the-same/22704
在这里插入图片描述

到网络层将 input类型变更:

input=input.float() 

猜你喜欢

转载自blog.csdn.net/LemonShy2019/article/details/124696447