tf.argmax(values,axis):返回values在axis维度最大值的索引
tf. reduce_max(values,axis):返回values在axis维度的最大值
结果维度为values的维度-1,且shape为去掉axis之后的values的shape,顺序不变。
细节见实例:
import tensorflow as tf d = [[[1,2],[3,4],[5,6]],[[7,8],[9,10],[11,12]]] # d.shape = (2,3,2) 三维 idx = tf.argmax(d,axis=0) val = tf.reduce_max(d,axis=0) with tf.Session() as sess: print(idx.eval()) # shape = (3,2) 二维 print(val.eval())
output:
[[1 1]
[1 1]
[1 1]]
[[ 7 8]
[ 9 10]
[11 12]]idx = tf.argmax(d,axis=1) val = tf.reduce_max(d,axis=1) with tf.Session() as sess: print(idx.eval()) # shape = (2,2) print(val.eval())
output:
[[2 2]
[2 2]]
[[ 5 6]
[11 12]]