Pytorch踩坑記——持續更新

1、nn.Conv2D()或者nn.Conv3D()输入参数数据格式不对

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

代碼定位:

nn.Conv3d(in_channels, out_channels/2, 3, stride=1, padding=0)

根据报错信息,是说conv函數包含有float的数据类型,通过分析可以看到,只有out_channels/2可能是float类型,由此想到在python3中n/2是带有小数点的,应该为n//2为整数

猜你喜欢

转载自blog.csdn.net/weixin_40519315/article/details/105952063
今日推荐