报错内容:
File "E:/Users/DELL/Documents/pycharmProjects/SimVPv2/simvp/models/modeltestMANV2andCGUandTA.py", line 509, in __init__
self.local_conv = nn.Conv1d(c,c,3,padding=1)
TypeError: new() received an invalid combination of arguments - got (float, float, int), but expected one of:
* (*, torch.device device)
* (torch.Storage storage)
* (Tensor other)
* (tuple of ints size, *, torch.device device)
didn't match because some of the arguments have invalid types: (!float!, !float!, !int!)
* (object data, *, torch.device device)
didn't match because some of the arguments have invalid types: (!float!, !float!, !int!)
报错原因
注意到,出错代码为
self.local_conv = nn.Conv1d(c,c,3,padding=1)
而我的参数c是这样得到的:
c = n_feats/10 #n_feats为int型
在python3中,/ 表示除法, int / int = float,所以我的参数c实际上是float型的。但是nn.Conv1d
要求channel
类型为int
解决办法
c = n_feats/10 #n_feats为int型
改为
c = n_feats//10
参考自https://blog.csdn.net/qq_36852840/article/details/114702011