0

Let's say I have an array which it's dimensions are 10 X 20 X 12 X 12 X 2 X 2. What should I do if I want to get the maximum values indices of the last two axes? meaning I want a function which will output (if the described array is the input) an array of shape: 10 X 20 X 12 X 12. So (array is the described array):

array[indices] == np.amax(array, (-2,-1))

yatu
  • 86,083
  • 12
  • 84
  • 139

1 Answers1

0

A simple solution is to call the function twice, once for each axis:

A = np.arange(1000).reshape((10,10,10))
np.amax(np.amax(A, axis=-1), axis=-1)

For np.argmax you can basically do the same. But of course the indices are changing. You need to correct for this.

Feodoran
  • 1,752
  • 1
  • 14
  • 31