Search code examples
pythondeep-learningnlpconv-neural-networklstm

it is normal that CNN give me better accuracy compared to LSTM in text classification?


For a text classification, I have data of 1000 reviews and I tried different neural networks. For the CNN I got an accuracy of 0.94 but with the LSTM I got a lower accuracy (0.88) is this normal because as far as I know the LSTM is specialized for text classification and it preserves the order of the word sequence?


Solution

  • Yes, this isn't abnormal and was shown in a lot of researches.
    The performance of these models depends on many factors like the data you have and the task you are dealing with it.
    For example, CNN can perform well if your task cares more about detecting some substantial features (like the sentiment).
    However, RNN-based models can show their superiority when the sequential aspect of the data is matters, like in Machine Translation and Text Summarization tasks.
    I don't believe that the "LSTM specialized for text classification" is true. It's better to say LSTM specialized to learn sequential data. LSTM can learn the texts and the relation between the tokens very well, but the task you defined maybe doesn't care about these linguistic features. For example, in sentiment classification, a model (like CNN) can care about just the presence of some words and achieves good results.