Mat1 dim 1 must match mat2 dim 0

def forward(self, x):

    """Perform forward."""


    # conv layers

    x = self.conv_layer(x)


    # flatten

    #x = x.view(x.size(0), -1)

    x = x.view(x.shape, -1)

    # fc layer

    x = self.fc_layer(x)

    return x

Hi while running this sell iam getting an error like this :

mat1 dim 1 must match mat2 dim 0

The the length of our train data is 31690 and test data is 2050
can you suggest me a way to solve this error

Print the shape of x before passing it to the linear layer and make sure the number of features in the activation match the in_features from the linear layer.

Also, x = x.view(x.shape, -1) won’t change the shape of the activation, so you might want to use the commented approach.