prakashpandey9 / Text-Classification-Pytorch

Text classification using deep learning models in Pytorch
MIT License
809 stars 239 forks source link

how to use the CNN model? #10

Closed supermuesli closed 4 years ago

supermuesli commented 5 years ago

can you make an example of how to use the cnn model, like you did for lstm? i have trouble understanding the parameters required to get the cnn up and running.

thanks in advance!

meisin commented 4 years ago

I managed to run CNN with these parameters:

batch_size = 32 ## given in code output_size = 2
in_channels = 1 ## for text, the in_channels is always 1 while images is 2 out_channels = 100 ## number of filters vocab_size = len(TEXT.vocab) ## given in code kernel_heights = [3, 4, 5] stride = 1 padding = 0 keep_probab = 0.5 embedding_length = 300 word_embeddings = TEXT.vocab.vectors ## given in code

model = CNN(batch_size, output_size, in_channels, out_channels, kernel_heights, stride, padding, keep_probab, vocab_size, embedding_length, word_embeddings)