Skip to main content
QUICK REVIEW

[Paper Review] Effects of padding on LSTMs and CNNs

Mahidhar Dwarampudi, N. V. Subba Reddy|arXiv (Cornell University)|Mar 18, 2019
Topic ModelingComputer Science12 references19 citations
TL;DR

This paper investigates the impact of pre-padding versus post-padding on LSTM and CNN performance in sentiment analysis. Using Twitter data with Word2Vec embeddings, it finds that pre-padding significantly improves LSTM accuracy (80.3% test) compared to post-padding (50.1%), while CNNs are largely unaffected by padding type, suggesting pre-padding is optimal for sequential models like LSTMs.

ABSTRACT

Long Short-Term Memory (LSTM) Networks and Convolutional Neural Networks (CNN) have become very common and are used in many fields as they were effective in solving many problems where the general neural networks were inefficient. They were applied to various problems mostly related to images and sequences. Since LSTMs and CNNs take inputs of the same length and dimension, input images and sequences are padded to maximum length while testing and training. This padding can affect the way the networks function and can make a great deal when it comes to performance and accuracies. This paper studies this and suggests the best way to pad an input sequence. This paper uses a simple sentiment analysis task for this purpose. We use the same dataset on both the networks with various padding to show the difference. This paper also discusses some preprocessing techniques done on the data to ensure effective analysis of the data.

Motivation & Objective

  • To evaluate how different padding strategies (pre- vs. post-padding) affect the performance of LSTMs and CNNs in sequence modeling tasks.
  • To determine whether data preprocessing choices like padding influence model accuracy and generalization in sentiment analysis.
  • To compare the effectiveness of LSTMs and CNNs under varying padding schemes using the same dataset and word embeddings.
  • To provide empirical guidance on optimal padding strategies for recurrent and convolutional networks in NLP applications.

Proposed method

  • Used a 10% subset of 157,860 tweets from Thinknook, preprocessed by replacing numbers with '0', handles with '1', URLs with '2', and lemmatizing words.
  • Generated 100-dimensional Word2Vec skipgram embeddings using a 5-word window over 5 epochs on the training data.
  • Trained 4-layer LSTMs with 100 units per layer, ReLU activation, 0.2 dropout, and tanh for all but the output layer (sigmoid).
  • Trained 4-layer CNNs with 100 units per convolutional layer, ReLU activation, 0.2 dropout, and a sigmoid output layer for binary classification.
  • Padded all sequences to the maximum length (93 tokens) using both pre-padding (zeros at start) and post-padding (zeros at end).
  • Compared model performance on training and test sets using accuracy, convergence speed (epochs), and overfitting behavior.

Experimental results

Research questions

  • RQ1How does pre-padding compare to post-padding in terms of test accuracy for LSTMs in sentiment classification?
  • RQ2Does the choice of padding strategy significantly affect CNN performance on short text sentiment analysis?
  • RQ3How do LSTMs and CNNs differ in their sensitivity to input sequence padding?
  • RQ4What is the impact of padding on model convergence and overfitting in sequential models?
  • RQ5Is there a consistent best practice for padding when combining LSTMs and CNNs in hybrid architectures?

Key findings

  • LSTM models with pre-padding achieved 80.3% test accuracy, while post-padding models reached only 50.1%, indicating a 30.2% performance gap.
  • The pre-padding LSTM converged in 9 epochs, while the post-padding LSTM peaked at 6 epochs and began overfitting earlier.
  • CNN models showed minimal performance difference between pre- and post-padding, with test accuracies of 74.99% and 74.91% respectively.
  • The pre-padding LSTM outperformed the post-padding LSTM by a wide margin, suggesting that preserving early sequence context is critical for LSTMs.
  • CNNs were insensitive to padding type due to their local receptive field and lack of sequential memory, making padding strategy less impactful.
  • Pre-padding is recommended for LSTMs and hybrid models where sequential context matters, especially in tasks like sentiment analysis.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.