Skip to content

Add attention layer to LSTM/word2vec model for sentiment analysis using tensorflow

Notifications You must be signed in to change notification settings

rantsandruse/lstm_attention_tf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tensorflow implementation of LSTM based sentiment analysis with attention layer

Bag of Words vs. Bag of Popcorn as an example

This is an extension of the previous project (lstm_word2vec). Now we have a tensorflow implementation of LSTM for the purpose of sentiment analysis, with the option of adding an attention layer.

In this project, I reused the I/O function and data prep functions from lstm_word2vec.

The major improvements are:

  1. Migration of code from keras to TF.
  2. Added an optional attention layer plus visualization.
  3. Added a batch generator class that can be easily used for different datasets.

The main_lstm.ipynb show cases how to leverage existing functions to train your own LSTM + attention layer model.

Addition of the attention layer appears to marginally improve the results of the testing set. But further testing is needed to establish the significance of the improvement...

About

Add attention layer to LSTM/word2vec model for sentiment analysis using tensorflow

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published