Skip to content

Convolutional Neural Networks for Sentence Classification(TextCNN) implements by TensorFlow

Notifications You must be signed in to change notification settings

DongjunLee/text-cnn-tensorflow

Repository files navigation

text-cnn

This code implements Convolutional Neural Networks for Sentence Classification models.

  • Figure 1: Illustration of a CNN architecture for sentence classification

figure-1

Requirements

  • Python 3.6
  • TensorFlow 1.4
  • hb-config

Features

Todo

Config

example: cornell-movie-dialogs.yml

data:
  base_path: 'data/'
  processed_path: 'tiny_processed_data'
  max_seq_length: 30
  num_classes: 2
  PAD_ID: 0

model:
  embed_dim: 32
  num_filters: 16
  filter_sizes:
    - 2
    - 3
    - 4
  dropout: 0.5

train:
  batch_size: 1
  learning_rate: 0.001
  train_steps: 10000
  model_dir: 'logs/check_tiny'
  save_every: 1000
  loss_hook_n_iter: 1
  check_hook_n_iter: 10
  min_eval_frequency: 10

Usage

Install requirements.

pip install -r requirements.txt

First, check if the model is valid.

python main.py --config check_tiny --mode train

Then, download Dataset and train it.

sh prepare_dataset
python main.py --config sentiment_dataset --mode train_and_evaluate

Tensorboard

tensorboard --logdir logs

Reference

About

Convolutional Neural Networks for Sentence Classification(TextCNN) implements by TensorFlow

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published