Answers for "tensorflow reduce_sum"

2

tensorflow reduce_sum

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
Posted by: Guest on April-15-2020

Python Answers by Framework

Browse Popular Code Answers by Language