dpnp.argmin
- dpnp.argmin(a, axis=None, out=None, *, keepdims=False)[source]
Returns the indices of the minimum values along an axis.
For full documentation refer to
numpy.argmin.- Parameters:
a ({dpnp.ndarray, usm_ndarray}) – Input array.
axis (int, optional) – Axis along which to search. If
None, the function must return the index of the minimum value of the flattened array. Default:None.out ({None, dpnp.ndarray, usm_ndarray}, optional) – If provided, the result will be inserted into this array. It should be of the appropriate shape and dtype.
keepdims (bool, optional) – If
True, the reduced axes (dimensions) must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array. Otherwise, ifFalse, the reduced axes (dimensions) must not be included in the result. Default:False.
- Returns:
out – If axis is
None, a zero-dimensional array containing the index of the first occurrence of the minimum value; otherwise, a non-zero-dimensional array containing the indices of the minimum values. The returned array must have the default array index data type.- Return type:
dpnp.ndarray
See also
dpnp.ndarray.argminEquivalent function.
dpnp.nanargminReturns the indices of the minimum values along an axis, igonring NaNs.
dpnp.argmaxReturns the indices of the maximum values along an axis.
dpnp.minThe minimum value along a given axis.
dpnp.unravel_indexConvert a flat index into an index tuple.
dpnp.take_along_axisApply
np.expand_dims(index_array, axis)from argmin to an array as if by calling min.
Notes
In case of multiple occurrences of the minimum values, the indices corresponding to the first occurrence are returned.
Examples
>>> import dpnp as np >>> a = np.arange(6).reshape((2, 3)) + 10 >>> a array([[10, 11, 12], [13, 14, 15]]) >>> np.argmin(a) array(0)
>>> np.argmin(a, axis=0) array([0, 0, 0]) >>> np.argmin(a, axis=1) array([0, 0])
>>> b = np.arange(6) + 10 >>> b[4] = 10 >>> b array([10, 11, 12, 13, 10, 15]) >>> np.argmin(b) # Only the first occurrence is returned. array(0)
>>> x = np.arange(24).reshape((2, 3, 4)) >>> res = np.argmin(x, axis=1, keepdims=True) # Setting keepdims to True >>> res.shape (2, 1, 4)