import tensorflow as tf
import numpy as np
# Computes the maximum of elements across dimensions of a tensor. (deprecated arguments)
#
# tf.reduce_max(
# input_tensor,
# axis=None,
# keepdims=None,
# name=None,
# reduction_indices=None,
# keep_dims=None
# )
c = np.array([[3.,4], [5.,6], [6.,7]])
step = tf.reduce_max(c, 1)
with tf.Session() as sess:
print(sess.run(step))
结果为:
[4. 6. 7.]
Process finished with exit code 0
tf.reduce_max(c, 1)参数为1找的是每一行的最大值;
c = np.array([[3.,4], [5.,6], [6.,7]])
step = tf.reduce_max(c,0)
with tf.Session() as sess:
print(sess.run(step))
参数为0计算的是每一列的最大值,结果为:
[6. 7.]
Process finished with exit code 0
不写参数的话,是找整个数组中最大的值,结果为7