• Stars
    star
    959
  • Rank 47,306 (Top 1.0 %)
  • Language
    Jupyter Notebook
  • License
    MIT License
  • Created over 7 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Sentiment Analysis with LSTMs in Tensorflow

Sentiment Analysis with LSTMs

This repository contains the iPython notebook and training data to accompany the O'Reilly tutorial on sentiment analysis with LSTMs in Tensorflow. See the original tutorial to run this code in a pre-built environment on O'Reilly's servers with cell-by-cell guidance, or run these files on your own machine. There is also another file called Pre-Trained LSTM.ipynb which allows you to input your own text, and see the output of the trained network.

Downloading Data

Before running the notebook, you'll first need to download all data we'll be using. This data is located in the models.tar.gz and training_data.tar.gz tarballs. We will extract these into the same directory as Oriole LSTM.ipynb. As always, the first step is to clone the repository.

git clone https://github.com/adeshpande3/LSTM-Sentiment-Analysis.git

Next, we will navigate to the newly created directory and run the following commands.

tar -xvzf models.tar.gz
tar -xvzf training_data.tar.gz

Requirements and Installation

In order to run the iPython notebook, you'll need the following libraries.

TensorFlow 1.2 and later

In order to load the models without errors you need to convert the checkpoints using the converter provided by TensorFlow:

wget https://raw.githubusercontent.com/tensorflow/tensorflow/master/tensorflow/contrib/rnn/python/tools/checkpoint_convert.py
python checkpoint_convert.py models/pretrained_lstm.ckpt-90000 converted-checkpoints/pretrained_lstm-90000.ckpt

You should also replace the original models folder if you don't want to modify the code:

rm -rf models
mv converted-checkpoints models

Docker

With Docker, you could just mount the repository and exec it.

  1. Install Docker. Follow the docker guide.

  2. Build docker image

    cd LSTM-Sentiment-Analysis
    docker build -t="@yourname/tensorflow_1.1.0_py3" .
  3. Run the container from the image

    docker run -p 8888:8888 --name=tensorflow_yourname_py3 -v /@YourDir/LSTM-Sentiment-Analysis:/LSTM-Sentiment-Analysis -it @yourname/tensorflow_1.1.0_py3

    and visit the URL(http://localhost:8888/)

  4. Stop and restart the container

    docker stop tensorflow_yourname_py3
    docker start tensorflow_yourname_py3
    docker attach tensorflow_yourname_py3

    If jupyter is down, relaunch it by using the command below.

    cd LSTM-Sentiment-Analysis
    jupyter notebook --ip=0.0.0.0 --allow-root

Installing Anaconda Python and TensorFlow

The easiest way to install TensorFlow as well as NumPy, Jupyter, and matplotlib is to start with the Anaconda Python distribution.

  1. Follow the installation instructions for Anaconda Python. We recommend using Python 3.6.

  2. Follow the platform-specific TensorFlow installation instructions. Be sure to follow the "Installing with Anaconda" process, and create a Conda environment named tensorflow.

  3. If you aren't still inside your Conda TensorFlow environment, enter it by opening your terminal and typing

    source activate tensorflow
  4. If you haven't done so already, download and unzip this entire repository from GitHub, either interactively, or by entering

    git clone https://github.com/adeshpande3/LSTM-Sentiment-Analysis
  5. Use cd to navigate into the top directory of the repo on your machine

  6. Launch Jupyter by entering

    jupyter notebook

    and, using your browser, navigate to the URL shown in the terminal output (usually http://localhost:8888/)

More Repositories

1

Tensorflow-Programs-and-Tutorials

Implementations of CNNs, RNNs, GANs, etc
Jupyter Notebook
1,046
star
2

Machine-Learning-Links-And-Lessons-Learned

List of all the lessons learned, best practices, and links from my time studying machine learning
986
star
3

Facebook-Messenger-Bot

Facebook chatbot that I trained to talk like me using Seq2Seq
Python
705
star
4

Generative-Adversarial-Networks

Tutorial on GANs
Jupyter Notebook
285
star
5

March-Madness-ML

Machine learned bracketology
Python
191
star
6

UCLA-Course-Notes

My notes from the classes I've taken at UCLA
101
star
7

Pandas-Tutorial

Tutorial on Using Pandas
Jupyter Notebook
79
star
8

March-Madness-2017

Kaggle Competition for Predicting NCAA Basketball Tourney Games
Jupyter Notebook
70
star
9

Chatbot-Flask-Server

The Flask server that communicates with my FB Messenger chatbot
Python
58
star
10

Machine-Learning-Notes

Notes for several Machine Learning and Deep Learning courses, textbooks, and talks
56
star
11

MachineLearningReimplementations

Just trying to reimplement machine learning techniques like linear regression, neural nets, logistic regression, etc in Python
Python
32
star
12

NLP-Stuff

Programs with word vectors, RNN, NLP stuff, etc
Jupyter Notebook
18
star
13

Quandl-Machine-Learning

Using the Quandl API to (try) to apply ML to the stock market
Jupyter Notebook
13
star
14

NBA-Data-Visualization

Visualizations of statistics for NBA players
Jupyter Notebook
12
star
15

MLB_Win_Predictor

Neural network that predicts the number of wins for a baseball team based on the importance of different statistical categories and their influence on a team's success.
Lua
11
star
16

Music-Analysis

Trying to apply deep learning to music analysis
Jupyter Notebook
11
star
17

Kaggle-Zillow

Repo for the $1.2 million Kaggle competition
Jupyter Notebook
11
star
18

PyTorch-Programs

Trying out PyTorch because the hype is real
Jupyter Notebook
10
star
19

ReinforcementLearning

A collection of simple RL agents in different environments
Python
10
star
20

Job-Descriptions-Hacker-Rank-Comp

Hackerrank ML Competition
Jupyter Notebook
9
star
21

Kaggle-MNIST

Simple ConvNet to classify digits from the famous MNIST dataset
Python
9
star
22

KaggleTitanic

Kaggle Titanic Survival ML Competition
Python
6
star
23

WalmartLabs-ML-CodeSprint

Hackerrank ML Contest
Python
6
star
24

Two-Sigma-Renting-Listing-Competition

Kaggle Competition for Predicting Interest of New Rental Listings
Jupyter Notebook
6
star
25

OpenAI_Gym_Universe

Playing around with Open AI's reinforcement learning frameworks
Python
6
star
26

MLB

MLB Web App using React
JavaScript
6
star
27

CS-145-Project

CS 145 Yelp Project
Python
4
star
28

Tech-Plus-You-March-Madness

My Machine Learning + March Madness demo for UCLA's Tech+You event
Python
3
star
29

KaggleGhosts

Kaggle Ghosts ML Competition
Jupyter Notebook
2
star
30

Accelerometer-Pogram

Program that reads in accelerometer data (x, y, z direction values), trains a neural network program for classification, and then outputs predictions for a set of test data
Lua
2
star