Runtime Error: Expected 2 to 3 dimensions, but got 4-dimensional tensor for argument # 1 I get the error'self'

When building CNN with pytorch
RuntimeError: Expected 2 to 3 dimensions, but got 4-dimensional tensor for argument # 1’self’ (while checking arguments for max_pool1d)
What does the error mean?
class Net (nn.Module):

def init __ (self):
super (Net, self) .
init__ ()
self.conv1 = nn.Conv1d (1, 60, kernel_size = (1, 15), stride = (1, 3))
self.conv2 = nn.Conv1d (60, 60, kernel_size = (1, 4), stride = (1, 2))
self.conv3 = nn.Conv1d (60, 60, kernel_size = (1, 17), stride = (1,3))
self.conv4 = nn.Conv1d (60, 90, kernel_size = (1, 3), stride = (1, 1))
self.conv5 = nn.Conv1d (90, 120, kernel_size = (1, 1), stride = (1, 1))
self.pool = nn.MaxPool1d ((1,2), stride = (1,2))
self.soft = nn.Softmax ()
self.li = nn.Linear (11520,95)

def forward (self, x):
x = self.conv1 (x)
x = self.pool (x)
x = self.conv2 (x)
x = self.pool (x)
x = self.conv3 (x)
x = self.conv4 (x)
x = self.pool (x)
x = self.conv5 (x)
x = self.li (x)
x = self.soft (x)
return x
The cnn class looks like this:

nn.MaxPool1d expect a 3-dimensional tensor in the shape [batch_size, channels, seq_len] while you are apparently passing a 4-dimensional tensor to this layer.

1 Like