Full implementation of TextCNN by TensorFlow
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
data
notebook
src
LICENSE
README.md

README.md

TextCNN

An implementation of TextCNN from Convolutional Neural Networks for Sentence Classification .

It is a full implementation by Tensorflow including multi channels, cross-validation, utilization of pretrained embedding model.

Usage

  • train with single channel, random initialization
python train.py --num_epochs 1  --evaluate_every  10 ../data/ ../model/
  • train with single channel, pretrained embedding initialization
python train.py --num_epochs 1  --evaluate_every  10 --use_pretrained_embedding True ../data/ ../model/
  • train with multi channel, pretrained embedding initialization both
python train.py --num_epochs 1  --evaluate_every  10 --use_pretrained_embedding True --use_multi_channel True ../data/ ../model/
  • train with multi channel, pretrained embedding initialization and random initialization
python train.py --num_epochs 1  --evaluate_every  10 --use_multi_channel True ../data/ ../model/
  • for prediction
python pred.py --model_dir ../model/ --model_number 1546229209  ../data/ ../result --eval_unknown 0

Requirements

  • Python 3.6
  • TensorFlow 1.8
  • pickle
  • pandas
  • numpy
  • tqdm
  • gensim
  • sklearn
  • beautifulsoup4

DataSet

PreTrained model

実験結果

パラメータ
組み合わせ
Accuracy(Train) Accuracy(Test)
single channel,
random init
0.94 0.71
single channel,
pretrained init
0.74 0.72
multi channel,
pretrained &
random init
0.73 0.71
multi channel,
pretrained &
pretrained init
0.82 0.74

Reference