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 深复制和浅复制

    浅复制是指复制对象时仅仅复制对象本身(包括对象中的基本变量),而不复制对象包含的引用指向的对象.深复制不仅复制对象本身,而且复制对象包含的引用指向的对象. 复制对象时需要调用Object类的clone ...

  2. unity 动画无法正常播放Animation的动画问题

    1,百度得来的一种方案,留作备用: 有一个区别的地方在于新建动画之前,选中物体身上有无Animation组件: 1.没有的话,选中物体,打开Animation窗口,新建,会出现一个animation一 ...

  3. c# 后台绑定treeview 单个tab

    <wijmo:C1TreeView ID="C1TreeView1" runat="server" ShowCheckBoxes="true&q ...

  4. LinkedList源码分析和实例应用

    1. LinkedList介绍 LinkedList是继承于AbstractSequentialList抽象类,它也可以被当作堆栈.队列或者双端队列使用. LinkedList实现了Deque接口,即 ...

  5. Hashmap的Hash()

    JDK7: public final int hashCode() {            return Objects.hashCode(getKey()) ^ Objects.hashCode( ...

  6. JAVA自学笔记27

    JAVA自学笔记27 1.类的加载 1)当程序要使用某个类时,如果该类还未被加载到内存中,则系统会通过加载,连接,初始化三步来实现对这个类进行初始化. ①加载:就是指将class文件读入内存,并为之创 ...

  7. .net 多态

    https://espider.github.io/CLR/inheritance-polymorphism/

  8. x264阅读记录-3

      14. x264_macroblock_encode函数-1 这个函数主要根据已经选定的模式来对宏块残差进行编码. )如果是P_SKIP模式,那么调用x264_macroblock_encode_ ...

  9. C# CancellationTokenSource和CancellationToken的实现

    微软关于CancellationTokenSource的介绍很简单,其实CancellationTokenSource的使用也很简单,但是实现就不是那么简单了,我们首先来看看CancellationT ...

  10. elementUI tree组件获取当前选择所有选中(check)和半选中(indeterminate)的节点

    网上查了半天,一大堆都说要改源码的,最后发现有方法不用改源码的 获取方法如下 this.$refs.tree.getCheckedKeys().concat(this.$refs.tree.getHa ...