mindspore.mint.amax
- mindspore.mint.amax(input, dim=(), keepdim=False)[source]
Compute the maximum value of all elements along the specified dimension.
Warning
This is an experimental API that is subject to change or deletion.
- Parameters
- Returns
Tensor
- Supported Platforms:
Ascend
Examples
>>> import mindspore >>> import numpy as np >>> x = mindspore.tensor(np.random.randn(3, 4, 5, 6).astype(np.float32)) >>> output = mindspore.mint.amax(x, dim=1, keepdim=True) >>> print(output.shape) (3, 1, 5, 6) >>> # case 1: Reduce a dimension by the maximum 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.amax(x) >>> print(output) 9.0 >>> print(output.shape) () >>> # case 2: Reduce a dimension along axis 0. >>> output = mindspore.mint.amax(x, dim=0, keepdim=True) >>> print(output) [[[7. 7. 7. 7. 7. 7.] [8. 8. 8. 8. 8. 8.] [9. 9. 9. 9. 9. 9.]]] >>> # case 3: Reduce a dimension along axis 1. >>> output = mindspore.mint.amax(x, dim=1, keepdim=True) >>> print(output) [[[3. 3. 3. 3. 3. 3.]] [[6. 6. 6. 6. 6. 6.]] [[9. 9. 9. 9. 9. 9.]]] >>> # case 4: Reduce a dimension along axis 2. >>> output = mindspore.mint.amax(x, dim=2, keepdim=True) >>> print(output) [[[1.] [2.] [3.]] [[4.] [5.] [6.]] [[7.] [8.] [9.]]]