np.random.seed(2)
a = np.random.rand(5,3)
print(a)
result:
a = [[0.4359949 0.02592623 0.54966248]
[0.43532239 0.4203678 0.33033482]
[0.20464863 0.61927097 0.29965467]
[0.26682728 0.62113383 0.52914209]
[0.13457995 0.51357812 0.18443987]]
轴0最大值的指标
m = a.shape[1]
a_labels = np.argmax(a,axis=0).reshape(1,m)
print(a_labels)
result:
a_labels = [[0 3 0]]
我想使每一列的最大值为0,如下所示...。我该怎么办?
result needed:
a = [[0 0.02592623 0 ]
[0.43532239 0.4203678 0.33033482]
[0.20464863 0.61927097 0.29965467]
[0.26682728 0 0.52914209]
[0.13457995 0.51357812 0.18443987]]