获取 CIFAR 示例(或类似)的输出概率 [英] Getting Probabilities of Outputs for CIFAR Example (or similar)

查看:24
本文介绍了获取 CIFAR 示例(或类似)的输出概率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我想弄清楚如何获得 CIFAR 示例中每个类的概率.目前我可以在输入张量中输入预测的类并返回一个真或假,但它不会告诉我它认为它是哪个类(10 个)以及它在该事实上的概率.知道如何在 sess.run() 之后获取此信息吗?

Hey I'm trying to figure out how to get the probabilities for each of the classes in the CIFAR example. Currently I can input the predicted class in the input tensor and get back a true or false, but it won't tell me the class it thinks it is (out of 10) and the probability it places on that fact. Any ideas how to get this information after sess.run()?

推荐答案

用于评估的 CIFAR-10 示例代码(在 cifar10_eval.py) 产生(作为中间输出)a-logits给定的图像在每个类中.将此张量传递给 sess.run() 将为您提供必要的信息,告诉您图像的预测类别是什么.相反,如果您计算 tf.nn.softmax(logits) 并将其传递给 sess.run(),您将获得每个概率(范围从 0 到 1)班级.

The CIFAR-10 example code for evaluation (in cifar10_eval.py) produces (as an intermediate output) a logits tensor that contains log-probabilities that a given image is in each of the classes. Passing this tensor to sess.run() will give you the necessary information to tell you what the predicted class for an image is. If instead you compute tf.nn.softmax(logits) and pass that to sess.run(), you will get a probability (ranging from 0 to 1) for each class.

这篇关于获取 CIFAR 示例(或类似)的输出概率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆