mygrad.amin(x: ArrayLike, axis: Union[None, int, Tuple[int, ...]] = None, keepdims: bool = False, *, constant: Optional[bool] = None) Tensor#

Return the minimum of a tensor or minimum along its axes.

axisOptional[int, Tuple[int, …]]

Axis or axes along which to operate. By default, flattened input is used.

keepdimsbool, optional

If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original arr.


If True, this tensor is treated as a constant, and thus does not facilitate back propagation (i.e. constant.grad will always return None).

Defaults to False for float-type data. Defaults to True for integer-type data.

Integer-type tensors must be constant.


Minimum of a. If axis is None, the result is a 0-D tensor.


>>> import mygrad as mg
>>> import numpy as np
>>> a = mg.arange(4).reshape((2,2))
>>> a
Tensor([[0, 1],
        [2, 3]])
>>> mg.amin(a)           # Minimum of the flattened array
>>> mg.amin(a, axis=0)   # Minima along the first axis
Tensor([0, 1])
>>> mg.amin(a, axis=1)   # Minima along the second axis
Tensor([0, 2])
>>> b = mg.arange(5, dtype=float)
>>> b[2] = np.NaN
>>> mg.amin(b)