微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在 (0, 1) 轴上查找 3d 数组的唯一最大索引

如何解决在 (0, 1) 轴上查找 3d 数组的唯一最大索引

我正在尝试在 (0,1) 轴上找到 3d 数组的最大索引。

我尝试将 argwhere 与 amax 一起使用,但如果它有多个最大值,它会在轴上返回多个索引

x = [[[ 4  5  9]
      [ 0 13  6]]

     [[12 11 13]
      [ 5 13  8]]]  

np.amax(x,axis=(0,1))
>> [12 13 13]  #I just want the indices of the following max values

x==np.amax(x,1))
#this seems to be the problem,multiple True in the second column
             v
>>[[[False False False]
    [False  True False]]

    [[True False  True]
     [False  True False]]]

np.argwhere(x==np.amax(x,1))) #this should return 3 indices instead of 4
>>[[0 1 1]
   [1 0 0]
   [1 0 2]
   [1 1 1]]

那么是否有任何“numpy 方法”可以在 (0,1) 轴上获得 3d 数组的唯一最大索引

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。