http://stackoverflow.com/questions/37312421/tensorflow-whats-the-difference-between-sparse-softmax-cross-entropy-with-logi

Having two different functions is a convenience, as they produce the same result.

The difference is simple:

  • For sparse_softmax_cross_entropy_with_logits, labels must have the shape [batch_size] and the dtype int32 or int64. Each label is an int in range [0, num_classes-1].
  • For softmax_cross_entropy_with_logits, labels must have the shape [batch_size, num_classes] and dtype float32 or float64.

Labels used in softmax_cross_entropy_with_logits are the one hot version of labels used in sparse_softmax_cross_entropy_with_logits.

Another tiny difference is that with sparse_softmax_cross_entropy_with_logits, you can give -1 as a label to have loss 0 on this label.

tensorflow 中 softmax_cross_entropy_with_logits 与 sparse_softmax_cross_entropy_with_logits 的区别的更多相关文章

  1. tensorflow中run和eval的区别(转)

    在tensorflow中,eval和run都是获取当前结点的值的一种方式. 在使用eval时,若有一个 t 是Tensor对象,调用t.eval()相当于调用sess.run(t) 一下两段代码等效: ...

  2. 【tensorflow】softmax_cross_entropy_with_logits与sparse_softmax_cross_entropy_with_logits

    softmax_cross_entropy_with_logits与sparse_softmax_cross_entropy_with_logits都是对最后的预测结果进行softmax然后求交叉熵 ...

  3. tf中softmax_cross_entropy_with_logits与sparse_softmax_cross_entropy_with_logits

    其实这两个都是计算交叉熵,只是输入数据不同. #sparse 稀疏的.稀少的 word_labels = tf.constant([2,0]) predict_logits = tf.constant ...

  4. TensorFlow中random_normal和truncated_normal的区别

    原文链接:https://blog.csdn.net/zhangdongren/article/details/83344048 区别如下: tf.random_normal(shape,mean=0 ...

  5. [开发技巧]·TensorFlow中numpy与tensor数据相互转化

    [开发技巧]·TensorFlow中numpy与tensor数据相互转化 个人主页–> https://xiaosongshine.github.io/ - 问题描述 在我们使用TensorFl ...

  6. 记录:TensorFlow 中的 padding 方式

    TensorFlow 中卷积操作和池化操作中都有一个参数 padding,其可选值有 ['VALID', 'SAME']. 在 TensorFlow 文档中只是给出了输出张量的维度计算方式,但是并没有 ...

  7. (原)tensorflow中函数执行完毕,显存不自动释放

    转载请注明出处: http://www.cnblogs.com/darkknightzh/p/7608916.html 参考网址: https://stackoverflow.com/question ...

  8. Tensorflow中的name_scope和variable_scope

    Tensorflow是一个编程模型,几乎成为了一种编程语言(里面有变量.有操作......). Tensorflow编程分为两个阶段:构图阶段+运行时. Tensorflow构图阶段其实就是在对图进行 ...

  9. Tensorflow中的run()函数

    1 run()函数存在的意义 run()函数可以让代码变得更加简洁,在搭建神经网络(一)中,经历了数据集准备.前向传播过程设计.损失函数及反向传播过程设计等三个过程,形成计算网络,再通过会话tf.Se ...

随机推荐

  1. Flume示例

    建议参考官方文档:http://flume.apache.org/FlumeUserGuide.html 示例一:用tail命令获取数据,下沉到hdfs 类似场景: 创建目录: mkdir /home ...

  2. 完成blog后台一枚

    技术实现:纯jfinal+AmazeUI

  3. Python笔记8:网络编程

    python内置封装了很多常见的网络协议的库,因此python成为了一个强大的网络编程工具,这里是对python的网络方面编程的一个简单描述. urllib 和 urllib2模块 urllib 和u ...

  4. Petrozavodsk Summer-2015. Ivan Smirnov Contest 1 B Bloom

    http://opentrains.snarknews.info/~ejudge/team.cgi?contest_id=001463 题目大意:给出$n$个$x$,$m$个$y$,问有多少个hash ...

  5. OpenWrt 安装usb支持

    (一)下载软件 1)komd-usb-ohci kmod-usb2 kmod-usb-storage kmod-usb-core 这些是USB驱动包 2) kmod-nls-base kmod-nls ...

  6. 蓝桥杯 第三届C/C++预赛真题(5) 转方阵(C基本功)

    对一个方阵转置,就是把原来的行号变列号,原来的列号变行号 例如,如下的方阵: 1 2 3 4 5 6 7 8 9 10 11 1213 14 15 16 转置后变为: 1 5 9 13 2 6 10 ...

  7. [LAMP]安装-Debian

    sudo apt-get install build-essential sudo apt-get install mysql-server sudo apt-get install apache2 ...

  8. .NET程序调试技巧(一):快速定位异常的一些方法

    作为一个程序员,解BUG是我们工作中常做的工作,甚至可以说解决问题能力是一个人工作能力的重要体现.因为这体现了一个程序员的技术水平.技术深度.经验等等. 那么在我们解决BUG的过程中,定位问题是非常重 ...

  9. java编译、编码、语言设置

    下面这两行加入,环境变量:特别是gradle在编译文件中含有中文时会遇到一些问题: JAVA_TOOL_OPTIONS -Dfile.encoding=UTF-8 -Duser.language=en ...

  10. 转载:resNet论文笔记

    <Deep Residual Learning for Image Recognition>是2016年 kaiming大神CVPR的最佳论文 原文:http://m.blog.csdn. ...