tf.argmax
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的更多相关文章
- TFboy养成记 tf.cast,tf.argmax,tf.reduce_sum
referrence: 莫烦视频 先介绍几个函数 1.tf.cast() 英文解释: 也就是说cast的直译,类似于映射,映射到一个你制定的类型. 2.tf.argmax 原型: 含义:返回最大值所在 ...
- tf.argmax()以及axis解析
首先,明确一点,tf.argmax可以认为就是np.argmax.tensorflow使用numpy实现的这个API. 简单的说,tf.argmax就是返回最大的那个数值所在的下标. 这个 ...
- 深度学习原理与框架-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 参 ...
- Tensorflow中的tf.argmax()函数
转载请注明出处:http://www.cnblogs.com/willnote/p/6758953.html 官方API定义 tf.argmax(input, axis=None, name=None ...
- TensorFlow函数(七)tf.argmax()
tf.argmax(input, dimension, name=None) 参数: input:输入数据 dimension:按某维度查找. dimension=0:按列查找: dimension= ...
- tensorflow四维tensor的形状以及函数tf.argmax( )的笔记
关于tensorflow里多维数组(主要是四维)的组织形式之前一直没弄懂,最近遇到相关问题,算是搞清楚了一些东西,特别记下来,免得自己又遗忘了. 三维形式能很简单的脑补出来三维的形状,不再赘述. 之前 ...
- 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 ...
- 【Tensorflow】tf.argmax函数
tf.argmax(input, axis=None, name=None, dimension=None) 此函数是对矩阵按行或列计算最大值 参数 input:输入Tensor axis:0表示 ...
- tf.argmax()解析
tf.argmax(input,axis)根据axis取值的不同返回每行或者每列最大值的索引. 代码如下: import tensorflow as tfimport numpy as npsess= ...
随机推荐
- PHP rabbitmq扩展安装
转载自: https://www.jianshu.com/p/65490900a937 安装rabbitmq的php扩展 1.安装扩展依赖库##### 注意:扩展是C写的,由于C与RabbitMQ通信 ...
- form的智能表单
1.智能表单的介绍 其中,(1)中的使用格式使得form不会太臃肿. 2.使用规范 3.新属性 4.举例 二.程序 1.关于邮件的问题 <!DOCTYPE html> <head&g ...
- 使用Ajax方式POST JSON数据包(转)
add by zhj: 用ajax发送json数据时注意两点, 第一,使用JSON.stringify()函数将data转为json格式的字符串,如下 data: JSON.stringify({ ...
- linux学习笔记-8.vim
ia/Ao/Or + ?替换 0:文件当前行的开头$:文件当前行的末尾G:文件的最后一行开头1 + G到第一行9 + G到第九行 = :9 dd:删除一行3dd:删除3行yy:复制一行3yy:复制3行 ...
- 在VC++中怎样改变控件间的TAB切换顺序?
在编辑界面按下ctrl+D键,就会出现所有控件的Tab键顺序,按照自己想要的顺序依次点击控件,就可以重新安排顺序.
- 解决jQueryUi AutoComplete在某些浏览器下无法出现候选项问题
在某些浏览器(如火狐),在使用AutoComplete进行绑定的时候,无法出现与关键字相似的候选项.其原因这里有描述: 解决方法可以采用下面方式: $('#bindInputId).bind(&quo ...
- OpenVPN推送默认路由表
根据官方Server配置文件:https://github.com/OpenVPN/openvpn/blob/master/sample/sample-config-files/server.conf ...
- Mac 10.12彻底关闭Dashboard
1.打开[系统偏好设置]. 2.点击进入[Mission Control]. 3.中间有一项[Dashboard],点击它右边的下拉菜单,选择[关闭],即可.
- word删除空白行
情况一:如果粘贴后,word页面既有表格又有文字(有时网页中选定时看不到表格,粘贴后却有表格),还有许多空行! 硬回车: “编辑--替换” -查找内容为“^p^p”,替换成“^p”--然后全部替换! ...
- 正余弦信号的DFT频谱分析
一般的,对正余弦信号进行採样并DFT运算,画出频谱图,会发现频谱并不干净.这样的现象称为频谱泄漏.由于DFT运算仅仅能是有限序列,突然的截断产生了泄漏. 会有这种特殊情况.当採样截取的刚好是整数个周期 ...