[Solved]Conv1d the parameter kernel_size and strides must be tuple?

Hi everone,
I using this code:
self.conv = nn.Conv1d(input_dim, output_dim, 1, 1)

but get the error:
RuntimeError: kernel size should be greater than zero, but got kH: 1 kW: 0 at /Users/soumith/code/builder/wheel/pytorch-src/torch/lib/THNN/generic/SpatialConvolutionMM.c:11

the strides has the same problem.
self.conv = nn.Conv1d(input_dim, output_dim, (1,1),(1,1)) is correct.

why did this case take place?In the document, the kernel_size and strides can use int or tuple.
Thanks for help :slight_smile:

I find my input Dimension is error, if use Conv1D, the input shape must be 3D-Tensor (N,Cin,Lin)


In one dimensional convolution, I think tuple is incorrect. Why? because you are dealing with 1 dimension (1, 1) means stride in direction X and Y. Just specify int, I think that might fix your problem.

yes, I find my input dimension is error, so i fix it.