1. Learn
  2. /
  3. Courses
  4. /
  5. Deep Learning for Text with PyTorch

Exercise

Build a CNN model for text

PyBooks has successfully built a book recommendation engine. Their next task is to implement a sentiment analysis model to understand user reviews and gain insight into book preferences.

You'll use a Convolutional Neural Network (CNN) model to classify text data (book reviews) based on their sentiment.

torch, torch.nn as nn, and torch.nn.functional as F have been loaded for you.

Instructions

100 XP
  • Initialize the embedding layer in the __init__() method.
  • Apply the convolutional layer self.conv to the embedded text within the forward() method.
  • Apply the ReLU activation to this layer within the forward() method.