TensorFlow函数:tf.reduce_mean

2018-12-13 11:41 更新
tf.reduce_mean 函数
reduce_mean(
    input_tensor,
    axis=None,
    keep_dims=False,
    name=None,
    reduction_indices=None
)

定义在:tensorflow/python/ops/math_ops.py.

请参阅指南:数学函数>减少

计算张量的各个维度上的元素的平均值.

axis是tf.reduce_mean函数中的参数,按照函数中axis给定的维度减少input_tensor.除非keep_dims是true,否则张量的秩将在axis的每个条目中减少1.如果keep_dims为true,则缩小的维度将保留为1. 

如果axis没有条目,则减少所有维度,并返回具有单个元素的张量.

例如:

x = tf.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.]

参数:

  • input_tensor:要减少的张量.应该有数字类型.
  • axis:要减小的尺寸.如果为None(默认),则减少所有维度.必须在[-rank(input_tensor), rank(input_tensor))范围内.
  • keep_dims:如果为true,则保留长度为1的缩小尺寸.
  • name:操作的名称(可选).
  • reduction_indices:axis的不支持使用的名称.

返回:

该函数返回减少的张量.

numpy兼容性

相当于np.mean

以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy