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) 

你可能感兴趣的:(MobileNetV2在python2.7中报错TypeError: new() received an invalid combination of arguments完美解决)