Numpy amin and amax alternative or algorithm?

Question:

I have to move an API from my server to AWS Lambda. Lambda has a size limit, i.e., 250 MB. I used numpy’s amin and amax methods in my code, rest of numpy is useless for me. Is there any other alternative to numpy in my case or can anyone tell me the algorithm for amin and amax without getting the time complexity of O(m+n)? Thank you

Asked By: heisenbaig

||

Answers:

Do the Python built-in functions max and min not work for you?

>>> max([1, 2, 3])
3
>>> min([1, 2, 3])
1

For a 2D list you can use a comprehension:

>>> l = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
>>> [max(r) for r in l] # max by rows, or axis = 1
[3, 6, 9]
>>> [max(r) for r in zip(*l)] # max by cols, or axis = 0
[7, 8, 9]
Answered By: orlp

I know I’m like 3 years late, but, tf.experimental.numpy.amin and amax

Answered By: Aiden Yun
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.