tensorflow reduce sum

Solutions on MaxInterview for tensorflow reduce sum by the best coders in the world

showing results for - "tensorflow reduce sum"
Kaina
24 Jan 2018
1Computes the sum of elements across dimensions of a tensor. 
2
3x = tf.constant([[1, 1, 1], [1, 1, 1]])
4tf.reduce_sum(x)  # 6
5tf.reduce_sum(x, 0)  # [2, 2, 2]
6tf.reduce_sum(x, 1)  # [3, 3]
7tf.reduce_sum(x, 1, keepdims=True)  # [[3], [3]]
8tf.reduce_sum(x, [0, 1])  # 6