Code Monkey home page Code Monkey logo

text_classify's Introduction

text_classify

针对Cnews数据集进行分类,使用了torchtext进行文本预处理,使用textcnn,lstm提取特征做分类。
代码中使用的need_bertembedding可以通过如下工具自动生成: https://github.com/xmxoxo/BERT-Vector

数据集如下

链接:https://pan.baidu.com/s/1t-MGwuntLgjOwlJKHh3oNg 提取码:j2yr

代码主体

  • models 网络定义,包含了textcnn和lstm的网络构建。
  • train_eval.py 训练代码,验证代码,测试单条数据代码,可直接微小改动构建flask服务。
  • utils.py 数据处理部分,主要使用torchtext完成了数据的词典映射,pad,shuffle等操作。
  • run.py 包含了训练和验证代码,以及单句测试
  • data data文件夹从百度网盘下载,直接考入即可。
  • data_tag 过程中生成的文件,包括模型和日志。

结果

结果具有随机性,大致差不多如下: avatar

avatar

代码对应的博客地址:

https://blog.csdn.net/qq_25992377/article/details/105012948
https://blog.csdn.net/qq_25992377/article/details/105013476
https://blog.csdn.net/qq_25992377/article/details/105019786

reference

https://github.com/649453932/Chinese-Text-Classification-Pytorch
http://mlexplained.com/2018/02/08/a-comprehensive-tutorial-to-torchtext/ en548708

text_classify's People

Contributors

mathcrazyy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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