How to capture index of highest valued array from predict function?
You just need to use np.argmax(pred[0]). Since your pred have the shape [[]] rather than [], your element is the list of itself. So in order to get the max pred you need to use np.argmax(l[0]).
[[0.12673968 0.15562803 0.03175346 0.6858788 ]]
This is how my predict function is giving its output, I want to fetch the index of the highest value.
Tried this:
pred= pred.tolist() print(max(pred)) index_l=pred.index(max(pred)) print(index_l)
But it seems to output only 0.
Printing max(pred) is giving the output:
[0.12673968076705933, 0.1556280255317688, 0.031753458082675934, 0.6858788132667542]
The network uses sequential with hidden layers (embedding, BiLSTM, BiLSTM, Dense, Dense)