Numpy argmax. How to compute both max and argmax?

后端 未结 1 910
情歌与酒
情歌与酒 2021-01-07 16:39

Is there a way to get max and argmax by one stroke ?

import numpy as np
a=[0,0,1,0]
maximum=max(a)
index=np.argmax(a)

Is there a fastest wa

1条回答
  •  抹茶落季
    2021-01-07 17:06

    Maybe something like this is faster...

    index = np.argmax(a)
    max = a[index]
    

    0 讨论(0)
提交回复
热议问题