conv2d() received an invalid combination of arguments - got

实战错误:

运行该代码无错

con=nn.Conv2d(in_channels=3,out_channels=3,kernel_size=(3,3))

运行下面出现错误

con(img)
TypeError: conv2d() received an invalid combination of arguments - got (torch.Size, Parameter, Parameter, tuple, tuple, tuple, int), but expected one of:
 * (Tensor input, Tensor weight, Tensor bias, tuple of ints stride, tuple of ints padding, tuple of ints dilation, int groups)
      didn't match because some of the arguments have invalid types: (torch.Size, Parameter, Parameter, tuple, tuple, tuple, int)
 * (Tensor input, Tensor weight, Tensor bias, tuple of ints stride, str padding, tuple of ints dilation, int groups)
      didn't match because some of the arguments have invalid types: (torch.Size, Parameter, Parameter, tuple, tuple, tuple, int)

简单排除后发现 img 参数问题

img=img_tensor.unsqueeze(dim=0).shape

img=img_tensor.unsqueeze(dim=0)

希望能够给你们一些帮助

你可能感兴趣的:(笔记,深度学习,pytorch,人工智能)