Reputation: 55
tf.reduce_mean command is used to take mean along specified axis. But if don't specify axis and use reduction indices zero then it prints middle row. Why is it so? How this reduction indices effects output values? If I print sum.eval() command why it prints [[4,5,6]]? I also go through the documentation but it doesn't give any explanation for reduction_indices.Please clear my concept about this command.
a = tf.range(0,12)
b = tf.reshape(a,(4,3))
sum = tf.reduce_mean(b,reduction_indices=[0],keep_dims=True)
sess = tf.InteractiveSession()
print (b.eval())
print (b.get_shape())
print (sum.eval())
print (sum.get_shape())
Upvotes: 0
Views: 334
Reputation: 3852
reduction_indices
behaves like axis
.
As per the documentation of tf.reduce_mean
:
reduction_indices: The old (deprecated) name for axis.
https://www.tensorflow.org/api_docs/python/tf/reduce_mean
4, 5 and 6 are just the mean of each column
(0+3+6+9)/4 = 4
(1+4+7+10)/4 = 5
(2+5+8+11)/4 = 6
Upvotes: 0