📜  argmax 更改多个最大值的默认值 - Python 代码示例

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

代码示例1
def my_argmax(a):
    rows = np.where(a == a.max(axis=1)[:, None])[0]
    rows_multiple_max = rows[:-1][rows[:-1] == rows[1:]]
    my_argmax = a.argmax(axis=1)
    my_argmax[rows_multiple_max] = -1
    return my_argmax