mygrad.amin#
- mygrad.amin(x: ArrayLike, axis: None | int | Tuple[int, ...] = None, keepdims: bool = False, *, constant: bool | None = None) Tensor #
Return the minimum of a tensor or minimum along its axes.
- Parameters:
- 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.
- constantOptional[bool]
If
True
, this tensor is treated as a constant, and thus does not facilitate back propagation (i.e.constant.grad
will always returnNone
).Defaults to
False
for float-type data. Defaults toTrue
for integer-type data.Integer-type tensors must be constant.
- Returns:
- minmygrad.Tensor
Minimum of a. If axis is None, the result is a 0-D tensor.
Examples
>>> 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 Tensor(0) >>> 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) Tensor(nan)