tf reduce sum 28 29

Solutions on MaxInterview for tf reduce sum 28 29 by the best coders in the world

showing results for - "tf reduce sum 28 29"
Lennart
01 Sep 2016
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