I have such an array:
arr = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]).reshape(2,2,4)
array([[[ 1, 2, 3, 4],
[ 5, 6, 7, 8]],
[[ 9, 10, 11, 12],
[13, 14, 15, 16]]])
And I want to get to get the max for each of these sub-arrays:
arr[:,:,-1]
array([[ 4, 8],
[12, 16]])
So I would want each of these sub-arrays converted to their max value. As result:
array([8, 16)]
How would I be able to do that without iterating?