1. 程式人生 > >(tensorflow) tf.reduce_max

(tensorflow) tf.reduce_max

tf. reduce_max(values,axis):返回values在axis維度的最大值

import tensorflow as tf

d = [[[1,2],[3,4],[5,6]],[[7,8],[9,10],[11,12]]]  

val = tf.reduce_max(d,axis=0)

with tf.Session() as sess:

     
    print(val.eval())   # axis=0,即每一列取最大值


output:
[[ 7  8]
 [ 9 10]
 [11 12]]
val = tf.reduce_max(d,axis=1)

with tf.Session() as sess:

    print(val.eval())   # axis=1,即每一行取最大值

output:
[[ 5  6]
 [11 12]]
val = tf.reduce_max(d,axis=2)

with tf.Session() as sess:

    print(val.eval())   # axis=2,即每一個元素取最大值


output:
[[ 2  4  6]
 [ 8 10 12]]

    

有什麼不足之處請指正!