I am adding an example code. You have to implement convolutions of size (2Xembdedding_size) in your case 300. You can modify the below code for your case.


class Example(nn.Module):


    def __init__(self, vocab_size, output_size, embedding_dim, drop_prob,n_filters,filter_sizes):
        
        """
        Settin up the parameters.
        """
        super(Intent_CNN, self).__init__()

        self.output_size = output_size
        
        # embedding layer and LSTM layers 
        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_size)
        
        self.dropout = nn.Dropout(drop_prob)

        

    def forward(self, x):
        """
        Perform a forward pass

        """
        #print("X initial",x.shape)

        batch_size = x.size(0)
        
        x = x.long()
        #print("X long",x.shape)
        
     
        embeds = self.embedding(x)
        
        
        embedded = embeds.unsqueeze(1)
        #print("embeds",embedded.shape)
      
        conved = [F.relu(conv(embedded)).squeeze(3) for conv in self.convs]
            
        #conved_n = [batch size, n_filters, sent len - filter_sizes[n] + 1]
                
        pooled = [F.max_pool1d(conv, conv.shape[2]).squeeze(2) for conv in conved]
        
        #pooled_n = [batch size, n_filters]
        
        cat = self.dropout(torch.cat(pooled, dim = 1))
        
        #cat = [batch size, n_filters * len(filter_sizes)]
        out=self.fc(cat)
        
        
        return out