I am a beginner in Keras and need help to understand keras.argmax(a, axis=-1) and keras.max(a, axis=-1). What is the meaning of axis=-1 when a.shape = (19, 19, 5, 80)?
I would be appreciated if you can answer what will be the output of keras.argmax(a, axis=-1) and keras.max(a, axis=-1)
Thanks in advance
-- Young
This means that the index that will be returned by argmax will be taken from the last axis.
Your data has some shape
(19,19,5,80)
. This means:Now, negative numbers work exactly like in python lists, in numpy arrays, etc. Negative numbers represent the inverse order:
When you pass the
axis
parameter to theargmax
function, the indices returned will be based on this axis. Your results will lose this specific axes, but keep the others.See what shape
argmax
will return for each index:K.argmax(a,axis= 0 or -4)
returns(19,5,80)
with values from0 to 18
K.argmax(a,axis= 1 or -3)
returns(19,5,80)
with values from0 to 18
K.argmax(a,axis= 2 or -2)
returns(19,19,80)
with values from0 to 4
K.argmax(a,axis= 3 or -1)
returns(19,19,5)
with values from0 to 79