Document feedback

Question document fragment

When a question document fragment contains a formula, it is displayed as a space.

Submission type
issue

It's a little complicated...

I'd like to ask someone.

Please select the submission type

Problem type
Specifications and Common Mistakes

- Specifications and Common Mistakes:

- Misspellings or punctuation mistakes,incorrect formulas, abnormal display.

- Incorrect links, empty cells, or wrong formats.

- Chinese characters in English context.

- Minor inconsistencies between the UI and descriptions.

- Low writing fluency that does not affect understanding.

- Incorrect version numbers, including software package names and version numbers on the UI.

Usability

- Usability:

- Incorrect or missing key steps.

- Missing main function descriptions, keyword explanation, necessary prerequisites, or precautions.

- Ambiguous descriptions, unclear reference, or contradictory context.

- Unclear logic, such as missing classifications, items, and steps.

Correctness

- Correctness:

- Technical principles, function descriptions, supported platforms, parameter types, or exceptions inconsistent with that of software implementation.

- Incorrect schematic or architecture diagrams.

- Incorrect commands or command parameters.

- Incorrect code.

- Commands inconsistent with the functions.

- Wrong screenshots.

- Sample code running error, or running results inconsistent with the expectation.

Risk Warnings

- Risk Warnings:

- Lack of risk warnings for operations that may damage the system or important data.

Content Compliance

- Content Compliance:

- Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions.

- Copyright infringement.

Please select the type of question

Problem description

Describe the bug so that we can quickly locate the problem.

mindspore.ops.var_mean

mindspore.ops.var_mean(input, axis=None, ddof=0, keepdims=False)[source]

Returns the variance and mean of each row of the input Tensor by default, or it can calculate them in specified dimension axis. If axis is a list of dimensions, reduce over all of them.

Note

If ddof is 0, 1, True or False, the supported device is only Ascend and CPU. In other cases, the supported device is Ascend, GPU and CPU.

Parameters
  • input (Tensor[Number]) – Input Tensor with a dtype of number.Number, its shape should be (N,) where means any number of additional dims.

  • axis (Union[int, tuple(int)], optional) – The dimensions to reduce. Only constant value is allowed. Must be in the range [-rank(input), rank(input)). Default: None , reduce all dimensions.

  • ddof (Union[int, bool], optional) – Means Delta Degrees of Freedom. If ddof is an integer, the divisor used in calculations is Nddof, where N represents the number of elements. If ddof is True, will use the Bessel correction unbiased estimation. If ddof is False, will through the biased estimation to calculate the variance. Default: 0 .

  • keepdims (bool, optional) – Whether the output Tensor has dim retained or not. If true, keep these reduced dimensions and the length is 1. If false, don't keep these dimensions. Default: False .

Returns

A tuple containing the variance and mean. Suppose the shape of input is (x0,x1,...,xR):

  • If axis is () and keepdims is set to False , returns a 0-D Tensor, indicating the standard deviation of all elements in input.

  • If axis is int 1 and keepdims is set to False , then the returned Tensor has shape (x0,x2,...,xR).

  • If axis is tuple(int) or list(int), e.g. (1, 2) and keepdims is set to False , then the returned Tensor has shape (x0,x2,...,xR).

Raises
  • TypeError – If input is not a Tensor.

  • TypeError – If axis is not one of the following: None, int, tuple.

  • TypeError – If keepdims is not a bool.

  • ValueError – If axis is out of range.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore as ms
>>> input = ms.Tensor([[1, 2, 3, 4], [-1, 1, 4, -10]], ms.float32)
>>> output_var, output_mean = ms.ops.var_mean(input, 1, 2, True)
>>> print(output_var)
[[ 2.5]
 [54.5]]
>>> print(output_mean)
[[ 2.5]
 [-1.5]]