1 Star 0 Fork 13

winterlac / CoolNLTK

forked from Rocky / CoolNLTK 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

CoolNLTK

文本分类工具集

特点

  1. 多模型,相对统一的数据输入,方便效果对比
  2. 可直接用于生产
  3. 使用相对简单

已实现模型

  1. TextCNN
  2. TextRNN
  3. CLstm

模型训练

1.train file

使用和fastText一样的数据输入

测试数据可以从fastText的代码中下载然后copy到./datasets/dbpedia目录下 具体方法, 参照fatText的文档,运行其中的classification-example.sh就能得到dbpedia.traindbpedia.test

注意:类别标签是从1开始的,因为在后面训练的时候需要做pad 0 的操作,为了避免混淆。

一个例子如下:

__label__7 , joseph purdy homestead
__label__13 , forever young ( 1992 film )
__label__11 , nepenthes ' boca rose
__label__6 , mv eilean bhearnaraigh

train/main.sh指定相关的训练样本路径


TRAIN_FILE=./datasets/dbpedia/dbpedia.train
TEST_FILE=./datasets/dbpedia/dbpedia.test

# 使用的模型 可选cnn, bilstm, clstm
MODEL=cnn

# 中间文件输出路径
DATA_OUT_DIR=./datasets/dbpedia/


# 模型输出路径
MODEL_OUT_DIR=./results/dbpedia/

2.embedding

生成word2vec的训练数据

./main.sh pre

训练词向量

./main.sh vec

3.map file

这一步产生需要的映射文件

./main.sh map

4.tfrecord

产生tfrecord 文件

./main.sh data

5.train

模型训练

./main.sh train

6.模型导出

导出成pb文件,可用Java,Go语言读取

./main export

模型使用

predict.py中有例子,读取上面训练好导出的模型,和产生的vocab.json文件

TextRNN、TextCNN,CLstm 模型能共用这个模块

todo

  • 根据最新的tensorflow重构代码
  • 修改tfrecord 文件的格式,产生多分而不是一份
  • 添加tensorboard 

计划实现更多模型,包括但不限于下面这些

  1. HAM
  2. RCNN
  3. Recurrent Entity Network
  4. Dynamic Memory Network
MIT License Copyright (c) 2018 wu.zheng Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Automatic Text Categorization by deep learning 展开 收起
Python
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Python
1
https://gitee.com/winterlac/CoolNLTK.git
git@gitee.com:winterlac/CoolNLTK.git
winterlac
CoolNLTK
CoolNLTK
master

搜索帮助

14c37bed 8189591 565d56ea 8189591