Traceback (most recent call last): File "/home/u1/下载/pycharm-community-2023.1.2/plugins/python-ce/helpers/pydev/pydevd.py", line 1496, in _exec pydev_imports.execfile(file, globals, locals) # execute the script File "/home/u1/下载/pycharm-community-2023.1.2/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "/home/u1/ywj/deepfashion/clothes_change_ywj/use_torch_on_deepfashion.py", line 186, in <module> outputs = net(inputs) File "/home/u1/miniconda3/envs/clothes_change_ywj/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(*args, **kwargs) File "/home/u1/ywj/deepfashion/clothes_change_ywj/use_torch_on_deepfashion.py", line 141, in forward roi_features = self.roi_pooling(x, roi_boxes) File "/home/u1/miniconda3/envs/clothes_change_ywj/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(*args, **kwargs) TypeError: forward() takes 2 positional arguments but 3 were given 进程已结束,退出代码1
时间: 2023-09-04 11:15:58 浏览: 147
Mac下anaconda中Spyder打开报错Traceback(most recent call last)…问题
5星 · 资源好评率100%
这个错误提示是因为在调用模型的forward()方法时传递的参数个数不正确。根据错误提示,forward()方法只接收两个位置参数,但是在调用时传递了三个参数。
请检查代码中调用forward()方法的地方,确保只传递了模型输入和ROI框,而没有多余的参数。例如,如果你的代码如下所示:
```python
outputs = net(inputs, roi_boxes, extra_param)
```
应该修改为:
```python
outputs = net(inputs, roi_boxes)
```
这样就可以解决这个错误了。
阅读全文