Siamese Neural Network
Siamese Neural Network (Deep Metric Learning) · Also known as: twin network, Siamese neural network, contrastive metric network, Siyam ağı
A Siamese network is a deep architecture with two (or more) identical, weight-sharing branches that map inputs into an embedding space where similar inputs land close together and dissimilar ones far apart. Introduced by Bromley, LeCun, and colleagues in 1993 for signature verification and revived by Koch et al. (2015) for one-shot image recognition, it learns a similarity metric rather than fixed class labels, making it ideal for verification, matching, and few-shot tasks.
Read the full method
Sign in with a free account to read this section.
Method map
The neighbourhood of related methods — select a node to explore.
When to use it
Use a Siamese network for similarity, verification, and matching tasks, and where classes are numerous, open-ended, or have very few examples — signature/face verification, person re-identification, signature and image matching, duplicate/near-duplicate detection, sentence-similarity, and one-/few-shot recognition. Its strengths are learning a reusable similarity metric and handling unseen classes without retraining. The costs: it trains on pairs/triplets, so performance depends heavily on pair/triplet sampling (hard-negative mining is often needed), it can be harder to train than a plain classifier, and the learned metric is only as good as the training pairs' coverage. When the class set is fixed and examples are plentiful, a standard classifier is simpler; modern self-supervised contrastive methods extend the same twin-encoder idea at scale.
Strengths & limitations
- Learns a reusable similarity metric, not a fixed label set.
- Handles open-ended/new classes and one-/few-shot recognition without retraining.
- Weight sharing yields comparable, meaningful embeddings.
- Versatile across modalities (images, signatures, text, audio).
- Trains on pairs/triplets; performance hinges on pair/triplet sampling.
- Often needs hard-negative mining and is trickier to train than a classifier.
- The metric only generalizes as far as the training pairs' coverage.
- Pairwise training can be computationally heavier per effective example.
Frequently asked
Why must the two branches share weights?
Weight sharing ensures both inputs are mapped by exactly the same function into the same embedding space, so the distance between their embeddings is meaningful and symmetric. Without shared weights the two branches could embed similar inputs incomparably, making the learned distance unreliable.
What is the difference between contrastive and triplet loss?
Contrastive loss works on pairs: pull similar pairs together, push dissimilar pairs apart beyond a margin. Triplet loss works on an (anchor, positive, negative) triple: make the anchor-positive distance smaller than the anchor-negative distance by a margin. Triplet loss directly optimizes relative ranking and is common in modern metric learning.
How does a Siamese network do one-shot recognition?
It learns a general similarity metric during training. At test time it embeds the query and each candidate reference (one example per class) and assigns the query to the nearest reference embedding. Because it compares similarities rather than predicting fixed labels, a single reference per new class suffices — no retraining.
Sources
- Bromley, J., Guyon, I., LeCun, Y., Säckinger, E., & Shah, R. (1993). Signature verification using a 'Siamese' time delay neural network. Advances in Neural Information Processing Systems, 6. link ↗
- Koch, G., Zemel, R., & Salakhutdinov, R. (2015). Siamese neural networks for one-shot image recognition. ICML Deep Learning Workshop. link ↗
How to cite this page
ScholarGate. (2026, June 2). Siamese Neural Network (Deep Metric Learning). ScholarGate. https://scholargate.app/en/deep-learning/siamese-network
Which method?
Set this method beside its closest kin and read them side by side — the library lays the books on the table; the choice is yours.
- AutoencoderDeep learning↔ compare