Coder Social home page Coder Social logo

gzilt-playground / char-cnn-text-classification-tensorflow Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kinni/char-cnn-text-classification-tensorflow

0.0 1.0 0.0 72 KB

Simple Convolutional Neural Network (CNN) for sentiment classification of Chinese movie reviews.

License: Apache License 2.0

Python 100.00%

char-cnn-text-classification-tensorflow's Introduction

char-cnn-text-classification-tensorflow

Simple Convolutional Neural Network (CNN) for text classification at character level. In this project we will implement a Chinese Movie Sentiment (Positive/Negative) Classifier with CNN using TensorFlow. A manually labeled small corpus (HK movie reviews) has been uploaded for you to try out the network.

Mostly reused code from https://github.com/dennybritz/cnn-text-classification-tf which was posted by Denny Britz. Check out his great blog post on CNN classification http://www.wildml.com/2015/12/implementing-a-cnn-for-text-classification-in-tensorflow/.

Things are modified from the original author:

  • modified the data helpers to support Chinese to train the embeddings at character level
  • added Tensorboard visualization for embeddings
  • added sample.py which will generate prediction output
  • added serve.py which will serve the classifier via Flask

Requirements

  • Tensorflow 1.0 or up

Basic Usage

To train with the Chinese movie reviews dataset, run: python train.py

To visualize results and embeddings, run: tensorboard --logdir ./runs/1492654198/summaries/

To predict from a trained model, run with checkpoint_dir argument python sample.py --checkpoint_dir=./runs/1492654198/checkpoints/ --text="套戲好鬼悶"

To serve the model via a Flask API, run: python serve.py --checkpoint_dir=./runs/1492656039/checkpoints/ then send a HTTP POST request to http://localhost:5000/predict with the following json body: {"text": "套戲好鬼悶"}

TODO

Some updates will be published soon.

  • Train the embeddings at word level using jieba's tokenizer or other pre-trained word embeddings
  • Use high level APIS such as tf.layers or tf.keras(will be available in TensorFLow 1.2)

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.