Giter Site home page Giter Site logo

sportzhang / zh_cnn_text_classify Goto Github PK

View Code? Open in Web Editor NEW

This project forked from clayandgithub/zh_cnn_text_classify

0.0 1.0 0.0 13.28 MB

基于CNN的中文文本分类算法(可应用于垃圾邮件过滤、情感分析等场景)

Python 100.00%

zh_cnn_text_classify's Introduction

基于cnn的中文文本分类算法

简介

参考IMPLEMENTING A CNN FOR TEXT CLASSIFICATION IN TENSORFLOW实现的一个简单的卷积神经网络,用于中文文本分类任务(此项目使用的数据集是中文垃圾邮件识别任务的数据集),数据集下载地址:百度网盘

区别

原博客实现的cnn用于英文文本分类,没有使用word2vec来获取单词的向量表达,而是在网络中添加了embedding层来来获取向量。
而此项目则是利用word2vec先获取中文测试数据集中各个的向量表达,再输入卷积网络进行分类。

运行方法

训练

run python train.py to train the cnn with the spam and ham files (only support chinese!) (change the config filepath in FLAGS to your own)

在tensorboard上查看summaries

run tensorboard --logdir /{PATH_TO_CODE}/runs/{TIME_DIR}/summaries/ to view summaries in web view

测试、分类

run python eval.py --checkpoint_dir /{PATH_TO_CODE/runs/{TIME_DIR}/checkpoints}
如果需要分类自己提供的文件,请更改相关输入参数

如果需要测试准确率,需要指定对应的标签文件(input_label_file):
python eval.py --input_label_file /PATH_TO_INPUT_LABEL_FILE
说明:input_label_file中的每一行是0或1,需要与input_text_file中的每一行对应。
在eval.py中,如果有这个对照标签文件input_label_file,则会输出预测的准确率

推荐运行环境

python 2.7.13 :: Anaconda 4.3.1 (64-bit)
tensorflow 1.0.0
gensim 1.0.1
Ubuntu16.04 64bit

说明

若按照以上步骤无法正常运行程序,请在Issues或在博客中提问,我会尽快回复。

zh_cnn_text_classify's People

Watchers

kevin 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.