np.argmax()は、配列の最大値を求める次元numpyのの指標となる要素は、以下の例:
import numpy as np
x = np.random.normal(1,4,(3,5))
y = np.argmax(x,axis=1)
print(x)
print(x.shape)
print(y)
print(y.shape)
输出结果为:
[[ 0.21732346 -3.48525172 -2.19230097 1.53942774 1.51051946]
[-4.298163 1.24736953 -1.24371032 -1.0929181 -2.04791179]
[ 2.29861605 2.14217121 -2.61879844 5.49840773 2.11360768]]
(3, 5)
[3 1 3]
(3,)
ここで、x = np.random.normal(1,4、(3,5))、xはアレイの世代1の平均値を表す、標準偏差4、[3,5]の大きさです。
Y = np.argmax(X軸= 1)、Iは第一次元における最大の要素を検索する軸= 1つの指定代表インデックス値。
次のように別の例は次のとおりです。
import numpy as np
x = np.random.normal(1,4,(3,5))
y = np.argmax(x,axis=0)
print(x)
print(x.shape)
print(y)
print(y.shape)
输出结果为:
[[ 2.9624991 7.85484938 1.45422659 5.76279443 -4.96967595]
[ 5.23517858 4.15894847 8.83419527 4.76619198 9.31344739]
[-1.73967324 3.03142305 -3.28402655 4.01823193 2.01979302]]
(3, 5)
[1 0 1 0 1]
(5,)
軸= 0、インデックス値は、Iが0番目の次元で検索する最大の要素を表しています。