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= ...
随机推荐
- 018 HDFS中,namenode与datanode的交互
1.解释 2.启动过程 namenode需要等待给他汇报块的情况,然后namenode会给datanode一个反馈. namenode在启动的时候有一个等待的过程. 3.如果有块损坏 等待报告中,na ...
- linux cudnn安装
cudnn-8.0-linux-x64-v5.1链接:http://pan.baidu.com/s/1c1JuMty 密码:v0g9 #以CuDNN的v5.1版本,Cuda 8.0为例 sudo ta ...
- 002.DHCP配置
一 DHCP服务器安装包 yum -y install dhcp 二 对应端口 ipv4 udp67.udp68 ipv6 udp546.udp547 三 文件路径 服务名:dhcpd 主配置文件:/ ...
- Java基础组件快速入门
最近需要上线很多新的JAVA项目,然而很多JAVA的相关库都不太熟悉,项目实现起来遇到了不小阻力,熬了好几天夜.现在手头的工作基本完成了,因此打算好好来归纳下java的相关工具库,将来需要借助你们,好 ...
- CPU的主频
CPU的主频,即CPU内核工作的时钟频率(CPU Clock Speed).通常所说的某某CPU是多少兆赫的(MHZ),而这个多少兆赫就是“CPU的主频”.很多人认为CPU的主频就是其运行速度,其实不 ...
- C#开发Unity游戏教程之Unity中方法的参数
C#开发Unity游戏教程之Unity中方法的参数 Unity的方法的参数 出现在脚本中的方法,无论是在定义的时候,还是使用的时候,后面都跟着一对括号“( )”,有意义吗?看起来最多也就是起个快速识别 ...
- BZOJ.4909.[SDOI2017]龙与地下城(正态分布 中心极限定理 FFT Simpson积分)
BZOJ 洛谷 https://www.luogu.org/blog/ShadowassIIXVIIIIV/solution-p3779# 正态分布 正态分布是随机变量\(X\)的一种概率分布形式.它 ...
- makefile 必知必会以及Makefile是怎样炼成的
Make必知必会原文链接 Makefile 必知必会 Makefile的根本任务是根据规则生成目标文件. 规则 一条规则包含三个:目标文件,目标文件依赖的文件,更新(或生成)目标文件的命令. 规则: ...
- Linux下以.rc结尾的文件含义
运行命令 资源控制 运行控制 运行时配置 其实我更青睐于运行时配置,也就是运行时的变量等放置变量的. 参考: https://stackoverflow.com/questions/11030552/ ...
- EF+Sqlite 动态设置连接字符串
摘要 在做c/s项目的时候,如果使用ef+sqlite,我们不知道客户端会安装在哪里,需要动态的来设置db所在路径. 解决办法 /// <summary> /// 数据上下文 /// &l ...