Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
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

Product type Book
Published in Jul 2020
Publisher Packt
ISBN-13 9781838989217
Pages 330 pages
Edition 1st Edition
Languages
Author (1):
Hyatt Saleh Hyatt Saleh
Profile icon Hyatt Saleh
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 $15.99/month. Cancel anytime