All Projects → dongjun-Lee → rnn-text-classification-tf

dongjun-Lee / rnn-text-classification-tf

Licence: other
Tensorflow implementation of Attention-based Bidirectional RNN text classification.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to rnn-text-classification-tf

automatic-personality-prediction
[AAAI 2020] Modeling Personality with Attentive Networks and Contextual Embeddings
Stars: ✭ 43 (+65.38%)
Mutual labels:  text-classification, attention-mechanism
Text classification
all kinds of text classification models and more with deep learning
Stars: ✭ 7,179 (+27511.54%)
Mutual labels:  text-classification, attention-mechanism
3HAN
An original implementation of "3HAN: A Deep Neural Network for Fake News Detection" (ICONIP 2017)
Stars: ✭ 29 (+11.54%)
Mutual labels:  text-classification, attention-mechanism
Textclassifier
Text classifier for Hierarchical Attention Networks for Document Classification
Stars: ✭ 985 (+3688.46%)
Mutual labels:  text-classification, attention-mechanism
Hierarchical Multi Label Text Classification
The code of CIKM'19 paper《Hierarchical Multi-label Text Classification: An Attention-based Recurrent Network Approach》
Stars: ✭ 133 (+411.54%)
Mutual labels:  text-classification, attention-mechanism
A Pytorch Tutorial To Text Classification
Hierarchical Attention Networks | a PyTorch Tutorial to Text Classification
Stars: ✭ 184 (+607.69%)
Mutual labels:  text-classification, attention-mechanism
Chatbot cn
基于金融-司法领域(兼有闲聊性质)的聊天机器人,其中的主要模块有信息抽取、NLU、NLG、知识图谱等,并且利用Django整合了前端展示,目前已经封装了nlp和kg的restful接口
Stars: ✭ 791 (+2942.31%)
Mutual labels:  text-classification, attention-mechanism
Sarcasm Detection
Detecting Sarcasm on Twitter using both traditonal machine learning and deep learning techniques.
Stars: ✭ 73 (+180.77%)
Mutual labels:  text-classification, attention-mechanism
Hierarchical Attention Networks
TensorFlow implementation of the paper "Hierarchical Attention Networks for Document Classification"
Stars: ✭ 75 (+188.46%)
Mutual labels:  text-classification, attention-mechanism
Document Classifier Lstm
A bidirectional LSTM with attention for multiclass/multilabel text classification.
Stars: ✭ 136 (+423.08%)
Mutual labels:  text-classification, attention-mechanism
TS3000 TheChatBOT
Its a social networking chat-bot trained on Reddit dataset . It supports open bounded queries developed on the concept of Neural Machine Translation. Beware of its being sarcastic just like its creator 😝 BDW it uses Pytorch framework and Python3.
Stars: ✭ 20 (-23.08%)
Mutual labels:  attention-mechanism, bidirectional-rnn
Very-deep-cnn-tensorflow
Very deep CNN for text classification
Stars: ✭ 18 (-30.77%)
Mutual labels:  text-classification
ChangeFormer
Official PyTorch implementation of our IGARSS'22 paper: A Transformer-Based Siamese Network for Change Detection
Stars: ✭ 220 (+746.15%)
Mutual labels:  attention-mechanism
hexia
Mid-level PyTorch Based Framework for Visual Question Answering.
Stars: ✭ 24 (-7.69%)
Mutual labels:  attention-mechanism
transfer-learning-text-tf
Tensorflow implementation of Semi-supervised Sequence Learning (https://arxiv.org/abs/1511.01432)
Stars: ✭ 82 (+215.38%)
Mutual labels:  text-classification
character-level-cnn
Keras implementation of Character-level CNN for Text Classification
Stars: ✭ 56 (+115.38%)
Mutual labels:  text-classification
CIAN
Implementation of the Character-level Intra Attention Network (CIAN) for Natural Language Inference (NLI) upon SNLI and MultiNLI corpus
Stars: ✭ 17 (-34.62%)
Mutual labels:  attention-mechanism
ulm-basenet
Implementation of ULMFit algorithm for text classification via transfer learning
Stars: ✭ 94 (+261.54%)
Mutual labels:  text-classification
organic-chemistry-reaction-prediction-using-NMT
organic chemistry reaction prediction using NMT with Attention
Stars: ✭ 30 (+15.38%)
Mutual labels:  attention-mechanism
LSTM-Attention
A Comparison of LSTMs and Attention Mechanisms for Forecasting Financial Time Series
Stars: ✭ 53 (+103.85%)
Mutual labels:  attention-mechanism

text-classification-tensorflow

Tensorflow implementation of Attention-based Bidirectional RNN text classification. (with naive Bidirectional RNN model as a baseline)

Requirements

  • Python 3
  • Tensorflow
  • pip install -r requirements.txt

Usage

Prepare Data

We are using pre-processed version of Twitter Sentiment Classification Data. To use sample data (100K train/30K test),

$ unzip sample_data/sample_data.zip -d sample_data

To use full data (1.2M train/0.4M test), download it from google drive link.

To use Glove pre-trained embedding, download it via

$ python download_glove.py

Train

To train the model with sample data,

$ python train.py

Train data is split to train set(85%) and validation set(15%). Every 2000 steps, the classification accuracy is tested with validation set and the best model is saved.

To use Glove pre-trained vectors as initial embedding,

$ python train.py --glove

Additional Hyperparameters

$ python train.py -h
usage: train.py [-h] [--train_tsv TRAIN_TSV] [--model MODEL] [--glove]
                [--embedding_size EMBEDDING_SIZE] [--num_hidden NUM_HIDDEN]
                [--num_layers NUM_LAYERS] [--learning_rate LEARNING_RATE]
                [--batch_size BATCH_SIZE] [--num_epochs NUM_EPOCHS]
                [--keep_prob KEEP_PROB] [--checkpoint_dir CHECKPOINT_DIR]

optional arguments:
  -h, --help            show this help message and exit
  --train_tsv TRAIN_TSV
                        Train tsv file.
  --model MODEL         naive | att
  --glove               Use glove as initial word embedding.
  --embedding_size EMBEDDING_SIZE
                        Word embedding size. (For glove, use 50 | 100 | 200 | 300)
  --num_hidden NUM_HIDDEN
                        RNN Network size.
  --num_layers NUM_LAYERS
                        RNN Network depth.
  --learning_rate LEARNING_RATE
                        Learning rate.
  --batch_size BATCH_SIZE
                        Batch size.
  --num_epochs NUM_EPOCHS
                        Number of epochs.
  --keep_prob KEEP_PROB
                        Dropout keep prob.
  --checkpoint_dir CHECKPOINT_DIR
                        Checkpoint directory.

Test

To test classification accuracy for test data,

$ python test.py

To use custom data,

$ python test.py --test_tsv=<CUSTOM_TSV>

Sample Test Results

Trained and tested with full data with default hyper-parameters,

Model Naive Naive(+Glove) Attention Attention(+Glove)
Accuracy 0.574 0.578 0.811 0.820

References

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].