Giter VIP home page Giter VIP logo

rnn-text-classification-tf's Introduction

Recurrent Neural Network for Text Calssification

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.

rnn

Data: Movie Review

  • Movie reviews with one sentence per review. Classification involves detecting positive/negative reviews (Pang and Lee, 2005)
  • Download "sentence polarity dataset v1.0" at the Official Download Page
  • Located in "data/rt-polaritydata/" in my repository
  • rt-polarity.pos contains 5331 positive snippets
  • rt-polarity.neg contains 5331 negative snippets

Usage

Train

  • positive data is located in "data/rt-polaritydata/rt-polarity.pos"

  • negative data is located in "data/rt-polaritydata/rt-polarity.neg"

  • "GoogleNews-vectors-negative300" is used as pre-trained word2vec model

  • Display help message:

     $ python train.py --help
  • Train Example:

    1. Vanilla RNN

    vanilla

     $ 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"

    2. Long Short-Term Memory (LSTM) RNN

    lstm

     $ 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"

    3. Gated Reccurrent Unit (GRU) RNN

    gru

     $ 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"

Evalutation

  • 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"

Reference

  • Seeing stars: Exploiting class relationships for sentiment categorization with respect to rating scales (ACL 2005), B Pong et al. [paper]
  • Long short-term memory (Neural Computation 1997), J Schmidhuber et al. [paper]
  • Learning Phrase Representations using RNN Encoder–Decoder for Statistical Machine Translation (EMNLP 2014), K Cho et al. [paper]
  • Understanding LSTM Networks [blog]
  • RECURRENT NEURAL NETWORKS (RNN) – PART 2: TEXT CLASSIFICATION [blog]

rnn-text-classification-tf's People

Contributors

roomylee avatar

Watchers

James Cloos avatar Shubham Pachori avatar paper2code - bot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.