2017-06-23 6 views
0

keras/examples/mnist_siamese_graph.pyで使用されているケラスの例が正しく表示されません。 以下の機能が、そのほかに、実際の精度(精度=(正確に予測クラス/総テストクラス))Kerasの例:mnist_siamese_graph - 精度が正しくないようです

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

ではありません、私たちは私がcontrastive_lossとget_pairs機能があまりにも間違っていると思いますthis問題を、持っています。誰かがこの精度メトリックとそれらの関数について説明することはできますか?

+0

この「計算精度」関数が精度を計算していることが分かりました。正しいものは "np.mean(np.equal(predictions.ravel()<0.5、labels))"です。 – ricardorlopes

答えて

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わからないんだけど、精度の機能を固定すると、正常に動作しているようです。

関連する問題