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.]

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM