Skip to content

Classifying movie reviews as positive or negative using Word2Vec Embeddings & LSTM network

Notifications You must be signed in to change notification settings

luzijian9/Movie-Review-Sentiment-Analysis-LSTM-Pytorch

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Sentiment Analysis of Movie Reviews w/ Word2Vec & LSTM (PyTorch)

This is my implementation of Sentiment Analysis using Long-Short Term Memory (LSTM) Network. The code performs:

  1. Loading and pre-processing raw reviews & labels data
  2. Building a deep neural network including Word2Vec embeddings and LSTM layers
  3. Test the performance of the model in classifying a random review as postive or negative.

Main Components of the Network

I. Word2Vec Embedding - used to reduce dimensionality, as there are tens of thousands of words in the entire vocabulary of all reviews. Each of those words are represented as vectors in 400-dimension space.

II. LSTM Layers - used to look at the review texts as the sequence of inputs, rather than individual, in order to take advantage of the bigger context of the text.

Repository

This repository contains:

  • sentiment_analysis_LSTM.py : Complete code for implementing the sentiment analysis of movie reviews using LSTM network
  • data folder : includes reviews.txt (contains all reivews) & labels.txt (contains all corresponding labels)

List of Hyperparameters Used:

  • Batch Size = 50
  • Sequence Length for Movie Reviews = 200
  • Embedding Dimension = 400
  • Number of hidden nodes in LSTM = 256
  • Number of LSTM Layers = 2
  • Learning Rate = 0.001
  • Gradient Clip Maximum Threshold= 5
  • Number of Epochs = 4

Sources

I referenced the following sources for building & debugging the final model :

About

Classifying movie reviews as positive or negative using Word2Vec Embeddings & LSTM network

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%