我们通过例子来了解用途
第一个例子:axis不指定的话,求所有元素的平均值
import tensorflow as tf
d=[[1,2,5],[33,20,10],[5,8,9]]
c=tf.reduce_mean(d)
with tf.Session() as sess:
print(sess.run(c))
第二个例子,axis=0 y轴求平均值
import tensorflow as tf
d=[[1,2,5],[33,20,10],[5,8,9]]
c=tf.reduce_mean(d,axis=0)
with tf.Session() as sess:
print(sess.run(c))
第三个例子,axis=1 x轴求平均值
import tensorflow as tf
d=[[1,2,5],[33,20,10],[5,8,9]]
c=tf.reduce_mean(d,axis=1)
with tf.Session() as sess:
print(sess.run(c))
我们发现降维度了,是不是2维变1维