1d conv filter on a 2d dataset

Hi everyone
I am trying to apply a 1d conv filter on my torch.Size([65536, 94]) data, however I faced with this error.

RuntimeError Traceback (most recent call last)
in ()
----> 1 z = m(y)

1 frames
/usr/local/lib/python3.6/dist-packages/torch/nn/modules/conv.py in forward(self, input)
198 _single(0), self.dilation, self.groups)
199 return F.conv1d(input, self.weight, self.bias, self.stride,
–> 200 self.padding, self.dilation, self.groups)

RuntimeError: Expected 3-dimensional input for 3-dimensional weight 10 1, but got 2-dimensional input of size [65536, 94] instead

Here is my code:
m = nn.Conv1d(1,10,5)

Dose anyone could help me ?

Based on the definition of your conv layer, it seems you are dealing with a single channel input data.
If that’s the case, make sure to add the channel dimension in dim1 to your input:

y = y.unsqueeze(1)
z = m(y)

This would create a tensor with the dimensions [batch_size=65535, channels=1, seq_length=94].

1 Like

That worked.
Thank you, ptrblck