Sentiment Analysis in PyTorch
Building a model to perform sentiment analysis in PyTorch is fairly similar to what we have seen so far with RNNs. The difference is that, on this occasion, the text data will be processed word by word. The steps that are required to build such a model will be provided in this section.
Preprocessing the Input Data
As with any other data problem, you need to load the data into the code, bearing in mind that different methodologies are used for different data types. Besides converting the entire set of words into lowercase, the data undergoes some basic transformations that will allow you to feed the data into the network. The most common transformations are as follows:
- Eliminating punctuation: When processing text data word by word for NLP purposes, remove any punctuation. This is done to avoid taking the same word as two separate words because one of them is followed by a period, comma, or any other special character. Once this has been achieved...