argmax outputs the element number of the one with the largest dimension specified by axis.
tmp.py
import numpy as np
array = [[2,3,4],
[5,6,4],
[3,2,1],
[2,1,3]]
array = np.array(array)
print(np.argmax(array, axis=0)) # [1 1 0]
print(np.argmax(array, axis=1)) # [2 1 0 2]
In print (np.argmax (array, axis = 0))
,
[2,5,3,2] [3,6,2,1] [4,4,1,3] are targeted.
Therefore, "5", "6", "4" are picked up.
Each element number is [1 1 0].
In print (np.argmax (array, axis = 1))
,
[2,3,4], [5,6,4], [3,2,1], [2,1,3] are targeted.
Therefore, "4", "6", "3", "3" are picked up.
Each element number is [2 1 0 2].
If axis is not specified, it will be 4. I haven't investigated this for some reason.
tmp.py
print(np.argmax(array) #=> 4
Recommended Posts