Tensorflow Implementation of Recurrent Neural Network (Vanilla, LSTM, GRU) for Text Classification
Tensorflow implementation of RNN(Recurrent Neural Network) for sentiment analysis, one of the text classification problems. There are three types of RNN models, 1) Vanilla RNN, 2) Long Short-Term Memory RNN and 3) Gated Recurrent Unit RNN.
positive data is located in <U>"data/rt-polaritydata/rt-polarity.pos"</U>
negative data is located in <U>"data/rt-polaritydata/rt-polarity.neg"</U>
"GoogleNews-vectors-negative300" is used as pre-trained word2vec model
Display help message:
python train.py --help
Train Example:
python train.py --cell_type "vanilla" \
-pos_dir "data/rt-polaritydata/rt-polarity.pos" \
-neg_dir "data/rt-polaritydata/rt-polarity.neg"\
-word2vec "GoogleNews-vectors-negative300.bin"
python train.py --cell_type "lstm" \
-pos_dir "data/rt-polaritydata/rt-polarity.pos" \
-neg_dir "data/rt-polaritydata/rt-polarity.neg"\
-word2vec "GoogleNews-vectors-negative300.bin"
python train.py --cell_type "gru" \
-pos_dir "data/rt-polaritydata/rt-polarity.pos" \
-neg_dir "data/rt-polaritydata/rt-polarity.neg"\
-word2vec "GoogleNews-vectors-negative300.bin"
Movie Review dataset has no test data.
If you want to evaluate, you should make test dataset from train data or do cross validation. However, cross validation is not implemented in my project.
The bellow example just use full rt-polarity dataset same the train dataset
Evaluation Example:
python eval.py \
-pos_dir "data/rt-polaritydata/rt-polarity.pos" \
-neg_dir "data/rt-polaritydata/rt-polarity.neg" \
-checkpoint_dir "runs/1523902663/checkpoints"