Keras示例:mnist_siamese_graph - 准确性似乎不正确

时间:2017-06-23 19:42:37

标签: python machine-learning keras

keras / examples / mnist_siamese_graph.py中使用的keras示例看起来不正确。 下面的函数不是真正的准确度(准确度=(正确预测的类/总测试类))

def compute_accuracy(predictions, labels):
    '''Compute classification accuracy with a fixed threshold on distances.
    '''
    return labels[predictions.ravel() < 0.5].mean()

除此之外,我们遇到this问题,这让我觉得contrastive_loss和get_pairs函数也是错误的。有人可以解释这个准确度指标和那些功能吗?

1 个答案:

答案 0 :(得分:0)

compute_accuracy function is wrong。它目前正在计算精度。它应该是:

def compute_precision(predictions, labels):
    '''Compute classification precision with a fixed threshold on distances.
    '''
    return labels[predictions.ravel() < 0.5].mean()


def compute_accuracy(predictions, labels):
    '''Compute classification accuracy with a fixed threshold on distances.
    '''
    return np.mean(np.equal(predictions.ravel() < 0.5, labels))

我还不确定this issue,但修复准确度函数似乎工作正常。