dpnp.argmax

dpnp.argmax(a, axis=None, out=None, *, keepdims=False)[source]

Returns the indices of the maximum values along an axis.

For full documentation refer to numpy.argmax.

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.argmax

Equivalent function.

dpnp.nanargmax

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

dpnp.argmin

Returns the indices of the minimum values along an axis.

dpnp.max

The maximum 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.argmax to an array as if by calling max.

Notes

In case of multiple occurrences of the maximum 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.argmax(a)
array(5)
>>> np.argmax(a, axis=0)
array([1, 1, 1])
>>> np.argmax(a, axis=1)
array([2, 2])
>>> b = np.arange(6)
>>> b[1] = 5
>>> b
array([0, 5, 2, 3, 4, 5])
>>> np.argmax(b)  # Only the first occurrence is returned.
array(1)
>>> x = np.arange(24).reshape((2, 3, 4))
>>> res = np.argmax(x, axis=1, keepdims=True) # Setting keepdims to True
>>> res.shape
(2, 1, 4)