卷积神经网络预测一个class的概率

Convolution neural network predicts the probability of a class

为了这个example,我试着打印出来"tf.argmax(pred, 1)",结果是[1 3 4 1 2]。

如何知道预测类别的概率? Tensorflow 是否提供 API?

你能做的就是得到预测的argmax,得到这个索引处的预测。 这在 numpy 中更容易(例如,使用 amax 函数:https://docs.scipy.org/doc/numpy/reference/generated/numpy.amax.html

tfpredicted,loss, acc = sess.run([pred,cost, accuracy], feed_dict={x: batch_x,y: batch_y,keep_prob: 1.})
print(np.amax(tfpredicted))

我没有测试代码,但希望它能工作。否则,您可能需要查看 numpy 提供的最大功能。

祝你好运!