jax.numpy.minmax#
- jax.numpy.minmax(a, axis=None, out=None, keepdims=False, initial=None, where=None)[source]#
Return the minimum and maximum of array elements along a given axis.
JAX implementation of
numpy.minmax().- Parameters:
a (ArrayLike) – Input array.
axis (Axis) – int or array, default=None. Axis along which the minimum to be computed. If None, the minimum is computed along all the axes.
keepdims (bool) – bool, default=False. If true, reduced axes are left in the result with size 1.
initial (ArrayLike | tuple[ArrayLike, ArrayLike] | None) – int or array, or tuple of ints. Default=None. Initial value for the minimum and maximum. If given as a tuple, the first entry is the maximum value for the minimum result, and the second entry is the minimum value for the maximum result.
where (ArrayLike | None) – int or array, default=None. The elements to be used in the minimum. Array should be broadcast compatible to the input.
initialmust be specified whenwhereis used.out (None) – Unused by JAX.
- Returns:
A tuple of arrays
(a_min, a_max)containing the arrays of minimum and maximum values along the given axis.- Return type:
See also
jax.numpy.min(): Compute the maximum of array elements along a given axis.jax.numpy.max(): Compute the maximum of array elements along a given axis.
Examples
By default, the minimum is computed along all the axes.
>>> x = jnp.array([[2, 5, 1, 6], ... [3, -7, -2, 4], ... [8, -4, 1, -3]]) >>> jnp.minmax(x) (Array(-7, dtype=int32), Array(8, dtype=int32))