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)
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]

本文介绍了 TensorFlow 中的 tf.reduce_max 函数,该函数用于计算输入张量在指定轴上的最大值。当 axis 设置为 0 时,函数按列求最大值;当 axis 设置为 1 时,则按行求最大值。参数 axis 和 reduction_indices 相同,但后者已被废弃。示例展示了如何使用该函数并比较了与 NumPy 的 np.max 函数的等效用法。
1万+

被折叠的 条评论
为什么被折叠?



