...

/

CNNs for Sentence Classification: Transformation of Data

CNNs for Sentence Classification: Transformation of Data

Learn about data transformations for sentence classification using a CNN.

Though CNNs have mostly been used for computer vision tasks, nothing stops them from being used in NLP applications. But as we highlighted earlier, CNNs were originally designed for visual content. Therefore, using CNNs for NLP tasks requires somewhat more effort. This is why we started out learning about CNNs with a simple computer vision problem. CNNs are an attractive choice for machine learning problems due to the low parameter count of convolution layers. One such NLP application for which CNNs have been used effectively is sentence classification.

In sentence classification, a given sentence should be classified with a class. We’ll use a question database, where each question is labeled by what the question is about. For example, the question “Who was Abraham Lincoln?” will be a question, and its label will be “Person.” For this, we’ll use a sentence classification dataset. We’re using the set with around 5,500 training questions and their respective labels and 500 testing sentences.

We’ll use the CNN network introduced in a paper by Yoon Kim, “Convolutional Neural Networks for Sentence Classification,” to help us understand the value of CNNs for NLP tasks. However, using CNNs for sentence classification is somewhat ...