I have this torch array.
tensor([[8.22266e-01, 1.34659e-03, 9.85146e-04, 8.11100e-04],
[9.35547e-01, 1.22261e-03, 8.70228e-04, 1.25122e-03],
[9.48730e-01, 1.21975e-03, 9.28402e-04, 8.44955e-04],
[7.97363e-01, 9.16004e-04, 9.16004e-04, 8.53539e-04],
[9.26270e-01, 7.69138e-04, 8.47816e-04, 1.12724e-03],
[9.43848e-01, 7.44820e-04, 8.53539e-04, 8.60691e-04],
[7.89062e-01, 6.50406e-04, 9.23634e-04, 8.44479e-04],
[9.29688e-01, 7.02858e-04, 7.60078e-04, 1.19591e-03],
[9.47266e-01, 5.88894e-04, 8.36849e-04, 9.37462e-04],
[8.27637e-01, 1.92642e-03, 1.73283e-03, 2.53105e-03],
[9.22363e-01, 2.23160e-03, 1.37615e-03, 2.46811e-03],
[9.31641e-01, 1.92928e-03, 1.49632e-03, 2.53296e-03],
[8.25684e-01, 1.89209e-03, 1.70994e-03, 2.39944e-03],
[9.21875e-01, 1.90926e-03, 1.28174e-03, 2.44904e-03],
[9.25781e-01, 1.65272e-03, 1.45912e-03, 2.44141e-03],
[8.39844e-01, 3.17955e-03, 4.02832e-03, 5.22614e-03],
[9.17480e-01, 3.13759e-03, 3.37982e-03, 4.72260e-03],
[9.37012e-01, 2.63405e-03, 3.57056e-03, 4.70734e-03]], device='cuda:0', dtype=torch.float16)
I like to get its max value and index for each row in Torch is
conf, j = x[:, 5:].max(1, keepdim=True)
How can I implement in numpy if I have 2D numpy array?
You are looking for numpy.argmax
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments