You can get complete example code from

https://github.com/chenghuige/hasky/tree/master/applications

Including

  1. How to parse libsvm dataset file to tfrecords
  2. Reading tfrecords and do dnn/logistic regresssion classifciation/regresssion
  3. Train + evaluate
  4. See train process (loss and metric track) in tensorboard
  5. 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的更多相关文章

  1. [转] Implementing a CNN for Text Classification in TensorFlow

    Github上的一个开源项目,文档讲得极清晰 Github - https://github.com/dennybritz/cnn-text-classification-tf 原文- http:// ...

  2. [Tensorflow] RNN - 04. Work with CNN for Text Classification

    Ref: Combining CNN and RNN for spoken language identification Ref: Convolutional Methods for Text [1 ...

  3. [Bayes] Maximum Likelihood estimates for text classification

    Naïve Bayes Classifier. We will use, specifically, the Bernoulli-Dirichlet model for text classifica ...

  4. 论文阅读:《Bag of Tricks for Efficient Text Classification》

    论文阅读:<Bag of Tricks for Efficient Text Classification> 2018-04-25 11:22:29 卓寿杰_SoulJoy 阅读数 954 ...

  5. 论文翻译——Character-level Convolutional Networks for Text Classification

    论文地址 Abstract Open-text semantic parsers are designed to interpret any statement in natural language ...

  6. input:text 的value 和 attribute('value') 不是一回事

    如题,input:text 当手工输入字符改变其值时,两者就不一样了. 要获得手工输入,不要用attribute('value'), 直接使用value: function getbyid(id){ ...

  7. jquery循环table中tbody的tr中input:text,将值进行拼接传入控制器并返回状态和描述

    引用jquery $(function(){ $("#按钮id").click(function(){ var nums="";//变量 $("#ta ...

  8. input text输完自动跳到下一个

    应用场景: 短信验证码输入 效果: input输入框,输入完以后自动跳转到下一个 思路: 四个输入框 进入聚焦到第一个输入框 第一个输入框输完一个字符后自动聚焦到下一个输入框 1.四个输入框 < ...

  9. RobotFramework自动化测试框架-移动手机自动化测试Input Text和Click Button关键字的使用

    Input Text和Click Button Input Text 关键字一般用来给输入框进行输入操作,该关键字接收两个参数[ locator | text ]. 示例1:启动安卓手机上一个APP的 ...

随机推荐

  1. 记事本编辑的Java文件生成文档

    用记事本写的Java源文件生成注释文 1)在命令行(事先调到相关的位置)中输入 -------javadoc -d doc Hello.java--------- 在这里Hello.java是Java ...

  2. CSS常用

    1.CSS3新增特性,目前主流浏览器都支持 -webkit-user-select: none;  /* Chrome all / Safari all /opera15+*/  -moz-user- ...

  3. PHP05

    php05 1.音乐案例删除部分 1)通过执行某些PHP代码获取到指定的数据,填充到html的指定位置 accept属性也可以直接写扩展名,多个扩展名间用英文的逗号分隔 accept=".l ...

  4. 直接打开virtualbox报错

    错误现象: Failed to instantiate CLSID_VirtualBox w/ IVirtualBox, but CLSID_VirtualBox w/ IUnknown works. ...

  5. Oracle创建Database Link

    一菜单方式: 打开plsql,点击[File]-[New]-[Database link],打开如下图所示窗口 填好各项信息后,点击[Apply]即可完成Database Link的创建. 二SQL方 ...

  6. wsl install lamp

    sudo apt-get update sudo apt-get install lamp-server^ /etc/init.d/apache2 start /etc/init.d/mysql st ...

  7. JAVA中的ZoneId常用值备注

    一.获取代码 @Test public void zonesTest() { for (String availableZoneId : ZoneId.getAvailableZoneIds()) { ...

  8. API 'variant.getJavaCompiler()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'

    WARNING: API 'variant.getJavaCompiler()' is obsolete and has been replaced with 'variant.getJavaComp ...

  9. Effective Java 第三版——83. 明智谨慎地使用延迟初始化

    Tips 书中的源代码地址:https://github.com/jbloch/effective-java-3e-source-code 注意,书中的有些代码里方法是基于Java 9 API中的,所 ...

  10. Git Flow 分支管理简述

    概述 Git 是什么 Git 是一个开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目. Git 是 Linus Torvalds 为了帮助管理 Linux 内核开发而开发的一个开放源码的 ...