📜  使用 Python numpy.argmax() 从矩阵中查找最大元素 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:08.164000             🧑  作者: Mango

代码示例1
import numpy as np    

a = np.matrix([[1,2,3,33],[4,5,6,66],[7,8,9,99]])

print(np.argmax(a))  # 11, which is the position of 99
print(np.argmax(a[:,:]))  # 11, which is the position of 99
print(np.argmax(a[:1]))  # 3, which is the position of 33
print(np.argmax(a[:,2]))  # 2, which is the position of 9
print(np.argmax(a[1:,2]))  # 1, which is the position of 9