Coder
Coder

Reputation: 17

How do I implement the np.argmin function for several dimensions

I'm looking for help implementing logic without a loop for the following code. With the present / below code -4D array, I am facing issue since argmin takes just one axis, whereas I need to consider several axes.

array= np.array([270,480,9,9]) # 4 D shape
locs = np.argmin(array, axis=[2,3])

Error message:

TypeError: 'list' object cannot be interpreted as an integer

and I do

i_y, i_x = np.unravel_index(locs , arry.shape[:2])

Upvotes: 0

Views: 33

Answers (0)

Related Questions