📜  tf.reduce_sum() - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:51.056000             🧑  作者: Mango

代码示例1
Computes the sum of elements across dimensions of a tensor. 

x = tf.constant([[1, 1, 1], [1, 1, 1]])
tf.reduce_sum(x)  # 6
tf.reduce_sum(x, 0)  # [2, 2, 2]
tf.reduce_sum(x, 1)  # [3, 3]
tf.reduce_sum(x, 1, keepdims=True)  # [[3], [3]]
tf.reduce_sum(x, [0, 1])  # 6