TypeError: conv2d(): argument 'padding' must be tuple of ints, but found element of type float at pos 1

I converted a python 2.7 program to 3, and there was an error at runtime. Thank you.

“D:\Program Files\Anaconda3\envs\lei\python.exe” D:/zgy/GCC/GCC-SFCN-master/train.py
D:\Program Files\Anaconda3\envs\lei\lib\site-packages\torch\tensor.py:287: UserWarning: non-inplace resize is deprecated
warnings.warn(“non-inplace resize is deprecated”)
Traceback (most recent call last):
File “D:/zgy/GCC/GCC-SFCN-master/train.py”, line 204, in
main()
File “D:/zgy/GCC/GCC-SFCN-master/train.py”, line 72, in main
i_tb = train(train_loader, net, optimizer, epoch, i_tb)
File “D:/zgy/GCC/GCC-SFCN-master/train.py”, line 95, in train
pred_map = net(img, gt_map)
File “D:\Program Files\Anaconda3\envs\lei\lib\site-packages\torch\nn\modules\module.py”, line 489, in call
result = self.forward(*input, **kwargs)
File “D:\zgy\GCC\GCC-SFCN-master\models\CC.py”, line 28, in forward
density_map = self.CCN(img).squeeze()
File “D:\Program Files\Anaconda3\envs\lei\lib\site-packages\torch\nn\modules\module.py”, line 489, in call
result = self.forward(*input, **kwargs)
File “D:\Program Files\Anaconda3\envs\lei\lib\site-packages\torch\nn\parallel\data_parallel.py”, line 141, in forward
return self.module(*inputs[0], **kwargs[0])
File “D:\Program Files\Anaconda3\envs\lei\lib\site-packages\torch\nn\modules\module.py”, line 489, in call
result = self.forward(*input, **kwargs)
File “D:\zgy\GCC\GCC-SFCN-master\models\resSFCN.py”, line 49, in forward
x = self.convDU(x)
File “D:\Program Files\Anaconda3\envs\lei\lib\site-packages\torch\nn\modules\module.py”, line 489, in call
result = self.forward(*input, **kwargs)
File “D:\zgy\GCC\GCC-SFCN-master\models\layer.py”, line 27, in forward
fea_stack.append(self.conv(fea_stack[i-1])+i_fea)
File “D:\Program Files\Anaconda3\envs\lei\lib\site-packages\torch\nn\modules\module.py”, line 489, in call
result = self.forward(*input, **kwargs)
File “D:\Program Files\Anaconda3\envs\lei\lib\site-packages\torch\nn\modules\container.py”, line 92, in forward
input = module(input)
File “D:\Program Files\Anaconda3\envs\lei\lib\site-packages\torch\nn\modules\module.py”, line 489, in call
result = self.forward(*input, **kwargs)
File “D:\Program Files\Anaconda3\envs\lei\lib\site-packages\torch\nn\modules\conv.py”, line 320, in forward
self.padding, self.dilation, self.groups)
TypeError: conv2d(): argument ‘padding’ must be tuple of ints, but found element of type float at pos 1

Process finished with exit code 1

Could you post the model code so that we can have a look?
Did you check the arguments for the conv2d layer, as apparently padding is set using a float.

Can the weights trained with Pytorch 0.4.0 be applied to Pytorch 1? This program is trained with Pytorch 0.4.0 and python 2.7, but my running environment is Python 3 and pytorch1. Is this feasible?

You might have a shot when you load your state dict. If you pickle your model it might not work.
If you have pickled your models before you might want to create a new environment with python 2.7 and PyTorch 0.4.0 save the state dicts there and load them in your Python 3 environment after.

https://pytorch.org/tutorials/beginner/saving_loading_models.html