Giter Club home page Giter Club logo

cnn-text-classification-pytorch's Introduction

CNN for Text Classification

This is an implementation of Yoon Kim's "Convolutional Neural Network for Sentence Classification" paper in Pytorch.

Dataset

An dataset is composed of a TSV file and a vocab file. The TSV file has two fields which are separated by a TAB chracter. The first field is a label which should '0' or '1'. (I think this should be changed.) The second field is a sentence that composed of words separated by a whitespace.

The vocab file contains all valid words. A word is in a line.

The MR dataset is provided as a sample. You can find it in /dataset/mr/ directory. There is also an configuration file 'config.yml' describing where the data files is.

Training

A new experiment can be started by following.

python text_classification.py train -c dataset/mr/config.yml conf/small.yml -m ./model

Training status can be monitored by tensorboard.

tensorboard --logdir ./model

An aborted traning session can be resumed by following.

python text_classification.py train -m ./model

Prediction

To use a text file for prediction:

python text_classification.py predict -m ./model INPUT_FILE

Also, stdin can be used as in input instead of a text file.

python text_classification.py predict -m ./model -

cnn-text-classification-pytorch's People

Contributors

yongjincho avatar

Stargazers

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

Watchers

 avatar  avatar

cnn-text-classification-pytorch's Issues

F.softmax(logits) and CrossEntropyLoss() is right?

torch.nn.CrossEntropyLoss(weight=None, size_average=None, ignore_index=-100, reduce=None, reduction='mean')[SOURCE]
This criterion combines nn.LogSoftmax() and nn.NLLLoss() in one single class. I guess F.softmax(logits) and CrossEntropyLoss() used together is wrong?

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.