Problems about Siamese network

recently i try to write a basic siamese network, i have finished the ‘training’ part and it works.but now i have a problem ,that is ,how can i get the accuracy.because i can’t get a label from the siamese network, i use contrastive loss and the model output just two vectors and i can only calculate their distance,rather than label.
if there exists a threshold of distance can classify the sample pair 1 or 0, then how can i learn the threshold …or there exist some methods to get labels?

anybody can help me? ^-^ thanks a lot !!

You can plot a ROC curve using sklearn library. This plot shows optimal threshold value.

Have a look at this post

Thank you! so you idea is viewing the threshold of distance as hyperparamters and through plotting the ROC curve to find a best threshold? i read the original siamese paper , it doesn’t mention the method of getting label , so is it the most popular method in siamese network?

Well, I don’t know if it’s the most popular method for siamese. It’s just a very traditional way of measuring performance. Basically that curve shows performance when you vary your threshold, then pick optimal point.
You can use other plots like precision-recall.

ok , thanks you a lot !:heart: i’ll give it a try.