NumPy - numpy.argmax
NumPy Manual
https://numpy.org/doc/stable/index.html
numpy.argmax
https://numpy.org/doc/stable/reference/generated/numpy.argmax.html
1. numpy.argmax
numpy.argmax(a, axis=None, out=None)
Returns the indices of the maximum values along an axis.
返回沿轴的最大值的索引。
Parameters
a: array_like
Input array.
axis: int, optional
By default, the index is into the flattened array, otherwise along the specified axis.
默认情况下,索引位于扁平数组中,否则沿指定轴。
out: array, optional
If provided, the result will be inserted into this array. It should be of the appropriate shape and dtype.
如果提供,结果将被插入到这个数组中。 它应该具有适当的 shape and dtype。
Returns
index_array: ndarray of ints
Array of indices into the array. It has the same shape as a.shape with the dimension along axis removed.
数组中的索引数组。它具有与 a.shape 相同的形状,但沿轴的维度已被移除。
1.1 Notes
In case of multiple occurrences of the maximum values, the indices corresponding to the first occurrence are returned.
如果最大值出现多次,则返回第一次出现对应的索引。
1.2 Examples
References
https://numpy.org/doc/stable/reference/generated/numpy.argmax.html