Numpy: argmax over multiple axes without loop
You could do something like this – # Reshape input array to a 2D array with rows being kept as with original array. # Then, get idnices of max values along the columns. max_idx = A.reshape(A.shape[0],-1).argmax(1) # Get unravel indices corresponding to original shape of A maxpos_vect = np.column_stack(np.unravel_index(max_idx, A[0,:,:].shape)) Sample run – In [214]: … Read more