TensorFlow:在二进制分类

时间:2017-01-12 10:51:18

标签: tensorflow classification floating-accuracy softmax

我正在使用softmax函数进行二进制分类任务。 我的测试标签是一个热门列表,看起来像:     test_y = [[1。 0.] [1。 0] ...]

预测标签是概率列表:

test_y_pred = [[  4.39091297e-09   1.00000000e+00]
        [  1.75207238e-10   1.00000000e+00] …]

当我尝试使用f1_score时,出现错误:

ValueError:无法处理二进制和连续的混合

我该如何处理这个问题?

由于

1 个答案:

答案 0 :(得分:0)

f1_score不会为您分类结果。

将预测更改为类的向量,例如:

import numpy as np
test_y = [np.argmax(prediction) for prediction in test_y]
test_y_pred= [np.argmax(prediction) for prediction in test_y_pred]