amin#
- ivy.amin(x, /, *, axis=None, keepdims=False, out=None)[source]#
Calculate the minimum value of the input array
x
.Note
amin
is an alias ofmin
and both function behaves similarly in every backend except PyTorch and PaddlePaddle (see PyTorch’s amin function documentation<https://pytorch.org/docs/stable/generated/torch.amin.html>`_) (see PaddlePaddle’s amin function documentation<https://www.paddlepaddle.org.cn/ documentation/docs/zh/api/paddle/amin_cn.html>`_)Note
When the number of elements over which to compute the minimum value is zero, the minimum value is implementation-defined. Specification-compliant libraries may choose to raise an error, return a sentinel value (e.g., if
x
is a floating-point input array, returnNaN
), or return the maximum possible value for the input arrayx
data type (e.g., ifx
is a floating-point array, return+infinity
).Special Cases
For floating-point operands,
If
x_i
isNaN
, the minimum value isNaN
(i.e.,NaN
values propagate).
- Parameters:
x (
Union
[Array
,NativeArray
]) – input array. Should have a real-valued data type.axis (
Optional
[Union
[int
,Sequence
[int
]]], default:None
) – axis or axes along which minimum values must be computed. By default, the minimum value must be computed over the entire array. If a tuple of integers, minimum values must be computed over multiple axes. Default:None
.keepdims (
bool
, default:False
) – optional boolean, ifTrue
, the reduced axes (dimensions) must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array (see `broadcasting<https://data-apis.org/ array-api/latest/API_specification/broadcasting.html#broadcasting>`_). Otherwise, ifFalse
, the reduced axes (dimensions) must not be included in the result. Default:False
.out (
Optional
[Array
], default:None
) – optional output array, for writing the result to.
- Return type:
- Returns:
ret – if the minimum value was computed over the entire array, a zero-dimensional array containing the minimum value; otherwise, a non-zero-dimensional array containing the minimum values. The returned array must have the same data type as
x
.
This function conforms to the Array API Standard. This docstring is an extension of the docstring in the standard.
Both the description and the type hints above assumes an array input for simplicity, but this function is nestable, and therefore also accepts
ivy.Container
instances in place of any of the arguments.Examples
With
ivy.Array
input:>>> x = ivy.array([1, 2, 3]) >>> y = ivy.amin(x) >>> print(y) ivy.array(1)
>>> x = ivy.array([0, 1, 2]) >>> z = ivy.array([0, 0, 0]) >>> y = ivy.amin(x, out=z) >>> print(z) ivy.array(0)
>>> x = ivy.array([[0, 1, 2], [4, 6, 10]]) >>> y = ivy.amin(x, axis=0, keepdims=True) >>> print(y) ivy.array([[0, 1, 2]])
>>> x = ivy.native_array([[0, 1, 2], [4, 6, 10]]) >>> y = ivy.amin(x) >>> print(y) ivy.array(0)
With
ivy.Container
input:>>> x = ivy.Container(a=ivy.array([1, 2, 3]), b=ivy.array([2, 3, 4])) >>> y = ivy.amin(x) >>> print(y) { a: ivy.array(1), b: ivy.array(2) }
- Array.amin(self, /, *, axis=None, keepdims=False, out=None)[source]#
ivy.Array instance method variant of ivy.amin. This method simply wraps the function, and so the docstring for ivy.amin also applies to this method with minimal changes.
- Parameters:
self (
Array
) – input array. Should have a real-valued data type.axis (
Optional
[Union
[int
,Sequence
[int
]]], default:None
) – axis or axes along which minimum values must be computed. By default, the minimum value must be computed over the entire array. If a tuple of integers, minimum values must be computed over multiple axes. Default:None
.keepdims (
bool
, default:False
) – optional boolean, ifTrue
, the reduced axes (dimensions) must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array (see `broadcasting<https://data-apis.org/array-api/latest/ API_specification/broadcasting.html#broadcasting>`_). Otherwise, ifFalse
, the reduced axes (dimensions) must not be included in the result. Default:False
.out (
Optional
[Array
], default:None
) – optional output array, for writing the result to.
- Return type:
Array
- Returns:
ret – if the minimum value was computed over the entire array, a zero-dimensional array containing the minimum value; otherwise, a non-zero-dimensional array containing the minimum values. The returned array must have the same data type as
x
.
Examples
>>> x = ivy.array([3., 4., 5.]) >>> y = x.amin() >>> print(y) ivy.array(3.)
>>> x = ivy.array([[-1, 0, 1], [2, 3, 4]]) >>> y = x.amin(axis=1) >>> print(y) ivy.array([-1, 2])
>>> x = ivy.array([0.1, 1.1, 2.1]) >>> y = ivy.array(0.) >>> x.amin(out=y) >>> print(y) ivy.array(0.1)
- Container.amin(self, /, *, axis=None, keepdims=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
ivy.Container instance method variant of ivy.amin. This method simply wraps the function, and so the docstring for ivy.amin also applies to this method with minimal changes.
- Parameters:
self (
Container
) – input container. Should have a real-valued data type.axis (
Optional
[Union
[int
,Sequence
[int
],Container
]], default:None
) – axis or axes along which minimum values must be computed. By default, the minimum value must be computed over the entire array. If a tuple of integers, minimum values must be computed over multiple axes. Default:None
.keepdims (
Union
[bool
,Container
], default:False
) – optional boolean, ifTrue
, the reduced axes (dimensions) must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array (see `broadcasting<https://data-apis.org/array-api/latest/ API_specification/broadcasting.html#broadcasting>`_). Otherwise, ifFalse
, the reduced axes (dimensions) must not be included in the result. Default:False
.key_chains (
Optional
[Union
[List
[str
],Dict
[str
,str
],Container
]], default:None
) – The key-chains to apply or not apply the method to. Default isNone
.to_apply (
Union
[bool
,Container
], default:True
) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default isTrue
.prune_unapplied (
Union
[bool
,Container
], default:False
) – Whether to prune key_chains for which the function was not applied. Default isFalse
.map_sequences (
Union
[bool
,Container
], default:False
) – Whether to also map method to sequences (lists, tuples). Default isFalse
.out (
Optional
[Container
], default:None
) – optional output, for writing the result to. It must have a shape that the inputs broadcast to.
- Return type:
Container
- Returns:
ret – container, if the minimum value was computed over the entire array, a zero-dimensional array containing the minimum value; otherwise, a non-zero-dimensional array containing the minimum values. The returned array must have the same data type as
x
.
Examples
With
ivy.Container
input:>>> x = ivy.Container(a=ivy.array([1, 2, 3]), ... b=ivy.array([2, 3, 4])) >>> y = x.amin() >>> print(y) { a: ivy.array(1), b: ivy.array(2) }
>>> x = ivy.Container(a=ivy.array([[1, 2, 3], [-1, 0, 2]]), ... b=ivy.array([[2, 3, 4], [0, 1, 2]])) >>> y = x.amin(axis=1) >>> print(y) { a:ivy.array([1, -1]), b:ivy.array([2, 0]) }