python - 在 (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, axis=(0,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, axis=(0,1))) #this should return 3 indices instead of 4
>>[[0 1 1]
[1 0 0]
[1 0 2]
[1 1 1]]
那么是否有任何“numpy 方式”来获取 3d 数组在 (0, 1) 轴上的唯一最大索引。
解决方案
推荐阅读
- database - Sybase ASE 15.7:创建触发器,以便在插入之前我想修改要插入的行
- react-native - React-native 在页面之间发送信息?
- c# - C# WinForms - 不相互交谈的表单
- android - Android:活动时更改材质 TextInputLayout 的背景颜色
- spring - Spring在JSON序列化中将属性名称转换为小写
- python - 将键盘宏与热键结合使用?
- azure-logic-apps - 用于评估 ftp 的 Azure 逻辑应用程序成本(添加或修改文件时)?
- c# - TCP 服务器未从 RFID 阅读器接收数据
- d3.js - d3 折线图的动画区域
- azure - 使用 Runbook 载入 Azure VM 以更新管理