Code Monkey home page Code Monkey logo

cnn-sentence-classification-pytorch's Introduction

Convolutional Neural Networks for Sentence Classification

This is the implementation of Convolutional Neural Networks for Sentence Classification (Y.Kim, EMNLP 2014) on Pytorch.

Results

Below are results corresponding to all 4 models proposed in the paper for each dataset. Experiments have been done with a learning rate = 0.1 1 up to 300 100 epochs and all details are tuned to follow the settings defined in the paper.

(17.02.06) There was a bug that the best model is selected based on test acc, not on dev acc. The error has been corrected and so do results. Also note that the results can be somewhat different whenever the code is executed. Thanks! (WARNING: CV should be performed in case of MR, but only the random selection of dev(10%) and test(10%) set is done for simplicity.)

(Measure: Accuracy)

Model Dataset MR TREC
Rand Results 67.7 88.2
Baseline 76.1 91.2
Static Results 79.7 93.2
Baseline 81.0 92.8
Non-static Results 80.1 94.4
Baseline 81.5 93.6
Multichannel Results 79.8 93.6
Baseline 81.1 92.2

Specification

  • model.py: CNN sentnece classifier implementation proposed by Y. Kim.
  • run.py: train and test a model with configs.

Development Environment

  • OS: Ubuntu 16.04 LTS (64bit)
  • Language: Python 3.6.2.
  • GPU: GTX 1080

Requirements

This model is based on pre-trained Word2vec(GoogleNews-vectors-negative300.bin) by T.Mikolov et al. You should download this file and place it in the root folder.

Also you should follow library requirements specified in the requirements.txt.

numpy==1.12.1
gensim==2.3.0
scikit_learn==0.19.0

Execution

python run.py --help

usage: run.py [-h] [--mode MODE] [--model MODEL] [--dataset DATASET]
			  [--save_model] [--early_stopping] [--epoch EPOCH]
			  [--learning_rate LEARNING_RATE] [--gpu GPU]

-----[CNN-classifier]-----

optional arguments:
  -h, --help            show this help message and exit
  --mode MODE           train: train (with test) a model / test: test saved
						models
  --model MODEL         available models: rand, static, non-static,
						multichannel
  --dataset DATASET     available datasets: MR, TREC
  --save_model          whether saving model or not
  --early_stopping      whether to apply early stopping
  --epoch EPOCH         number of max epoch
  --learning_rate LEARNING_RATE
						learning rate
  --gpu GPU             the number of gpu to be used

cnn-sentence-classification-pytorch's People

Contributors

galsang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cnn-sentence-classification-pytorch's Issues

issues regarding training

train 할때 test set 이 들어가면 안되지 않나요?
코드를 보면 반영하신것같아서요..
감사합니다

issue with pytorch 0.3

ran into core dump (after word2vec loading):
(core dumped) python3 ./run.py --model non-static --dataset MR --gpu 1

Env: pytorch 0.3 (CUDA9.0)/Python 3.5.2/ubuntu 16.04.03 (numpy 1.14.1)

Replaced a few python 3.6 f-string to be 3.5 compatible.

Does it require pytorch 0.2.x?

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.