I’m trying to implement convolution to pick up n-grams in the data and then use them as features for classification. I’ve since changed the kernel_size to 2 now that I’ve implemented a 2D one-hot matrix for each observation rather than a single collapsed one-hot vector for each (hence why I couldn’t use a 2x2 kernel before). Noob here so please bear with me.
Refactored the vectorizer so that my classifier inputs are now of the shape [batch_size, channels, seq_length] as ptrblock suggested. I’m currently using the following helper function to flatten inputs before passing them to my fc layer:
def flatten(x):
    shape = torch.prod(torch.tensor(x.shape[1:])).item()
    return x.view(-1, shape)

Still, I’m getting the following error when I run the forward pass on my model:
RuntimeError: size mismatch, m1: [512 x 34688], m2: [128 x 1] at ../aten/src/TH/generic/THTensorMath.cpp:752

512 is my batch_size, 3995 is my initial_n_features (the words appearing often enough in the text to be used as features), and 275 is my seq_length (the maximum length of any review passed into my model).
I’m also using 128 as the number of features used by my intermediate layers (so out_channels in each of my Conv1d’s), and 1 as the number of classes in my final prediction vector.
What am I doing wrong? I’m using the same Classifier as above except I flatten the output of the Conv layers before passing them into the fc layer using the function in this post.