My CNN outputs an array of values that I have to check for the biggest one and take it as the predicted class. Example:
-148.7290802 , -133.90687561, -90.850914 , -135.78356934,
-128.6325531 , -125.76812744, -85.41909027, -72.3269577 ,
-103.51300812
For class index 6.
Now, how can I get the confidence of that result?
My setup is:
predict_op = [tf.argmax(py_x,1), py_x]
cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(py_x, Y))
train_op = tf.train.RMSPropOptimizer(learningRate, decayRate).minimize(cost)
Updated code now returning: [[ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 1. 0.]]
predict_op = tf.nn.softmax(py_x)
cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(py_x, Y))
train_op = tf.train.RMSPropOptimizer(learningRate, decayRate).minimize(cost)
Apply softmax in the last stage; this will yield posterior probabilities at the final stage. You're already using softmax in the set-up; just use it on the final vector to convert it to RMS probabilities. The confidence of that prediction is simply the probability of the top item.
For a quick illustration, see the Wikipedia page under Generalization and Statistics. This section also describes the confidence of the model overall.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With