TypeError: new() received an invalid combination of arguments - got (float, int, int, int), but expe
程序员文章站
2022-05-27 12:16:59
...
TypeError: new() received an invalid combination of arguments - got (float, int, int, int), but expected one of:
* (*, torch.device device)
* (torch.Storage storage)
* (Tensor other)
* (tuple of ints size, *, torch.device device)
* (object data, *, torch.device device)
今天在复现代码的过程中出现了这个错误,然后通过查阅资料找到了原因:在我的conv层中有个为float类型的通道大小输入。
我当时写了一个1x1的卷积,然后通道数c设置的为输出通道 out_c / 4,这就是导致出现该报错的原因。注意,在python3中,/ 表示除法, int / int = float,所以当 64 / 4 时,输出是16.0而不是16,这不是conv层中channel大小的有效值。
所以解决方法如下:
- out_c // 4
- int(out_c / 4)
上一篇: 读取注册表键值对的C#代码
下一篇: TypeError: transpose() received an invalid combination of arguments - got (Tensor)的问题
推荐阅读
-
TypeError: new() received an invalid combination of arguments-got(float, int)
-
TypeError: new() received an invalid combination of arguments - got (float, int, int, int), but expe
-
TypeError: sum() received an invalid combination of arguments - got (axis=int, ), but expected one
-
TypeError: transpose() received an invalid combination of arguments - got (int, int, int, int), but
-
TypeError: new() received an invalid combination of arguments - got (float, int), but expected one
-
numpy矩阵求和 TypeError: sum() received an invalid combination of arguments - got (axis=int, )