How to do sparse input text classification(dnn) using tensorflow
You can get complete example code from
https://github.com/chenghuige/hasky/tree/master/applications
Including
- How to parse libsvm dataset file to tfrecords
- Reading tfrecords and do dnn/logistic regresssion classifciation/regresssion
- Train + evaluate
- See train process (loss and metric track) in tensorboard
- Show how to use melt.train_flow to handle all other things(optimizer, learning rate, model saving, log …)
The main realated code:
melt.tfrecords/libsvm_decode #parsing libsvm file
melt.models.mlp
def forward(inputs,
num_outputs,
input_dim=None,
hiddens=[200],
activation_fn=tf.nn.relu,
weights_initializer=initializers.xavier_initializer(),
weights_regularizer=None,
biases_initializer=init_ops.zeros_initializer(),
biases_regularizer=None,
reuse=None,
scope=None
):
text-classfication/model.py shows how to use this
You must specify num_outputs and input_dim for sparse input dataset
For example 10 classes classficiation problem then num_outputs=10
If you do regresssion then num_outputs=1
input_dim should be the same as your dataset num input features
You may change hiddens, the default is [200], means only 1 hidden layer size 200,
You can use more hiddens like [200, 100, 100] means 3 hidden layers with size 200,100,100
You may also set hiddens [] empty , means you only do logistic regression
What's the diff between melt.layers.fully_connected and tf.contrib.layers.fully_connected?
Well similary but we will also deal with sparse input, the main difference in here
We use melt.matmul
|
def matmul(X, w): |
|
|
if isinstance(X, tf.Tensor): |
|
|
return tf.matmul(X,w) |
|
|
else: |
|
|
#X[0] index, X[1] value |
|
|
return tf.nn.embedding_lookup_sparse(w, X[0], X[1], combiner='sum') |
来自 <https://github.com/chenghuige/tensorflow-example/blob/master/util/melt/ops/ops.py>
Tensorboard show:


How to do sparse input text classification(dnn) using tensorflow的更多相关文章
- [转] Implementing a CNN for Text Classification in TensorFlow
Github上的一个开源项目,文档讲得极清晰 Github - https://github.com/dennybritz/cnn-text-classification-tf 原文- http:// ...
- [Tensorflow] RNN - 04. Work with CNN for Text Classification
Ref: Combining CNN and RNN for spoken language identification Ref: Convolutional Methods for Text [1 ...
- [Bayes] Maximum Likelihood estimates for text classification
Naïve Bayes Classifier. We will use, specifically, the Bernoulli-Dirichlet model for text classifica ...
- 论文阅读:《Bag of Tricks for Efficient Text Classification》
论文阅读:<Bag of Tricks for Efficient Text Classification> 2018-04-25 11:22:29 卓寿杰_SoulJoy 阅读数 954 ...
- 论文翻译——Character-level Convolutional Networks for Text Classification
论文地址 Abstract Open-text semantic parsers are designed to interpret any statement in natural language ...
- input:text 的value 和 attribute('value') 不是一回事
如题,input:text 当手工输入字符改变其值时,两者就不一样了. 要获得手工输入,不要用attribute('value'), 直接使用value: function getbyid(id){ ...
- jquery循环table中tbody的tr中input:text,将值进行拼接传入控制器并返回状态和描述
引用jquery $(function(){ $("#按钮id").click(function(){ var nums="";//变量 $("#ta ...
- input text输完自动跳到下一个
应用场景: 短信验证码输入 效果: input输入框,输入完以后自动跳转到下一个 思路: 四个输入框 进入聚焦到第一个输入框 第一个输入框输完一个字符后自动聚焦到下一个输入框 1.四个输入框 < ...
- RobotFramework自动化测试框架-移动手机自动化测试Input Text和Click Button关键字的使用
Input Text和Click Button Input Text 关键字一般用来给输入框进行输入操作,该关键字接收两个参数[ locator | text ]. 示例1:启动安卓手机上一个APP的 ...
随机推荐
- JavaScript面向对象的三大特性
1.JavaScript面向对象的三大特性 JavaScript的三大特性:封装性.继承性.多态性. 2.JavaScript实现封装特性 在一些静态类型的语言如java中,本身语法就提供了这些功能. ...
- GItHub Git 基础教程 常用命令 命令
最近复习了一下Git的使用,简单总结了一些.以供以后查阅和大家参考. 一,安装 首先是Linux下: 打开shell ,输入 sudo apt-get install git-core 之后回车输入密 ...
- static之静态初始化块
static之静态初始化块 所有的静态初始化块都优先执行,其次才是非静态的初始化块和构造函数,它们的执行顺序是: 父类的静态初始化块 子类的静态初始化块 父类的初始化块 父类的 ...
- 【搜索】传感器 @upcexam6023
时间限制: 1 Sec 内存限制: 128 MB 题目描述 SR最近新买了一款电子桌游 这个玩具内部是M个围成一圈的传感器.每个传感器都有开和关两种工作状态,分别用1和0表示.显然,从不同的位置触发沿 ...
- What is the NETStandard.Library metapackage?
In my last post, I took a quick look at the Microsoft.AspNetCore meta package. One of the libraries ...
- C10K问题
转自:https://www.jianshu.com/p/ba7fa25d3590 C10K问题由来 随着互联网的普及,应用的用户群体几何倍增长,此时服务器性能问题就出现.最初的服务器是基于进程/线程 ...
- Mybatis中使用集合、数组
一.简述 本文讲Mybatis中如何将传入参数为数组或者集合对象,进行遍历,组合Where条件中如in条件等内容. 有3种情况: 如果传入的是单参数且参数类型是一个List的时候,collection ...
- spring mvc 实战化项目之三板斧
laravel实战化项目之三板斧 spring mvc 实战化项目之三板斧 asp.net mvc 实战化项目之三板斧 接上文希望从一张表(tb_role_info 用户角色表)的CRUD展开spri ...
- Ubuntu18.04下可以完美运行Quake3 Arena
安装 其实很早就知道Linux下面可以跑Quake3, 但是一直没有付诸行动, 在硬盘上躺了很多年的Quake III Arena, 和Brood一起从来不舍得删, 昨天终于想起来试试. 安装很简单, ...
- keil软件错误总结.doc
KEIL编译错误信息表 错误代码及错误信息 错误释义 error 1: Out of memory 内存溢出 error 2: Identifier expected 缺标识符 error 3: ...