mindspore.ops.aminmax
- mindspore.ops.aminmax(input, *, axis=0, keepdims=False)[source]
It returns the minimum and maximum value along the given axis of input tensor.
- Parameters
input (Tensor) – The input tensor, can be any dimension. Set the shape of input tensor as \((x_1, x_2, ..., x_N)\) .
- Keyword Arguments
axis (int, optional) – The dimension to reduce. The value range of axis is [-rank, rank), where “rank” is the dimension of input. Default: 0.
keepdims (bool, optional) – Whether to maintain dimension. When set to True, the output will keep the same dimension as the input, or the dimension specified by axis is reduced. Default: False.
- Returns
tuple (Tensor), containing the minimum value and maximum value of the input tensor.
If keepdims is True, the shape of output tensors is \((x_1, x_2, ..., x_{axis-1}, 1, x_{axis+1}, ..., x_N)\).
If keepdims is False, the shape of output tensors is \((x_1, x_2, ..., x_{axis-1}, x_{axis+1}, ..., x_N)\).
- Raises
TypeError – If keepdims is not a bool.
TypeError – If axis is not an int.
ValueError – If axis is not in range [-rank, rank).
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> x = Tensor(np.array([0.0, 0.4, 0.6, 0.7, 0.1]), mindspore.float32) >>> output0, output1 = ops.aminmax(x) >>> print(output0, output1) 0.0 0.7 >>> output2, output3 = ops.aminmax(x, axis=-1, keepdims=True) >>> print(output2, output3) [0.] [0.7]