huizhang0110 / tf-text-classification

CNN and RNN with Attention for Chinese Text Classification in Tensorflow

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Environment setup

  • Requirements: python3, tensorflow>=1.0, sklearn, numpy, pandas and jieba
pip install -r requirements.txt

Data preprocessing

  • Text cleaning and word segmentation, data format: label\tsentence
python seg_words.py

Training models

  • CNN
python train_cnn.py
  • RNN with attention
python train_rnn.py

Evaluating models

python eval.py --checkpoint_dir=./runs/textrnn/trained_result_1512462690/checkpoints --model_type=RNN

If evaluation data has labels, has_label should be set to True.

About

CNN and RNN with Attention for Chinese Text Classification in Tensorflow

License:Apache License 2.0


Languages

Language:Python 100.0%