argmax¶
- argmax(x: array, /, *, axis: int | None = None, keepdims: bool = False) array ¶
Returns the indices of the maximum values along a specified axis.
When the maximum value occurs multiple times, only the indices corresponding to the first occurrence are returned.
Note
For backward compatibility, conforming implementations may support complex numbers; however, inequality comparison of complex numbers is unspecified and thus implementation-dependent (see Complex Number Ordering).
- Parameters:
x (array) – input array. Should have a real-valued data type.
axis (Optional[int]) – axis along which to search. If
None
, the function must return the index of the maximum value of the flattened array. Default:None
.keepdims (bool) – 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 (see Broadcasting). Otherwise, ifFalse
, the reduced axes (dimensions) must not be included in the result. Default:False
.
- Returns:
out (array) – if
axis
isNone
, a zero-dimensional array containing the index of the first occurrence of the maximum value; otherwise, a non-zero-dimensional array containing the indices of the maximum values. The returned array must have be the default array index data type.