0
$\begingroup$

When I do a prediction with my DNN clasifier I get a dictionary like this.

{'probabilities': array([9.9912649e-01, 8.7345875e-04, 8.5633601e-12], dtype=float32), 'logits': array([ 12.641698,   5.599522, -12.840958], dtype=float32), 'classes': array(['0'], dtype=object), 'class_ids': array([0])}

Can someone explain me the values of probability and logits? Why the three values ?

The docs just states

Evaluated values of predictions tensors.

And do not refer (the docs) to a struct/explanation of the output

Thanks!

$\endgroup$
  • $\begingroup$ This is a softmax prediction. The classifier assigns the sample with probabilities for being in each class, rather than strictly stating this sample belongs to a particular class. If you take the argmax of each prediction, you can get the most probable class that your classifier predicted, for each sample. $\endgroup$ – Ugur MULUK Jan 3 '19 at 14:10
  • 1
    $\begingroup$ @UgurMULUK The "softmax predition" you stated just opened me new horizons. Thanks for the comment ! $\endgroup$ – ItsYou Jan 3 '19 at 19:42
0
$\begingroup$

At the probabilities key you will find the probabilities of every label. Tensorflow just chooses the one with the highest. So in order to get the probability of the current outcome, you need to do something like this.

results = classifier.predict(input_fn = lambda: mem_input_fn())

for r in results:
    idx = r["classes"][0] # idx is the predicted label
    print idx, r["probabilities"][int(idx)]
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.