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
RuntimeError: Input type (torch.cuda.DoubleTensor) and weight type (torch.cuda.FloatTensor) should b_第1张图片

到网络层将 input类型变更:

input=input.float() 

你可能感兴趣的:(遇到bug,报错,pytorch,深度学习,人工智能)