mindspore/docs/api/api_python/ops/mindspore.ops.func_median.rst

28 lines
1.4 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.ops.median
====================
.. py:function:: mindspore.ops.median(x, global_median=False, axis=0, keep_dims=False)
输出张量指定维度上的中值。
.. warning::
如果 `global_median` 为True`indices` 无意义。
参数:
- **x** (Tensor) - median的输入任意维度的Tensor。数据类型支持int16、int32、int64、float32或float64。
- **global_median** (bool) - 表示是否对x的全部元素取中值。默认值False。
- **axis** (int) - 指定计算维度。默认值:(0), 取值范围为[-dims, dims - 1]`dims` 表示 `x` 的维度长度
- **keep_dims** (bool) - 表示是否减少维度如果为True输出将与输入保持相同的维度如果为False输出将减少维度。默认值False。
返回:
- **y** (Tensor) - 返回指定维度上的中值,数据类型与 `x` 相同。
- **indices** (bool) - 指定中值索引。数据类型为int64。如果 `global_median` 为True则结果无意义。
异常:
- **TypeError** - `x` 的数据类型不是: int16, int32, int64, float32, float64。
- **TypeError** - `x` 不是Tensor。
- **TypeError** - `global_median` 不是bool。
- **TypeError** - `axis` 不是int。
- **TypeError** - `keep_dims` 不是bool。
- **ValueError** - `axis` 的范围不在[-dims, dims - 1]`dims` 表示 `x` 的维度长度。