File "/root/autodl-tmp/project/tools/../lib/net/pointnet2_msg.py", line 157, in forward li_xyz, li_features = self.SA_modules[i](l_xyz[i], l_features[i], channel_out) File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(*input, **kwargs) TypeError: forward() takes 2 positional arguments but 4 were given
时间: 2023-07-16 18:12:38 浏览: 89
这个错误是因为你在调用 `forward()` 方法时传入了 4 个参数,但是这个方法只需要 2 个参数。可能是你在调用 `forward()` 方法时传入了额外的参数,需要检查一下你的代码。如果有多余的参数,可以尝试删除它们或者将它们传递给其他的方法。如果问题仍然存在,你可以检查一下 `SA_modules` 这个模块的实现,确认它的 `forward()` 方法是否正确定义。
相关问题
File "train_rcnn.py", line 195, in <module> model = PointRCNN(num_classes=train_loader.dataset.num_class, use_xyz=True, mode='TRAIN') File "/root/autodl-tmp/project/tools/../lib/net/point_rcnn.py", line 15, in __init__ self.rpn = RPN(use_xyz=use_xyz, mode=mode) File "/root/autodl-tmp/project/tools/../lib/net/rpn.py", line 17, in __init__ self.backbone_net = MODEL.get_model(input_channels=int(cfg.RPN.USE_INTENSITY), use_xyz=use_xyz) File "/root/autodl-tmp/project/tools/../lib/net/pointnet2_msg.py", line 97, in get_model return Pointnet2MSG(input_channels=input_channels, use_xyz=use_xyz) File "/root/autodl-tmp/project/tools/../lib/net/pointnet2_msg.py", line 125, in __init__ SelfAttention(channel_out=channel_out) TypeError: __init__() got an unexpected keyword argument 'channel_out'
这个错误提示的意思是,在 "/root/autodl-tmp/project/tools/../lib/net/pointnet2_msg.py" 文件的第 125 行,SelfAttention() 函数不支持 'channel_out' 这个参数。可能是版本更新或者代码改动导致的。你需要检查一下代码,看看是否有相应的参数名字改动或者参数不需要了。你可以查看一下 SelfAttention() 函数的定义,看看它需要哪些参数,并且检查你传给它的参数是否正确。
raceback (most recent call last): File "train_rcnn.py", line 243, in <module> trainer.train( File "/root/autodl-tmp/project/tools/../tools/train_utils/train_utils.py", line 199, in train loss, tb_dict, disp_dict = self._train_it(batch) File "/root/autodl-tmp/project/tools/../tools/train_utils/train_utils.py", line 132, in _train_it loss, tb_dict, disp_dict = self.model_fn(self.model, batch) File "/root/autodl-tmp/project/tools/../lib/net/train_functions.py", line 35, in model_fn ret_dict = model(input_data) File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(*input, **kwargs) File "/root/autodl-tmp/project/tools/../lib/net/point_rcnn.py", line 33, in forward rpn_output = self.rpn(input_data) File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(*input, **kwargs) File "/root/autodl-tmp/project/tools/../lib/net/rpn.py", line 74, in forward backbone_xyz, backbone_features = self.backbone_net(pts_input) # (B, N, 3), (B, C, N) File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(*input, **kwargs) File "/root/autodl-tmp/project/tools/../lib/net/pointnet2_msg.py", line 154, in forward li_xyz, li_features = self.SA_modules[i](l_xyz[i], l_features[i]) File "/root/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(*input, **kwargs) TypeError: forward() takes 2 positional arguments but 3 were given
这个错误是因为在调用 `forward()` 函数时给了 3 个参数,但是该函数只接受 2 个参数。可能是在调用 `self.SA_modules[i](l_xyz[i], l_features[i])` 时出现了问题。你可以检查一下该函数的定义,确保它只需要 2 个参数,并且检查一下你在调用 `forward()` 函数时是否传入了多余的参数。
阅读全文