我试图从tensorflow提供的CIFAR-10示例的修改版本绘制ROC曲线.它现在是2班而不是10班.
网络的输出称为logits并采用以下形式:
[[-2.57313061 2.57966399] [0.04221377 -0.04033273] [-1.42880082 1.43337202] [-2.7692945 2.78173304] [-2.48195744 2.49331546] [2.0941515 -2.10268974] [-3.51670194 3.53267646] [-2.74760485 2.75617766] ...]
首先,这些logits实际代表什么?网络中的最后一层是WX + b形式的"softmax linear".
该模型能够通过调用计算准确性
top_k_op = tf.nn.in_top_k(logits, labels, 1)
Run Code Online (Sandbox Code Playgroud)
然后,一旦图形被初始化:
predictions = sess.run([top_k_op])
predictions_int = np.array(predictions).astype(int)
true_count += np.sum(predictions)
...
precision = true_count / total_sample_count
Run Code Online (Sandbox Code Playgroud)
这很好用.
但是现在如何从中绘制ROC曲线?
我一直在尝试"sklearn.metrics.roc_curve()"函数(http://scikit-learn.org/stable/modules/generated/sklearn.metrics.roc_curve.html#sklearn.metrics.roc_curve)但我不喜欢不知道该用什么作为我的"y_score"参数.
任何帮助,将不胜感激!