A step-by-step guide to build a text classifier with CNNs implemented in PyTorch.

“Deep Learning is more that adding layers”

The objective of this blog is to develop a step by step text classifier by implementing convolutional neural networks. So, this blog is divided into the following sections:

  • Introduction
  • Preprocessing
  • The model
  • Training
  • Evaluation

So, let’s get started!

Introduction

The text classification problem can be addressed from different approaches, for example, considering the frequency of occurrence of words in a given text with respect to the occurrence of these words in the complete corpus.

On the other hand, there exists other approaches where the text is modeled as a sequence of words or characters, this type of approach makes use mainly of models based on Recurrent Neural Network architectures.

_If you want to know more about text classification with LSTM recurrent neural networks, take a look at this blog: _Text Classification with LSTMs in PyTorch

However, there is another approach where the text is modeled as a distribution of words in a given space. This is achieved through the use of Convolutional Neural Networks (CNNs).

So, we are going to start from the last mentioned approach, we are going to build a model to classify text considering the distribution in space of a set of words that make up the text using an architecture based on CNNs.

Let’s start!

#pytorch #cnn #text #neural-networks #python

Text Classification with CNNs in PyTorch
5.55 GEEK