TensorFlow api: reduce_mean

tf.math.reduce_mean():
有六个参数:

input_tensor, 输入的tensor,numeric型数据
axis=None, 指定计算轴
keepdims=None, 保持维度
name=None, 为操作命名
reduction_indices=None, 旧版本的axis,不推荐使用
keep_dims=None,避免使用,功能同keepdims

函数定义:按照axis所给出的轴的方向(0为纵向1为横向)对tensor求平均数,若未指定axis则计算所有值的平均数并返回。
如果keepdim=True则减去的维度会保持长度为1。
返回类型与输入相同,是一个降维的tensor。

例子:

| 1. 1.|
| 2. 2.|=x  即x=constant([[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.]

猜你喜欢

转载自blog.csdn.net/cyr429/article/details/89243904
今日推荐