moments¶
- dragon.vm.tensorflow.nn.- moments(
 x,
 axes=None,
 keepdims=False,
 name=None
 )[source]¶
- Compute the mean and variance of input along the given axis. \[\begin{cases} \mathrm{E}[x] = \frac{1}{n}\sum(x) \\ \mathrm{Var}[x] = \frac{1}{n}\sum(x - \mathrm{E}[x])^{2} \end{cases} \]- axescould be negative or- None:- x = tf.constant([[1, 2, 3], [4, 5, 6]]) # A negative axis is the last-k axis print(tf.nn.moments(x, 1)) print(tf.nn.moments(x, -1)) # Equivalent # If axes is None, reduce as a vector and return scalars print(tf.nn.moments(x)) # mean is 3.5, var is 2.916667 # Also, axes could be a sequence of integers print(tf.nn.moments(x, [0, 1])) # mean is 3.5, var is 2.916667 - Parameters:
- x (dragon.Tensor) – The input tensor.
- axes (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 mean tensor.
- dragon.Tensor – The variance tensor.
 
 
