TensorFlow函数(七)tf.argmax()

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

参数:

  • input:输入数据
  • dimension:按某维度查找。

    dimension=0:按列查找;

    dimension=1:按行查找;

返回:

  • 最大值的下标
1 a = tf.constant([1.,2.,3.,0.,9.,])
2 b = tf.constant([[1,2,3],[3,2,1],[4,5,6],[6,5,4]])
3 with tf.Session() as sess:
4     sess.run(tf.argmax(a, 0))
5 with tf.Session() as sess:
6     sess.run(tf.argmax(b, 0))
7 with tf.Session() as sess:
8     sess.run(tf.argmax(b, 1))

输出:

4

输出:

[3, 2, 2]

输出:

[2, 0 ,2, 0]

 

posted @ 2018-08-16 21:56  章朔  阅读(2096)  评论(0编辑  收藏  举报