计算张量维度上元素的方差。
用法
tf.math.reduce_variance(
input_tensor, axis=None, keepdims=False, name=None
)参数
-
input_tensor要减少的张量。应该有实数或复数类型。 -
axis要减小的尺寸。如果None(默认),减少所有维度。必须在[-rank(input_tensor), rank(input_tensor))范围内。 -
keepdims如果为真,则保留长度为 1 的缩减维度。 -
name关联操作的名称范围(可选)。
返回
-
与 input_tensor 具有相同 dtype 的缩减张量。请注意,对于
complex64或complex128输入,返回的Tensor将分别为float32或float64类型。
沿 axis 中给定的尺寸减少 input_tensor 。除非 keepdims 为真,否则对于 axis 中的每个条目,张量的秩都会减少 1,这必须是唯一的。如果 keepdims 为真,则保留缩减后的维度,长度为 1。
如果axis 为None,则所有维度都会减少,并返回具有单个元素的张量。
例如:
x = tf.constant([[1., 2.], [3., 4.]])
tf.math.reduce_variance(x)
<tf.Tensor:shape=(), dtype=float32, numpy=1.25>
tf.math.reduce_variance(x, 0)
<tf.Tensor:shape=(2,), dtype=float32, numpy=array([1., 1.], ...)>
tf.math.reduce_variance(x, 1)
<tf.Tensor:shape=(2,), dtype=float32, numpy=array([0.25, 0.25], ...)>
numpy 兼容性
相当于 np.var
请注意np.var 有一个dtype 参数,可用于指定输出类型。默认情况下这是 dtype=float64 。另一方面,tf.math.reduce_variance 具有来自 input_tensor 的激进类型推断。
相关用法
- Python tf.math.reduce_max用法及代码示例
- Python tf.math.reduce_min用法及代码示例
- Python tf.math.reduce_std用法及代码示例
- Python tf.math.reduce_logsumexp用法及代码示例
- Python tf.math.reduce_mean用法及代码示例
- Python tf.math.reduce_all用法及代码示例
- Python tf.math.reduce_euclidean_norm用法及代码示例
- Python tf.math.reduce_sum用法及代码示例
- Python tf.math.reduce_any用法及代码示例
- Python tf.math.reduce_prod用法及代码示例
- Python tf.math.real用法及代码示例
- Python tf.math.reciprocal_no_nan用法及代码示例
- Python tf.math.rsqrt用法及代码示例
- Python tf.math.rint用法及代码示例
- Python tf.math.round用法及代码示例
- Python tf.math.special.fresnel_cos用法及代码示例
- Python tf.math.polyval用法及代码示例
- Python tf.math.is_finite用法及代码示例
- Python tf.math.special.bessel_k0e用法及代码示例
- Python tf.math.acosh用法及代码示例
注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.math.reduce_variance。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
