【问题标题】:How To Get the Confusion Matrix when Using Tflearn使用 Tflearn 时如何获取混淆矩阵
【发布时间】:2017-12-19 06:31:05
【问题描述】:

我想得到混淆矩阵 但为此,我需要一组谓词和标签。 例如,我如何从 tflearn 获取这些数据(Pannous speech_data)https://github.com/llSourcell/tensorflow_speech_recognition_demo/blob/master/demo.py

谢谢!

    model.fit(trainX, trainY, n_epoch=10, validation_set=(testX, testY), show_metric=True,batch_size=batch_size)
_y=model.predict(X)
predictions.append(_y)
labels.append(trainY)
bp()
confusionMat=tf.confusion_matrix(labels,predictions,num_classes=classes,dtype=tf.int32,name=None,weights=None)
print(np.matrix(confusionMat))

【问题讨论】:

    标签: tensorflow tflearn


    【解决方案1】:
    _y=model.predict(X)  # predictions
    y = train_Y # i think this is actual labels data
    
    tf.confusion_matrix(
    labels,               # put y here
    predictions,          #put _y here
    num_classes=None,
    dtype=tf.int32,
    name=None,
    weights=None
    )
    

    【讨论】:

    • 感谢您的及时答复。简单且有意义:) 。所以实际上需要在每次迭代时将_y和train_Y添加到预测和标签中,然后在最后计算混淆矩阵?
    • 试过了,但标签和预测应该是类数组。然而,对于 tflearn,每个项目都是一个具有该类概率的数组。我应该如何将其用作标签/预测?
    • 请尝试调试和理解代码。您的混淆矩阵需要两个数组。您拥有的一个标签和另一个标签是预测类。所以改为返回概率分数尝试返回预测类。预测类是概率分数被分类的地方。!!
    猜你喜欢
    • 2018-06-03
    • 2021-04-12
    • 1970-01-01
    • 1970-01-01
    • 2021-12-03
    • 2018-01-01
    • 2018-03-08
    • 2018-10-02
    • 2016-05-07
    相关资源
    最近更新 更多