运行预训练模型 densenet161,训练好模型,用pytorch加载模型时,报错如下:
Traceback (most recent call last):
File “C:\Users\zxl\AppData\Local\Temp\ipykernel_5116\1378358857.py”, line 1, in
net()
File “C:\Users\zxl\anaconda3\envs\pytorch\lib\site-packages\torch\nn\modules\module.py”, line 727, in _call_impl
result = self.forward(*input, **kwargs)
File “C:\Users\zxl\anaconda3\envs\pytorch\lib\site-packages\torch\nn\parallel\data_parallel.py”, line 159, in forward
return self.module(*inputs[0], **kwargs[0])
IndexError: tuple index out of range
将程序
net().to(device)
改为
net.to(device)
解决~!