python TypeError错误
本人刚接触python,想要复现github上的一个项目,在jupyter notebook上跑代码时遇到了一个错误,尝试了许多方法都解决不了C:\Users\Administrator\DeepTTE\main.py:129: DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() or inspect.getfullargspec()
model_args = inspect.getargspec(model_class.__init__).args
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
~\DeepTTE\main.py in <module>()
159
160 if __name__ == '__main__':
--> 161 run()
~\DeepTTE\main.py in run()
143
144 # model instance
--> 145 model = models.DeepTTE.Net(**kwargs)
146
147 # experiment logger
~\DeepTTE\models\DeepTTE.py in __init__(self, kernel_size, num_filter, pooling_method, num_final_fcs, final_fc_size, alpha)
89 self.alpha = alpha
90
---> 91 self.build()
92 self.init_weight()
93
~\DeepTTE\models\DeepTTE.py in build(self)
107 kernel_size = self.kernel_size, \
108 num_filter = self.num_filter, \
--> 109 pooling_method = self.pooling_method
110 )
111
~\DeepTTE\SpatioTemporal.py in __init__(self, attr_size, kernel_size, num_filter, pooling_method, rnn)
20 self.pooling_method = pooling_method
21
---> 22 self.geo_conv = GeoConv.Net(kernel_size = kernel_size, num_filter = num_filter)
23 #num_filter: output size of each GeoConv + 1:distance of local path + attr_size: output size of attr component
24 if rnn == 'lstm':
~\DeepTTE\GeoConv.py in __init__(self, kernel_size, num_filter)
15 self.num_filter = num_filter
16
---> 17 self.build()
18
19 def build(self):
~\DeepTTE\GeoConv.py in build(self)
20 self.state_em = nn.Embedding(2, 2)
21 self.process_coords = nn.Linear(4, 16)
---> 22 self.conv = nn.Conv1d(16, self.num_filter, self.kernel_size)
23
24 def forward(self, traj, config):
D:\anaconda\lib\site-packages\torch\nn\modules\conv.py in __init__(self, in_channels, out_channels, kernel_size, stride, padding, dilation, groups, bias, padding_mode, device, dtype)
288 super(Conv1d, self).__init__(
289 in_channels, out_channels, kernel_size_, stride_, padding_, dilation_,
--> 290 False, _single(0), groups, bias, padding_mode, **factory_kwargs)
291
292 def _conv_forward(self, input: Tensor, weight: Tensor, bias: Optional):
D:\anaconda\lib\site-packages\torch\nn\modules\conv.py in __init__(self, in_channels, out_channels, kernel_size, stride, padding, dilation, transposed, output_padding, groups, bias, padding_mode, device, dtype)
130 else:
131 self.weight = Parameter(torch.empty(
--> 132 (out_channels, in_channels // groups), *kernel_size), **factory_kwargs))
133 if bias:
134 self.bias = Parameter(torch.empty(out_channels, **factory_kwargs))
TypeError: empty(): argument 'size' must be tuple of ints, but found element of type NoneType at pos 3
我尝试将132行中的kernel_size和out_channels两个参数分别强制转换成int类型,但是仍然报同样的错误
我认为是这个conv.py文件中pos3位置的参数类型不对,但是我修改后也没有成功
请各位来帮忙看下 。。。你这个报错信息我看不懂,你用原生的IDE再发下报错信息
我建议初学尽量用原来的IDE,其他的(比如Pycharm之类)有点不适合新手
(项目地址在哪,发一下谢谢) __add__ 发表于 2022-5-28 09:05
。。。你这个报错信息我看不懂,你用原生的IDE再发下报错信息
我建议初学尽量用原来的IDE,其他的(比如Py ...
https://github.com/lucktroy/DeepTTE
上面这个是项目的地址
我先在IDE上跑跑看,谢谢!
页:
[1]