Home

Awesome

Convolutional Neural Network for Sentence Classification, in TensorFlow

This is a full (slightly modified and extended) TensorFlow implementation of the model presented by Kim in Convolutional Neural Networks for Sentence Classification.

With this code you can reproduce almost all results presented by Kim and the results we present in our Word Embeddings and Their Use In Sentence Classification Tasks paper.

Credits

If you're using this code please make sure you cite both following papers:

@article{Kim2014ConvNetSent,
  Author = {Kim, Yoon},
  Journal = {arXiv preprint arXiv:1408.5882},
  Title = {Convolutional Neural Networks for Sentence Classification},
  Year = {2014}
}
@article{Man2016WordEmbbed,
  Author = {Mandelbaum, Amit and Shalev, Adi},
  Journal = {arXiv preprint arXiv:1610.08229},
  Title = {Word Embeddings and Their Use In Sentence Classification Tasks},
  Year = {2016}
}

Also, small parts of the code were taken from:

Features

Requirements

Usage

Preperation:

  1. Clone the repository recursively to get all folder and subfolders
  2. Download Google's word embeddings binary file from https://code.google.com/p/word2vec/ extract it, and place it under data/ folder

Running:

  1. Choose the dataset you want to run on by uncommenting it in the last section of sentence_convnet_final.py
  2. Run python sentence_convnet_final.py --static <True/False> --random <True/False>
    Below is a list of modes and appropriate flags: