I have a 3d numpy array of shape (150, 9, 5)
and I would like to get the argmax of the 3rd dimension (out of the elements) but I cannot get it done.
For example, let's say the array looks like (this example does not follow the shape I am using in my code):
[[[615, 142, 18]],
[[12, 412, 98]],
[[5, 11, 162]],
[[19, 76, 7]],
[[56, 78, 12]],
[[119, 41, 55]],
[[26, 7, 15]],
[[19, 67, 53]]]
I would like to get back an array of shape (150, 9, 1) (again this is in my case, not related to the example). For the example it would be:
[[[0]],
[[1]],
[[2]],
[[1]],
[[1]],
[[0]],
[[0]],
[[1]]]
When I try np.argmax()
with both axis 0 and 1
, I get wrong results.
Is there a way to work it out directly or should I go through each (9,5) using a for loop ?