Machine learningDeep learningMetric learningAlgorithm

Siamese Neural Network

Also known as: twin network, Siamese neural network, contrastive metric network, Siyam ağı

OriginatorJane Bromley & Yann LeCun et al.; popularized by Koch et al.Year1993Sources2Related methods4

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.

Key highlights

  • 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).

Intuition

This section is available to Pro members. Upgrade to Pro

How it works

This section is available to Pro members. Upgrade to Pro

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

Strengths
  • 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).
Limitations
  • 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.

Common pitfalls

This section is available to Pro members. Upgrade to Pro

Applications

This section is available to Pro members. Upgrade to Pro

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

  1. 1.
    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.
  2. 2.
    Koch, G., Zemel, R., & Salakhutdinov, R. (2015). Siamese neural networks for one-shot image recognition. ICML Deep Learning Workshop.

You have read it. What now?

Cite this page

ScholarGate. (2026, June 2). Siamese Network. ScholarGate. https://scholargate.app/deep-learning/siamese-network