发布于 2022-07-13 15:31:33
是的,这实际上是在numpy.argmax
文档中解释的:
Notes 在最大值多次出现的情况下,返回对应于第一次出现的索引。
发布于 2022-07-13 15:34:54
是的,它只输出第一个匹配项,但是可以使用np.argsort获得n个最高值:
np.argsort(your_array)[-n:] #the top n indexes
即:
n=2
a = np.array([1,2,3,3,-1])
np.argsort(a)[-n:]
>array([2, 3], dtype=int64) #elements at index 2 and 3 in array a (3, 3) have the top max values
https://stackoverflow.com/questions/72968858
复制相似问题