Pytorch nn.conv2d报错 RuntimeError: expected scalar type Int but found Float

测试nn.conv2d时出现如下错误RuntimeError: expected scalar type Int but found Float

Pytorch nn.conv2d报错 RuntimeError: expected scalar type Int but found Float_第1张图片

 查看img类型,确实时int没错

 查阅资料后,找到解决方法,参考运行深度学习模型出现“RuntimeError:expected scalar type Long but found Float”, 成功解决!_毛毛真nice的博客-CSDN博客

 将img转换为float类型,后解决问题

Pytorch nn.conv2d报错 RuntimeError: expected scalar type Int but found Float_第2张图片

 这个报错真的有点误导人,明明说现有float类型,想要int类型,事实上却恰恰相反,现有int类型,想要float类型。是不是pytorch开发人员写错了?

你可能感兴趣的:(pytorch,pytorch,深度学习,python)