tf.argmax(input, axis=None, name=None, dimension=None)

Returns the index with the largest value across axis of a tensor.

input is a Tensor and axis describes which axis of the input Tensor to reduce across. For vectors, use axis = 0.

For your specific case let's use two arrays and demonstrate this

pred = np.array([[31, 23,  4, 24, 27, 34],
[18, 3, 25, 0, 6, 35],
[28, 14, 33, 22, 20, 8],
[13, 30, 21, 19, 7, 9],
[16, 1, 26, 32, 2, 29],
[17, 12, 5, 11, 10, 15]]) y = np.array([[31, 23, 4, 24, 27, 34],
[18, 3, 25, 0, 6, 35],
[28, 14, 33, 22, 20, 8],
[13, 30, 21, 19, 7, 9],
[16, 1, 26, 32, 2, 29],
[17, 12, 5, 11, 10, 15]])

Evaluating tf.argmax(pred, 1) gives a tensor whose evaluation will give array([5, 5, 2, 1, 3, 0])

Evaluating tf.argmax(y, 1) gives a tensor whose evaluation will give array([5, 5, 2, 1, 3, 0])

tf.equal(x, y, name=None) takes two tensors(x and y) as inputs and returns the truth value of (x == y) element-wise.

Following our example, tf.equal(tf.argmax(pred, 1),tf.argmax(y, 1)) returns a tensor whose evaluation will givearray(1,1,1,1,1,1).

correct_prediction is a tensor whose evaluation will give a 1-D array of 0's and 1's

y_test_prediction can be obtained by executing pred = tf.argmax(logits, 1)

tf.argmax的更多相关文章

  1. TFboy养成记 tf.cast,tf.argmax,tf.reduce_sum

    referrence: 莫烦视频 先介绍几个函数 1.tf.cast() 英文解释: 也就是说cast的直译,类似于映射,映射到一个你制定的类型. 2.tf.argmax 原型: 含义:返回最大值所在 ...

  2. tf.argmax()以及axis解析

    首先,明确一点,tf.argmax可以认为就是np.argmax.tensorflow使用numpy实现的这个API.    简单的说,tf.argmax就是返回最大的那个数值所在的下标.    这个 ...

  3. 深度学习原理与框架-Tensorflow基本操作-mnist数据集的逻辑回归 1.tf.matmul(点乘操作) 2.tf.equal(对应位置是否相等) 3.tf.cast(将布尔类型转换为数值类型) 4.tf.argmax(返回最大值的索引) 5.tf.nn.softmax(计算softmax概率值) 6.tf.train.GradientDescentOptimizer(损失值梯度下降器)

    1. tf.matmul(X, w) # 进行点乘操作 参数说明:X,w都表示输入的数据, 2.tf.equal(x, y) # 比较两个数据对应位置的数是否相等,返回值为True,或者False 参 ...

  4. Tensorflow中的tf.argmax()函数

    转载请注明出处:http://www.cnblogs.com/willnote/p/6758953.html 官方API定义 tf.argmax(input, axis=None, name=None ...

  5. TensorFlow函数(七)tf.argmax()

    tf.argmax(input, dimension, name=None) 参数: input:输入数据 dimension:按某维度查找. dimension=0:按列查找: dimension= ...

  6. tensorflow四维tensor的形状以及函数tf.argmax( )的笔记

    关于tensorflow里多维数组(主要是四维)的组织形式之前一直没弄懂,最近遇到相关问题,算是搞清楚了一些东西,特别记下来,免得自己又遗忘了. 三维形式能很简单的脑补出来三维的形状,不再赘述. 之前 ...

  7. tensorflow 基本函数(1.tf.split, 2.tf.concat,3.tf.squeeze, 4.tf.less_equal, 5.tf.where, 6.tf.gather, 7.tf.cast, 8.tf.expand_dims, 9.tf.argmax, 10.tf.reshape, 11.tf.stack, 12tf.less, 13.tf.boolean_mask

    1.  tf.split(3, group, input)  # 拆分函数    3 表示的是在第三个维度上, group表示拆分的次数, input 表示输入的值 import tensorflow ...

  8. 【Tensorflow】tf.argmax函数

    tf.argmax(input, axis=None, name=None, dimension=None) 此函数是对矩阵按行或列计算最大值   参数 input:输入Tensor axis:0表示 ...

  9. tf.argmax()解析

    tf.argmax(input,axis)根据axis取值的不同返回每行或者每列最大值的索引. 代码如下: import tensorflow as tfimport numpy as npsess= ...

随机推荐

  1. 【LOJ】#2493. 「BJOI2018」染色

    题面 题解 推结论大题--然而我推不出什么结论 奇环显然是NO 如果一个联通块里有两个分离的环,也是NO 如果一个联通块里,点数为n,边数为m m <= n的时候,是YES m >= n ...

  2. Djang1.8+Python2.0迁移到Django2.0+Python3.6注意事项(转)

    Djang1.8+Python2.0迁移到Django2.0+Python3.6注意事项 参考:https://blog.csdn.net/weixin_40475396/article/detail ...

  3. jQuery-Selectors(选择器)的使用(二、层次篇)(转载)

    原文:http://www.cnblogs.com/bynet/archive/2009/12/01/1614405.html 本系列文章导航 jQuery-Selectors(选择器)的使用(一.基 ...

  4. Linux下部署tomcat及tomcat war包应用程序

    1, 通过winscp将tomcat包(6和7版本都是一样的安装方法)和jdk-6u27-linux-x64.bin安装文件传送到linux 系统/opt里面.(这里没有固定要传送到/opt/hn,可 ...

  5. <泛> C++3D数学库设计详解 简单光学几何 && 随机向量生成

    // 注:本内容为作者原创,禁止在其他网站复述内容以及用于商业盈利,如需引用,请标明出处:http://www.cnblogs.com/lv_anchoret/  Preface 当初写这个库,是为了 ...

  6. collectionView代理方法快速设置cell大小上下左右间隔

    #define JianGe 25 #define GeShu 4 #define ScreenWidth ([UIScreen mainScreen].bounds.size.width) #def ...

  7. Android 常见SD卡操作

    目录 Android 常见SD卡操作 Android 常见SD卡操作 参考 https://blog.csdn.net/mad1989/article/details/37568667. [0.] E ...

  8. C#泛型的抗变与协变

    C#泛型的抗变与协变 学习自 C#本质论6.0 https://www.cnblogs.com/pugang/archive/2011/11/09/2242380.html Overview 一直以来 ...

  9. hdu 3289 最大独立集

    题意:一个动物园里有N只猫和K只狗,一些小朋友来参观,他们如果喜欢狗就不喜欢猫,喜欢猫就不喜欢狗,园长想要移走一些动物,如果,移走的是某个小朋友不喜欢的,而喜欢的没被移走,该小朋友就会高兴,求移动的数 ...

  10. .net core下的dotnet全局工具

    .net core 2.1后支持了一个全新的部署和扩展命令,可以自己注册全局命令行. dotnet install tool -g dotnetsaydotnetsay 也可以自己构建自己的命令行,一 ...