Tensorflow之计算tensor平均值

https://www.tensorflow.org/versions/r0.12/api_docs/python/math_ops.html#reduce_mean

tf.reduce_mean(input_tensor, axis=None, keep_dims=False, name=None, reduction_indices=None)

计算tensor中各个维度上元素的平均值. 在给定维度axis上进行删减. keep_dims被设置为false的话, 原始变量的维度会减少1.  如果不对axis进行赋值, 那么返回所有元素的平均值.

例子:

# 'x' is [[1., 1.]
#         [2., 2.]]
tf.reduce_mean(x) ==> 1.5
tf.reduce_mean(x, 0) ==> [1.5, 1.5]
tf.reduce_mean(x, 1) ==> [1.,  2.]
原文地址:https://www.cnblogs.com/huangshiyu13/p/6534264.html