Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I am a beginner in Deep Learning and while performing a practical assignment, came across the Keras documentation on
keras.backend
.
I went through the explanation a number of times. however, i cannot exactly understand the difference between max and argmax function.
I will explain this using
max
and
argmax
from the
numpy
package, but the two functions are identical to the ones in the Keras backend:
import numpy as np
vector = np.array([1, 2, 3, 2, 1])
Now, np.max(vector) returns the number 3, as this is the maximal value in the vector. np.argmax(vector) however returns 2, as this is the index of the maximal value in the vector.
The argmax function is often used to post-process the output of a softmax layer. Say the output layer of your classifier (which classifies some image into one of four classes) is
output = Dense(4, activation='softmax')(...)
and the output of predict(some_random_image) is [0.02, 0.90, 0.06, 0.02]. Then, argmax([0.02, 0.90, 0.06, 0.02]) immediately gives you the class (1).
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.