tensorflow tf.argmax() 用法 例子
来源:互联网 发布:rpcs3 安装游戏数据卡 编辑:程序博客网 时间:2024/06/05 18:07
argmax()官方文档如下:
tf.argmax(input, dimension, name=None)
Returns the index with the largest value across dimensions of a tensor.
Args:
input: A Tensor. Must be one of the following types: float32, float64, int64, int32, uint8, int16, int8, complex64, qint8, quint8, qint32.
dimension: A Tensor of type int32. int32, 0 <= dimension < rank(input). Describes which dimension of the input Tensor to reduce across. For vectors, use dimension = 0.
name: A name for the operation (optional).
Returns:
A Tensor of type int64.
dimension=0 按列找
dimension=1 按行找
tf.argmax()返回最大数值的下标
通常和tf.equal()一起使用,计算模型准确度
correct_pred = tf.equal(tf.argmax(pred,1), tf.argmax(y,1))accuracy = tf.reduce_mean(tf.cast(correct_pred, tf.float32))
栗子
>>> import tensorflow as tf>>> a = tf.constant([1.,2.,3.,0.,9.,])>>> b = tf.constant([[1,2,3],[3,2,1],[4,5,6],[6,5,4]])>>> with tf.Session() as sess:... sess.run(tf.argmax(a, 0))Output:4>>> with tf.Session() as sess:... sess.run(tf.argmax(b, 0))Output:array([3, 2, 2])>>> with tf.Session() as sess:... sess.run(tf.argmax(b, 1))Output:array([2, 0, 2, 0])
Ref:
API文档
阅读全文
0 0
- tensorflow tf.argmax() 用法 例子
- 【Tensorflow】tf.argmax函数
- tf.argmax()用法
- TensorFlow- tf.argmax 函数学习
- TensorFlow插曲--tf.argmax函数
- tf.argmax
- tf.argmax()
- tf.argmax()
- tensorflow中tf.maximum,tf.minimum,tf.argmax,tf.argmain的对比
- tf.arg_max和tf.argmax
- tf.argmax函数
- tf.argmax的使用
- tensorflow_api_2:tf.argmax( )
- 【TensorFlow】tf.sparse_to_dense的用法
- 【TensorFlow】tf.concat的用法
- tensorflow:tf.stack的用法
- Tensorflow:tf.flags的用法
- tensorflow 中tf.concat()用法
- vuex的辅助函数mapState前面的那三个点--对象展开运算符
- 关于 Network-in-network理解和实现
- Python自学方法
- Maven项目之Spring.profile.开发.测试.生产环境的配置和切换之一键部署
- 浅谈算法和数据结构: 八 平衡查找树之2-3树
- tensorflow tf.argmax() 用法 例子
- IntelliJ IDEA 破解
- lrcn
- 关于极光推送的问题
- 数据结构之查找(六)——平衡二叉树(AVL树)
- 海底捞这么出名,但它的Slogan是啥呢?
- 跪求管家婆360+ 8.1破解版
- Tomcat 报错 (The tomcat server configuration at /Servers/Tomcat v7.0 Server at localhost-config is mi)
- hdu 1166 敌兵布阵(线段树模板题)