📜  Python| numpy matrix.argmax()

📅  最后修改于: 2022-05-13 01:55:18.753000             🧑  作者: Mango

Python| numpy matrix.argmax()

借助Numpy matrix.argmax()方法,我们能够找到给定矩阵中具有一维或多维的最大元素的索引值。

示例 #1:
在这个例子中,我们可以看到在matrix.argmax()方法的帮助下,我们能够找到给定矩阵中最大元素的索引。

# import the important module in python
import numpy as np
           
# make a matrix with numpy
gfg = np.matrix('[1, 2, 3, 4]')
           
# applying matrix.argmax() method
geeks = gfg.argmax()
     
print(geeks)
输出:
3

示例 #2:

# import the important module in python
import numpy as np
           
# make a matrix with numpy
gfg = np.matrix('[1, 2, 3; 4, 5, 6; 7, 8, 9]')
           
# applying matrix.argmax() method
geeks = gfg.argmax()
     
print(geeks)
输出:
8