Giter Site home page Giter Site logo

cnn-rnf's Introduction

Convolutional Neural Networks with Recurrent Neural Filters

Author: Yi Yang

Contact: [email protected]

Basic description

This is the Python implementation of the recurrent neural filters for convolutional neural networks, described in

Yi Yang
"Convolutional Neural Networks with Recurrent Neural Filters"
EMNLP 2018

[pdf]

BibTeX

@inproceedings{yang2018convolutional,
  title={Convolutional Neural Networks with Recurrent Neural Filters},
  author={Yang, Yi},
  booktitle={Proceedings of Empirical Methods in Natural Language Processing},
  year={2018}
}

Dependencies

  1. TensorFlow
  2. Keras
  3. Optional: CUDA Toolkit for GPU programming.

Data

We use the Stanford Sentiment Treebank (SST) datasets processed by Lei et al. (2015). Please put all the files of this directory into the data/sst_text_convnet folder.

Please download the pre-trained GloVe vectors and unzip it into the data folder.

Results

Running the code requires two steps:

  1. Prepare the data and generate the required data files

    # binary sentiment classification
    python proc_data.py data/stsa.binary.pkl
    
    # fine-grained sentiment classification
    python proc_data.py --train-path data/sst_text_convnet/stsa.fine.phrases.train \
                        --dev-path   data/sst_text_convnet/stsa.fine.dev \
                        --test-path  data/sst_text_convnet/stsa.fine.test \
                        data/stsa.fine.pkl
    
  2. CNNs for sentiment classification with linear filters and recurrent neural filters (RNFs)

    # binary sentiment classification
    python cnn_keras.py --filter-type linear data/stsa.binary.pkl
    python cnn_keras.py --filter-type rnf data/stsa.binary.pkl
    
    # fine-grained sentiment classification
    python cnn_keras.py --filter-type linear data/stsa.fine.pkl
    python cnn_keras.py --filter-type rnf data/stsa.fine.pkl
    

Hyperparameter tunning may be needed to achive the best results reported in the paper.

Unfortunately, I failed to find out how to entirely eliminate randomness for training Keras-based models. However, you should be easily able to achieve 89%+ and 52%+ accuracies with RNFs after a few runs.

Recurrent neural filters consistently outperform linear filters across different filter widths, by 3-4% accuracy.

cnn-rnf's People

Contributors

kpfleming avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.