MobileNetV2在python2.7中报错TypeError: new() received an invalid combination of arguments完美解决

在github下载的MobileNetV2,在python2.7上报错如下:

TypeError: new() received an invalid combination of arguments - got (float, float, 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)

问题定位:定位到报错行为:

nn.Conv2d(hidden_dim, hidden_dim, 3, stride, 0, dilation, groups=hidden_dim, bias=False),

问题分析: 根据报错信息,是说本行代码包含有float的数据类型,通过分析可以看到,只有hidden_dim = round(inp * expand_ratio)可能是float类型,hidden_dim应该为整数。
问题解决:将其类型转换为整型,hidden_dim = int(hidden_dim) 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值