I have a binary classification network with a softmax layer at the end:
predictions = Dense(2, activation='softmax')(x)
When I do model.predict() I get results as below. How do I interpret this array? If 0.00673855 is the probability for class 0 and 0.0016871 is the probability for class 1. Shouldn't they add up to 1.0 ?
[[ 0.00673855 0.0016871 ]]
Hi,
Your network is not correct, you should only have one output neuron, i.e., Dense(1, ...). Then with model.predict() you'll have a value between 0 and 1, which can be interpreted as the probability to belong to class 1.
On another note, I think this kind of question (not related to an issue) is more for the google group: https://groups.google.com/forum/#!forum/keras-users
@Fuerril Thanks for the help. It doesn't matter that the output is 2 because I am using categorical_crossentropy instead of binary_crossentropy. I forgot to mention it.
So I managed to figure out the issue: instead of using softmax I was using sigmoid. Again my mistake. Many hours on the screen...
I have only one output neuron,but I don't know how to get the label from the result ,my label is 'normal' and 'abnormal'
Most helpful comment
@Fuerril Thanks for the help. It doesn't matter that the output is 2 because I am using
categorical_crossentropyinstead ofbinary_crossentropy. I forgot to mention it.So I managed to figure out the issue: instead of using
softmaxI was usingsigmoid. Again my mistake. Many hours on the screen...