tf.reduce_mean

x = tf.constant([[1,2]
                        [3,4]],dtype=tf.float32)


tf.reduce_mean(x) ==> 2.5 #如果不指定第二个参数,那么就在所有的元素中取平均值
tf.reduce_mean(x, 0) ==> [2.,  3.] #指定第二个参数为0,则第一维的元素取平均值,即每一列求平均值
tf.reduce_mean(x, 1) ==> [1.5,  3.5] #指定第二个参数为1,则第二维的元素取平均值,即每一行求平均值                        

  

猜你喜欢

转载自www.cnblogs.com/zenan/p/9151930.html