import numpy as np
exemple=np.arange(9).reshape((3,3))
print(exemple)
#输出
#[[0 1 2]
# [3 4 5]
# [6 7 8]]
#全矩阵最大值 8
print(exemple.max())
#等价于:
#print(np.max(exemple))
#列最大值 输出:[6 7 8]
print(np.max(exemple,axis=0))
#行最大值 输出:[2 5 8]
print(np.max(exemple,axis=1))
#全矩阵最大值 索引
print(np.where(exemple==exemple.max()))
#输出
#(array([2], dtype=int64), array([2], dtype=int64))
numpy矩阵最大值
最新推荐文章于 2024-04-23 18:47:10 发布