Expected stride to be a single integer value or a list?

So I went through this thread and I am still facing this error. In my case, I am using a 3rd party library to just see how the network is working (torchinfo). I am giving the input as (1,1,28,28). My model is as follows:

net(
  (conv1): Conv2d(1, 1, kernel_size=(2, 2), stride=(1, 1))
  (pool): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
  (conv2): Conv2d(1, 1, kernel_size=(2, 2), stride=(1, 1))
)

But, I get

RuntimeError: expected stride to be a single integer value or a list of 1 values to match the convolution dimensions, but got stride=[1, 1]

when I run torchinfo.summary(net, (1,1,28,28)).
Torchinfo seems to be running fine otherwise. What should I do?

Hello~

        self.pca1 = nn.Conv2d(
            in_channels=rff_num_filter1,
            out_channels=pca_num_filter1,
            kernel_size=10,
            padding=round((kernel_size1-1)/2)
        ).requires_grad_(False)

data : torch.Size([1, 100, 128, 128])
Conv2d(100, 8, kernel_size=(10, 10), stride=(1, 1), padding=(3, 3))
The above is the dimension of the data and Conv2d ,but i had a question.can you help me ,please?

RuntimeError: expected stride to be a single integer value or a list of 1 values to match the convolution dimensions, but got stride=[1, 1]

Your code works fine:

pca1 = nn.Conv2d(in_channels=100, out_channels=8, kernel_size=10, padding=3).requires_grad_(False)

data = torch.randn(1, 100, 128, 128)
out = pca1(data)
print(out.shape)
# torch.Size([1, 8, 125, 125])

Could you check what the difference between my working code and yours would be?

yes,thank your reply, it’s right! then ,how i to do?

As I cannot reproduce the issue, could you post a minimal, executable code snippet which would raise the error?
Your current code snippet is not executable and my code works fine.

Hello. My PCa1 structure output is conv2d (100, 8, kernel_size= (10, 10), stripe= (1, 1), padding= (3, 3)), is it the same as yours?

Hello. My PCa1 structure output is conv2d (100, 8, kernel_size= (10, 10), stripe= (1, 1), padding= (3, 3)), is it the same as yours?

When I execute your code in jupyter cell alone, it works normally. But when I copy your code into my project (including data generated randomly), he will report the above error.