Creating simple NN for

Hi, I’m a total beginner in PyTorch and NN.

I am trying to create a simple Sentiment Analysis NN with 3 classes (negative, positive, neutral) for my school project, but I am still getting errors.

Recently I got this error:
RuntimeError: Given groups=1, weight of size [50, 1, 2, 50], expected input[1, 64, 1, 50] to have 1 channels, but got 64 channels instead

and I do not have a clue on how to solve it.

This is my Convolutional Neural Network, I forked it from this Github project

import torch
import torch.nn as nn
import torch.nn.functional as F

class CNN(nn.Module):
    def __init__(self, vocab_size, embedding_dim, n_filters, filter_sizes, output_dim, 
                 dropout, pad_idx):
        self.embedding = nn.Embedding(vocab_size, embedding_dim)
        self.convs = nn.ModuleList([
                                    nn.Conv2d(in_channels = 1, 
                                              out_channels = n_filters, 
                                              kernel_size = (fs, embedding_dim)) 
                                    for fs in filter_sizes
        self.fc = nn.Linear(len(filter_sizes) * n_filters, output_dim)
        self.dropout = nn.Dropout(dropout)
    def forward(self, text):
        #text = [batch size, sent len]
        embedded = self.embedding(text)
        #embedded = [batch size, sent len, emb dim]
        embedded = embedded.unsqueeze(1)
        #embedded = [batch size, 1, sent len, emb dim]
        conved = [F.relu(conv(embedded)).squeeze(3) for conv in self.convs]
        #conv_n = [batch size, n_filters, sent len - filter_sizes[n]]
        pooled = [F.max_pool1d(conv, conv.shape[2]).squeeze(2) for conv in conved]
        #pooled_n = [batch size, n_filters]
        cat = self.dropout(, dim = 1))

        #cat = [batch size, n_filters * len(filter_sizes)]
        return self.fc(cat)

Can anybody help me? I would be really grateful

Could you post the model initialization as well as random input shapes to reproduce the issue?
Based on the error message it seems as if

conved = [F.relu(conv(embedded)).squeeze(3) for conv in self.convs]

would be failing, but the channel dimension of embedded should be set to 1 via the unsqueeze(1) and I can’t see the obvious issue so far.