mindspore.ops.aminmax
- mindspore.ops.aminmax(input, *, axis=0, keepdims=False)[source]
Return the minimum values and maximum values along the given axes of the tensor.
- Parameters
input (Tensor) – The input tensor.
- Keyword Arguments
- Returns
Tuple(min, max) of 2 tensors.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> input = mindspore.tensor([[9, 3, 4, 5], >>> [5, 2, 7, 4], >>> [8, 1, 3, 6]]) >>> >>> # case 1: By default, compute along axis 0. >>> mindspore.ops.aminmax(input) (Tensor(shape=[4], dtype=Int64, value= [5, 1, 3, 4]), Tensor(shape=[4], dtype=Int64, value= [9, 3, 7, 6])) >>> >>> # case 2: Disregard NaN (Not a Number) values present in the input during computation. >>> input = mindspore.tensor([[9, 3, 4, 5], >>> [5, 2, 7, 4], >>> [8, 1, 3, float('nan')]]) >>> mindspore.ops.aminmax(input, axis=None) (Tensor(shape=[], dtype=Float32, value= 1), Tensor(shape=[], dtype=Float32, value= 9)) >>> >>> # case 3: If keepdims=True, the output shape will be same of that of the input. >>> mindspore.ops.aminmax(input, axis=None, keepdims=True) (Tensor(shape=[1, 1], dtype=Float32, value= [[ 1.00000000e+00]]), Tensor(shape=[1, 1], dtype=Float32, value= [[ 9.00000000e+00]]))