mindspore.mint.amin
- mindspore.mint.amin(input, dim=(), keepdim=False)[源代码]
返回tensor在指定维度上的最小值。
警告
这是一个实验性API,后续可能修改或删除。
- 参数:
input (Tensor) - 输入tensor。
dim (Union[int, tuple(int), list(int)], 可选) - 指定计算维度, 输入为 () 时计算所有元素。默认
()。keepdim (bool, 可选) - 输出tensor是否保留维度 dim。默认
False。
- 返回:
Tensor
- 支持平台:
Ascend
样例:
>>> import mindspore >>> import numpy as np >>> x = mindspore.tensor(np.random.randn(3, 4, 5, 6).astype(np.float32)) >>> output = mindspore.mint.amin(x, 1, keepdim=True) >>> result = output.shape >>> print(result) (3, 1, 5, 6) >>> # case 1: Reduce a dimension by the minimum value of all elements in the dimension. >>> x = mindspore.tensor(np.array([[[1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3]], ... [[4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6]], ... [[7, 7, 7, 7, 7, 7], [8, 8, 8, 8, 8, 8], [9, 9, 9, 9, 9, 9]]]), ... mindspore.float32) >>> output = mindspore.mint.amin(x) >>> print(output) 1.0 >>> print(output.shape) () >>> # case 2: Reduce a dimension along axis 0. >>> output = mindspore.mint.amin(x, 0, True) >>> print(output) [[[1. 1. 1. 1. 1. 1.] [2. 2. 2. 2. 2. 2.] [3. 3. 3. 3. 3. 3.]]] >>> # case 3: Reduce a dimension along axis 1. >>> output = mindspore.mint.amin(x, 1, True) >>> print(output) [[[1. 1. 1. 1. 1. 1.]] [[4. 4. 4. 4. 4. 4.]] [[7. 7. 7. 7. 7. 7.]]] >>> # case 4: Reduce a dimension along axis 2. >>> output = mindspore.mint.amin(x, 2, True) >>> print(output) [[[1.] [2.] [3.]] [[4.] [5.] [6.]] [[7.] [8.] [9.]]]