tf.reduce_mean

import numpy as np
import tensorflow as tf

x = np.array([[1.,2.,3.],[4.,5.,6.]])
sess = tf.Session()

mean1 = sess.run(tf.reduce_mean(x))
mean2 = sess.run(tf.reduce_mean(x, 0))
mean3 = sess.run(tf.reduce_mean(x, 1))


print (x)
print (mean1)
print (mean2)
print (mean3)


sess.close()
[[ 1.  2.  3.]
 [ 4.  5.  6.]]
3.5
[ 2.5  3.5  4.5]
[ 2.  5.]
posted @ 2022-08-19 22:59  luoganttcc  阅读(10)  评论(0编辑  收藏  举报