reduce_variance

dragon.vm.tensorflow.math.reduce_variance(
  input_tensor,
  axis=None,
  keepdims=False,
  name=None
)[source]

Compute the variance value of elements along the given axis.

The argument axis could be negative or None:

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

# A negative axis is the last-k axis
print(tf.math.reduce_variance(x, 1))
print(tf.math.reduce_variance(x, -1))  # Equivalent

# If ``axis`` is None, the vector-style reduction
# will be applied to return a scalar result
print(tf.math.reduce_variance(x))  # 2.917

# Also, ``axis`` could be a sequence of integers
print(tf.math.reduce_variance(x, [0, 1]))  # 2.917
Parameters:
  • input_tensor (dragon.Tensor) The input tensor.
  • axis (Union[int, Sequence[int]], optional) The axis to reduce.
  • keepdims (bool, optional, default=False) Keep the reduced dimensions or not.
  • name (str, optional) The operation name.
Returns:

dragon.Tensor The output tensor.