📜  Python| numpy matrix.argmin()

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

Python| numpy matrix.argmin()

借助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.argmin() method
geeks = gfg.argmin()
     
print(geeks)
输出:
0

示例 #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.argmin() method
geeks = gfg.argmin()
     
print(geeks)
输出:
4