tf.reduce_max()

2022-09-02 13:19:24 浏览数 (1)

代码语言:javascript复制
tf.reduce_max(
    input_tensor,
    axis=None,
     name=None,
)

函数是求按axis方向的最值,axis=0按列求最值,axis=1按行求最值。其中有时候会看到参数没有axis,而是reduction_indices=None,其实两者相等,不过后者是axis废弃的名称。

另外该函数等价于np.max:(a, axis=None, out=None, keepdims=False)

代码语言:javascript复制
import tensorflow as tf
import numpy as np
     
max_value = tf.reduce_max([[1, 3, 2], [4,5,6]], axis=0)
with tf.Session() as sess:
    max_value = sess.run(max_value)
    print(max_value)
     
print(np.max([[1, 3, 2], [4,5,6]], axis=0))
     
     
#### 输出
[4 5 6]
[4 5 6]

0 人点赞