Skip to content

Text classification models: cnn, self-attention, cnn-rnf, rnn-att, capsule-net. TensorFlow. Single GPU or multi GPU

Notifications You must be signed in to change notification settings

Li-Ming-Fan/text_classification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Text Classification (Plain Sequence)

Experiments on sentence classification. Task-Independent Model Baseboard/Wrapper.

Single GPU or Multi GPU.

Models

  • CNN
  • CNN-RNF
  • RNN & Attention-Pooling
  • Multi-head Self-Attention
  • Capsule Network

Description

To run this repo:

1, python script_data.py

2, python script_runner.py --model_tag=cnn --mode=train

3, python script_runner.py --model_tag=cnn --mode=predict


To specifiy gpu to be used:

2', python script_runner.py --model_tag=cnn --mode=train --gpu=0

2'', python script_runner.py --model_tag=cnn --mode=train --gpu=0,1


Using package jieba for token-segmentation:

pip install jieba

Using package Zeras for model baseboard:

pip install Zeras==0.4.4

Task-independent Model Baseboard/Wrapper

A supervised learning project commonly has the following modules:

  • Dataset module (including data-preprocessing, data-batching)
  • Model defining, or graph defining module
  • Training, validation, prediction procedures

The train/valid/pred procedures for supervised learnings are much the same for different tasks, so I tried to implement the model wrapper to be task-independent. Then one can focus on data preprocessing and model construction jobs.

References

1, Convolutional Neural Networks for Sentence Classification ( https://arxiv.org/abs/1408.5882 )

2, Convolutional Neural Networks with Recurrent Neural Filters ( https://arxiv.org/abs/1808.09315 )

3, Neural Machine Translation by Jointly Learning to Align and Translate ( https://arxiv.org/abs/1409.0473 )

4, Attention Is All You Need ( https://arxiv.org/abs/1706.03762 )

5, Dynamic Routing Between Capsules ( https://arxiv.org/abs/1710.09829 )

6, Information Aggregation via Dynamic Routing for Sequence Encoding ( https://arxiv.org/abs/1806.01501 )

7, https://github.com/gaussic/text-classification-cnn-rnn

8, https://github.com/brightmart/text_classification

9, https://github.com/bloomberg/cnn-rnf

...

About

Text classification models: cnn, self-attention, cnn-rnf, rnn-att, capsule-net. TensorFlow. Single GPU or multi GPU

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages