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 ({None, int}, optional) -- By default, the index is into the flattened array, otherwise along the specified axis. 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. Default: None.

  • keepdims ({None, bool}, 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 array. Default: False.

Returns:

out -- Array of indices into the array. It has the same shape as a.shape with the dimension along axis removed. If keepdims is set to True, then the size of axis will be 1 with the resulting array having same shape as a.shape.

Return type:

dpnp.ndarray

See also

dpnp.ndarray.argmin

Equivalent function.

dpnp.nanargmin

Returns the indices of the minimum values along an axis, ignoring NaNs.

dpnp.argmax

Returns the indices of the maximum values along an axis.

dpnp.min

The minimum value along a given axis.

dpnp.unravel_index

Convert a flat index into an index tuple.

dpnp.take_along_axis

Apply np.expand_dims(index_array, axis)

from

obj:dpnp.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)