TensorFlow- tf.argmax 函数学习
来源:互联网 发布:h5实现的炫酷页面源码 编辑:程序博客网 时间:2024/06/04 19:41
tf.argmax 格式
tf.argmax
argmax(
input,
axis=None,
name=None,
dimension=None
)
其中,input为一个张量,类型为 float32, float64, int64, int32, uint8, uint16, int16, int8, complex64, complex128, qint8, quint8, qint32, half
axis 表示选取的坐标轴
name 为该操作取名
看一个栗子
import tensorflow as tfimport numpy as npipt = np.array([[1,2,1,4],[10,3,2,8],[6,7,9,66],[5,45,78,54]])res = tf.argmax(ipt,0)sess = tf.Session()opt = sess.run(res)print(opt)
输出结果为:
[1 3 3 2]
输出结果解释
首先,argmax返回的是索引值,返回每一行或者每一列的最大值的索引,当选择axis=1时。表示每一行的最大值,0表示每列的最大值索引,看上面的例子,第一列最大值为10,为该列的第二个,所以索引为1,第二列,最大值为45。为第四个,所以索引为3,第三列最大值为78,为第四个,索引为3,最后一个最大值为66,为第三个,所以索引为2。
axis 换成1
import tensorflow as tfimport numpy as npipt = np.array([[1,2,1,4],[10,3,2,8],[6,7,9,66],[5,45,78,54]])res = tf.argmax(ipt,1)sess = tf.Session()opt = sess.run(res)print(opt)
[3 0 3 2]
当axis为1,就是比每一行的值,返回最大值在该行的索引,比如,第一行,最大值为4,为第四个,索引为3,第二行最大值为10,为第一个,索引为0,以此类推。
tf.argmin
和argmax格式之类的都是一样,但是返回的是最小值对应的索引
其实tensorflow中的argmin,argmax和numpy中的argmin,argmax是一样的,都是返回索引
阅读全文
0 0
- TensorFlow- tf.argmax 函数学习
- 【Tensorflow】tf.argmax函数
- TensorFlow插曲--tf.argmax函数
- tf.argmax函数
- tensorflow tf.argmax() 用法 例子
- tensorflow学习之常用函数总结:tensorflow.argmax()函数
- Tensorflow argmax函数详解
- [tensorflow]argmax()函数
- tf.argmax
- tf.argmax()
- tf.argmax()
- tensorflow中tf.maximum,tf.minimum,tf.argmax,tf.argmain的对比
- 【Tensorflow】tf.placeholder函数
- 【Tensorflow】tf.reshape 函数
- Tensorflow tf.placeholder函数
- 【Tensorflow】tf.Graph()函数
- 【Tensorflow】tf.placeholder函数
- 【Tensorflow】tf.concat函数
- Tomcat 搭建简单文件服务器
- 移动端一些小问题
- python2.7基于selenium的web自动化测试项目--base目录文件
- 键盘录入任意一个年份,判断该年是闰年还是平年
- dispatch_suspend 与 dispatch_resume探索
- TensorFlow- tf.argmax 函数学习
- SylixOS磁盘高速传输
- [Codeforces 547C] Mike And Foam 莫比乌斯反演
- 安装ubuntu16.04桌面版及其相关优化
- 卡尔曼滤波 -- 从推导到应用(一)
- 文章标题
- Comparable和Comparator的区别
- 进程组、作业、会话
- 配置SSH无密码登陆