TypeError: new() received an invalid combination of arguments - got (float, int, int, int), but expe
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
·
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)
更多推荐
已为社区贡献2条内容
所有评论(0)