Some error when load model to predict

Ihave trained a CNN network and save it,but when i load it and predict some picture,it show error that RuntimeError: expected stride to be a single integer value or a list of 1 values to match the convolution dimensions, but got stride=[2, 2].
But if i have some error in network,why do i could train the network successfly?And i check up the code,i set the stride with 2,not [2,2]

This is a misleading error message, which is thrown if your data is missing a batch dimension.
It should be fixed on master. Here is the github issue.

Your data for prediction might be a single image with dimensions: [channels, height, width].
Just add a batch dimension at dim0 and your code should run again:

x = torch.randn(3, 24, 24) # your image
x.unsqueeze_(0)
print(x.shape)
> torch.Size([1, 3, 24, 24])
1 Like