MCPcopy
hub / github.com/numpy/numpy / argmax

Function argmax

numpy/_core/fromnumeric.py:1260–1352  ·  view source on GitHub ↗

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 pr

(a, axis=None, out=None, *, keepdims=np._NoValue)

Source from the content-addressed store, hash-verified

1258
1259@array_function_dispatch(_argmax_dispatcher)
1260def argmax(a, axis=None, out=None, *, keepdims=np._NoValue):
1261 """
1262 Returns the indices of the maximum values along an axis.
1263
1264 Parameters
1265 ----------
1266 a : array_like
1267 Input array.
1268 axis : int, optional
1269 By default, the index is into the flattened array, otherwise
1270 along the specified axis.
1271 out : array, optional
1272 If provided, the result will be inserted into this array. It should
1273 be of the appropriate shape and dtype.
1274 keepdims : bool, optional
1275 If this is set to True, the axes which are reduced are left
1276 in the result as dimensions with size one. With this option,
1277 the result will broadcast correctly against the array.
1278
1279 .. versionadded:: 1.22.0
1280
1281 Returns
1282 -------
1283 index_array : ndarray of ints
1284 Array of indices into the array. It has the same shape as ``a.shape``
1285 with the dimension along `axis` removed. If `keepdims` is set to True,
1286 then the size of `axis` will be 1 with the resulting array having same
1287 shape as ``a.shape``.
1288
1289 See Also
1290 --------
1291 ndarray.argmax, argmin
1292 amax : The maximum value along a given axis.
1293 unravel_index : Convert a flat index into an index tuple.
1294 take_along_axis : Apply ``np.expand_dims(index_array, axis)``
1295 from argmax to an array as if by calling max.
1296
1297 Notes
1298 -----
1299 In case of multiple occurrences of the maximum values, the indices
1300 corresponding to the first occurrence are returned.
1301
1302 Examples
1303 --------
1304 >>> import numpy as np
1305 >>> a = np.arange(6).reshape(2,3) + 10
1306 >>> a
1307 array([[10, 11, 12],
1308 [13, 14, 15]])
1309 >>> np.argmax(a)
1310 5
1311 >>> np.argmax(a, axis=0)
1312 array([1, 1, 1])
1313 >>> np.argmax(a, axis=1)
1314 array([2, 2])
1315
1316 Indexes of the maximal elements of an N-dimensional array:
1317

Callers

nothing calls this directly

Calls 1

_wrapfuncFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…