I'm interested in modeling a Siamese network for facial verification. I've already written a simple working model that inputs feature vectors generated from two CNNs with shared weights then outputs a similarity score (euclidean distance.)
Here is a similar model found within the Keras documentation (this Siamese network joins two networks comprised of fully connected layers) The model also uses a euclidean distance metric.
The threshold used in that example when computing the accuracy of the model is 0.5. The similarity scores generated by the model run from that training script roughly ranges from 0 to 1.68. My model outputs scores ranging from 0 to 1.96.
I would suppose that the choice of threshold when working with a similarity metric could be determined by finding the threshold value that maximizes an appropriate metric (e.g. F1 score) on a test set.
Now when it comes to parameter tuning using a validation set - done so to choose the appropriate optimization and regularization parameters and model architecture to generate scores in the first place, how do I determine what value to set as the threshold? This threshold would be important to calculating the performance metric of each model generated during the parameter search - needed to determine what final model architecture and parameter set to use when training. Also, would the method for choosing the threshold change should I choose a different distance metric (e.g. cosine similarity)?
I've already done a parameter search using an arbitrarily-set threshold of 0.5. I'm unsure if this would reflect best practices or if it ought to be adjusted when using a different distance metric.
Thank you for any help offered. Please let me know if any more details on my part are necessary to facilitate a better discussion in this thread.