mindspore.ops.amin
- mindspore.ops.amin(input, axis=None, keepdims=False, *, initial=None, where=None)[source]
Return the minimum values along the given axis of the tensor.
Warning
Starting after version 2.9.0, this API will undergo an incompatible change:
The parameter axis will be renamed to dim, with default value changing to
().The parameter keepdims will be renamed to keepdim.
The keyword arguments initial and where will be removed.
The new signature will be
mindspore.ops.amin(input, dim=(), keepdim=False).- Parameters
- Keyword Arguments
initial (scalar, optional) – Initial value for the minimum. Default
None.where (Tensor[bool], optional) – Specifies the range over which to compute the minimum values. The shape of this tensor must be broadcastable to the shape of input . An initial value must be specified. Default
None, indicating that all elements are to be computed.
- Returns
Tensor
- Supported Platforms:
AscendGPUCPU
Examples
>>> import mindspore >>> input = mindspore.tensor([[2, 5, 1, 6], ... [3, -7, -2, 4], ... [8, -4, 1, -3]]) >>> # case 1: By default, compute the minimum of all elements. >>> mindspore.ops.amin(input) Tensor(shape=[], dtype=Int64, value= -7) >>> >>> # case 2: Compute minimum along axis 1. >>> mindspore.ops.amin(input, axis=1) Tensor(shape=[3], dtype=Int64, value= [ 1, -7, -4]) >>> >>> # case 3: If keepdims=True, the output shape will be the same as that of the input. >>> mindspore.ops.amin(input, axis=1, keepdims=True) Tensor(shape=[3, 1], dtype=Int64, value= [[ 1], [-7], [-4]]) >>> >>> # case 4: Use "where" to include only specific elements in computing the minimum. >>> where = mindspore.tensor([[1, 0, 1, 0], ... [0, 0, 1, 1], ... [1, 1, 1, 0]], dtype=mindspore.bool) >>> mindspore.ops.amin(input, axis=1, keepdims=True, initial=0, where=where) Tensor(shape=[3, 1], dtype=Int64, value= [[ 0], [-2], [-4]]) >>> >>> # case 5: The shape of "where" must be broadcast compatible with input. >>> where = mindspore.tensor([[False], ... [False], ... [False]]) >>> mindspore.ops.amin(input, axis=0, keepdims=True, initial=0, where=where) Tensor(shape=[1, 4], dtype=Int64, value= [[0, 0, 0, 0]])