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函数也是错误的。有人可以解释这个准确度指标和那些功能吗?
答案 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,但修复准确度函数似乎工作正常。