Expected 3-dimensional input for 3-dimensional weight [200, 1, 4], but got 2-dimensional input of size [64, 1500] instead
I'm trying to create Conv1d. My data consists of byte streams with a length of 1500. My batch size is 64. I know that Conv1d expects the input to be [batch, channels, sequence_length]. Here is my neural net:
class ConvNet(nn.Module):
   def __init__(self):
     super().__init__()
     self.conv1 = nn.Sequential( 
                    nn.Conv1d(
                        in_channels=1,
                        out_channels=200,
                        kernel_size=4, 
                        stride=3, 
                        padding = 0) 
                    , nn.ReLU()
     )

  def forward(self,x):
     output = self.conv1(x)
     return output

I got the error:

Expected 3-dimensional input for 3-dimensional weight [200, 1, 4], but got 2-dimensional input of size [64, 1500] instead

I don't know how to change the input to be compatible with the input that my convent expects. Or should I change the model itself?

You're feeding your model with data somewhere. You may have something like this:
model = ConvNet()

# get data from somewhere
input_x = # your data

# feed the model with the data
output = model(input_x)

You can change the last part to:
# feed the model with the data
output = model(input_x.unsqueeze(1))

Or you can change your model's forward to:
    def forward(self,x):
        output = self.conv1(x.unsqueeze(1))
        return output

but I don't recommend the second approach.
Both approaches will change the shape to [64, 1, 1500].
