mindspore.mint.max
- mindspore.mint.max(input) Tensor [source]
Returns the maximum value of the input tensor.
- Parameters
input (Tensor) – The input tensor.
- Returns
Scalar Tensor with the same dtype as input, the maximum value of the input.
- Supported Platforms:
Ascend
Examples
>>> import mindspore >>> import numpy as np >>> from mindspore import Tensor, mint >>> x = Tensor(np.array([0.0, 0.4, 0.6, 0.7, 0.1]), mindspore.float32) >>> output = mint.max(x) >>> print(output) 0.7
- mindspore.mint.max(input, dim, keepdim=False)[source]
Calculates the maximum value along with the given dim for the input tensor, and returns the maximum values and indices.
- Parameters
input (Tensor) – The input tensor, can be any dimension. Set the shape of input tensor as \((input_1, input_2, ..., input_N)\) , Complex tensor is not supported.
dim (int) – The dimension to reduce.
keepdim (bool, optional) – Whether to reduce dimension, if
True
the output will keep the same dimension as the input , the output will reduce dimension iffalse
. Default:False
.
- Returns
tuple (Tensor), tuple of 2 tensors, containing the maximum value of the self tensor along the given dimension dim and the corresponding index.
values (Tensor) - The maximum value of input tensor, with the same shape as index, and same dtype as input.
index (Tensor) - The index for the maximum value of the input tensor, with dtype int64. If keepdim is
True
, the shape of output tensors is \((input_1, input_2, ..., input_{dim-1}, 1, input_{dim+1}, ..., input_N)\). Otherwise, the shape is \((input_1, input_2, ..., input_{dim-1}, input_{dim+1}, ..., input_N)\) .
- Raises
- Supported Platforms:
Ascend
Examples
>>> import mindspore >>> import numpy as np >>> from mindspore import Tensor, mint >>> x = Tensor(np.array([0.0, 0.4, 0.6, 0.7, 0.1]), mindspore.float32) >>> output, index = mint.max(x, 0, keepdim=True) >>> print(output, index) [0.7] [3]
For details, please refer to
mindspore.mint.maximum()
.