Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
The Deep Learning with PyTorch Workshop

You're reading from   The Deep Learning with PyTorch Workshop Build deep neural networks and artificial intelligence applications with PyTorch

Arrow left icon
Product type Paperback
Published in Jul 2020
Publisher Packt
ISBN-13 9781838989217
Length 330 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Hyatt Saleh Hyatt Saleh
Author Profile Icon Hyatt Saleh
Hyatt Saleh
Arrow right icon
View More author details
Toc

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...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime