fix Tensor min api docs
This commit is contained in:
parent
abd4dd0dc2
commit
d3a61af8bf
|
@ -3,4 +3,16 @@ mindspore.Tensor.min
|
|||
|
||||
.. py:method:: mindspore.Tensor.min(axis=None, keepdims=False, initial=None, where=True)
|
||||
|
||||
详情请参考 :func:`mindspore.ops.min`。
|
||||
返回Tensor元素中的最小值或沿 `axis` 轴方向上的最小值。
|
||||
|
||||
参数:
|
||||
- **axis** (Union[None, int, list, tuple of ints], 可选) - 轴,在该轴方向上进行操作。默认情况下,使用扁平输入。如果该参数为整数元组,则在多个轴上选择最小值,而不是在单个轴或所有轴上进行选择。默认值:None。
|
||||
- **keepdims** (bool, 可选) - 如果这个参数为True,被删去的维度保留在结果中,且维度设为1。有了这个选项,结果就可以与输入数组进行正确的广播运算。默认值:False。
|
||||
- **initial** (scalar, 可选) - 输出元素的最小值。如果对空切片进行计算,则该参数必须设置。默认值:None。
|
||||
- **where** (Tensor[bool], 可选) - 一个bool类型的Tensor,被广播以匹配数组维度和选择包含在降维中的元素。如果传递了一个非默认值,则必须提供初始值。默认值:True。
|
||||
|
||||
返回:
|
||||
Tensor或标量,输入Tensor的最小值。如果 `axis` 为None,则结果是一个标量值。如果提供了 `axis` ,则结果是Tensor ndim - 1维度的一个数组。
|
||||
|
||||
异常:
|
||||
- **TypeError** - 参数的数据类型与上述不一致。
|
||||
|
|
|
@ -2033,7 +2033,58 @@ class Tensor(Tensor_):
|
|||
|
||||
def min(self, axis=None, keepdims=False, initial=None, where=True):
|
||||
"""
|
||||
For details, please refer to :func:`mindspore.ops.min`.
|
||||
Return the minimum of a tensor or minimum along an axis.
|
||||
|
||||
Args:
|
||||
axis (Union[None, int, list, tuple of ints], optional): An axis or
|
||||
axes along which to operate. By default, flattened input is used. If
|
||||
`axis` is a tuple of ints, the minimum is selected over multiple axes,
|
||||
instead of a single axis or all the axes as before. Default: None.
|
||||
keepdims (bool, optional):
|
||||
If True, the axes which are reduced are left in the
|
||||
result as dimensions with size one. With this option, the result will
|
||||
broadcast correctly against the input array. Default: False.
|
||||
initial (scalar, optional):
|
||||
The minimum value of an output element. Must be present to allow
|
||||
computation on empty slice. Default: None.
|
||||
where (bool Tensor, optional):
|
||||
A boolean tensor which is broadcasted to match the dimensions of array,
|
||||
and selects elements to include in the reduction. If non-default value
|
||||
is passed, initial must also be provided. Default: True.
|
||||
|
||||
Returns:
|
||||
Tensor or scalar, minimum of input tensor. If `axis` is None, the result is a scalar
|
||||
value. If `axis` is given, the result is a tensor of dimension ``self.ndim - 1``.
|
||||
|
||||
Raises:
|
||||
TypeError: If arguments have types not specified above.
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``GPU`` ``CPU``
|
||||
|
||||
See also:
|
||||
:func:`mindspore.Tensor.argmin`: Return the indices of the minimum values along an axis.
|
||||
|
||||
:func:`mindspore.Tensor.argmax`: Return the indices of the maximum values along an axis.
|
||||
|
||||
:func:`mindspore.Tensor.max`: Return the minimum of a tensor or minimum along an axis.
|
||||
|
||||
Examples:
|
||||
>>> import numpy as np
|
||||
>>> from mindspore import Tensor
|
||||
>>> a = Tensor(np.arange(4).reshape((2, 2)).astype('float32'))
|
||||
>>> output = a.min()
|
||||
>>> print(output)
|
||||
0.0
|
||||
>>> output = a.min(axis=0)
|
||||
>>> print(output)
|
||||
[0. 1.]
|
||||
>>> output = a.min(axis=0, initial=9, where=Tensor([False]))
|
||||
>>> print(output)
|
||||
[9. 9.]
|
||||
>>> output = a.min(axis=0, initial=9, where=Tensor([False, True]))
|
||||
>>> print(output)
|
||||
[9. 1.]
|
||||
"""
|
||||
reduce_ = tensor_operator_registry.get("reduce")
|
||||
reduce_min = tensor_operator_registry.get("reduce_min")
|
||||
|
|
Loading…
Reference in New Issue