mindspore.ops.nanmean

View Source On Gitee
mindspore.ops.nanmean(input, axis=None, keepdims=False, *, dtype=None)[source]

Computes the mean of input in specified dimension, ignoring NaN.

Parameters
  • input (Tensor) – The input tensor.

  • axis (int, optional) – The specified axis for computation. Default None .

  • keepdims (bool, optional) – Whether the output tensor has to dim retained. Default False .

Keyword Arguments

dtype (mindspore.dtype, optional) – The data type returned. Default None .

Returns

Tensor

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> x = mindspore.tensor([[0.5, -1.1, float('nan')], [3.4, float('nan'), float('nan')]], mindspore.float32)
>>> y = mindspore.ops.nanmean(x, axis=0, keepdims=False)
>>> print(y)
[ 1.95 -1.1    nan]