@numpy数组的max、min、argmax和argmin计算方法
数组:
2 | 4 | 6 | 1 |
1 | 5 | 2 | 9 |
import numpy as np
if __name__ == '__main__':
a = np.array([[2, 4, 6, 1], [1, 5, 2, 9]])
print(a)
print(np.argmax(a, axis=0)) # axis=0是指把第零个维度压缩为1
print(np.argmax(a, axis=1)) # axis=1是指把第一个维度压缩为1
# 预估axis=0会输出[0 1 0 1]
pass
运行结果: