numpy如何获取多维矩阵中最大值的坐标

利用argmax和unravel_index函数即可。任何维度的矩阵都可以。

import numpy as np a = np.array([[1,2,3],[4,5,6],[3,2,1]]) pos = np.unravel_index(np.argmax(a),a.shape) print(pos) --------------- (1, 2)

【numpy如何获取多维矩阵中最大值的坐标】参考:https://stackoverflow.com/questions/3584243/get-the-position-of-the-biggest-item-in-a-multi-dimensional-numpy-array

    推荐阅读