mindspore.ops.nanmedian

View Source On Gitee
mindspore.ops.nanmedian(input, axis=- 1, keepdims=False)[source]

Computes the median and indices of input in specified dimension, ignoring NaN.

Warning

indices does not necessarily contain the first occurrence of each median value found in the input, unless it is unique.

Parameters
  • input (Tensor) – The input tensor.

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

  • keepdims (bool, optional) – Whether the output tensor needs to retain dimension or not. Default False .

Returns

Tuple(median, median_indices)

Supported Platforms:

CPU

Examples

>>> import mindspore
>>> x = mindspore.tensor([[0.57, 0.11, float("nan")],
...             [0.38, float("nan"), float("nan")],
...             [0.36, 0.16, float("nan")]], mindspore.float32)
>>> y, idx = mindspore.ops.nanmedian(x, axis=0, keepdims=False)
>>> print(y)
[0.38 0.11  nan]
>>> print(idx)
[1 0 0]