Giter Site home page Giter Site logo

rnn-classifier's Introduction

Recurrent neural network classifier with self-attention

A minimal RNN-based classification model (many-to-one) with self-attention. Tested on master branches of both torch (commit 5edf6b2) and torchtext (commit c839a79). The volatile warnings that might be printed are due to using pytorch version 4 with torchtext.

Inspired by @Keon's barebone seq2seq implementation, this repository aims to provide a minimal implementation of an RNN classifier with self-attention.

Model description:

  • LSTM or GRU encoder for the embedded input sequence
  • Scaled dot-product self-attention with the encoder outputs as keys and values and the hidden state as the query
  • Logistic regression classifier on top of attention outputs

Arguments:

  --data DATA        Corpus: [SST, TREC, IMDB]
  --model MODEL      type of recurrent net [LSTM, GRU]
  --emsize EMSIZE    size of word embeddings [Uses pretrained on 50, 100, 200, 300]
  --hidden HIDDEN    number of hidden units for the RNN encoder
  --nlayers NLAYERS  number of layers of the RNN encoder
  --lr LR            initial learning rate
  --clip CLIP        gradient clipping
  --epochs EPOCHS    upper epoch limit
  --batch_size N     batch size
  --drop DROP        dropout
  --bi               bidirectional encoder
  --cuda             [DONT] use CUDA
  --fine             use fine grained labels in SST # currently unused

A sample set of arguments can be viewed in run.sh.

Results

Accuracy on test set after 5 epochs of the model with sample params:

SST TREC IMDB
run.sh 80.340% 87.000% 86.240%

rnn-classifier's People

Contributors

mttk avatar

Watchers

James Cloos 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.