【TypeError】empty() received an invalid combination of arguments - got (tuple, dtype=NoneType, device

在构建一个简单的卷积层进行维度设置时,出现如下的错误: 

【TypeError】empty() received an invalid combination of arguments - got (tuple, dtype=NoneType, device_第1张图片

测试发现,在使用乘法计算维度是没有报错,而在使用除法是报错。思考是由于变量类型导致的

【TypeError】empty() received an invalid combination of arguments - got (tuple, dtype=NoneType, device_第2张图片

 产生的原因是因为在python3中两个整型相除得到的是浮点型,例如:128/2=64.0,而在构建卷积时的参数要求时整型,强转一下就可以了。

你可能感兴趣的:(pytorch,错误异常处理,python,深度学习,开发语言)