Machine Learning

Siamese Network

A Siamese network is a neural network that runs two inputs through identical twin branches and compares the results, learning to judge whether the inputs match rather than what class they belong to.

What is a Siamese network?

A Siamese network is a neural network architecture with two identical branches that share the same weights. Each branch converts one input into an embedding, a compact numeric representation, and the network is trained so that embeddings of matching inputs end up close together and embeddings of non-matching inputs end up far apart. The output is a similarity score rather than a class label.

This matters when the categories are not fixed. A classifier for staff faces would need retraining every time someone joined. A Siamese network instead learns what “same person” looks like in general, so a new face can be verified against a single stored photo. Training uses pairs labeled as same or different, or triplets of an anchor, a positive, and a negative, with a contrastive or triplet loss.

Siamese networks in practice

A regional bank verifies signatures on paper checks. A Siamese network compares the signature on each incoming check with the reference on file and returns a similarity score, and low scores go to a fraud analyst. An online retailer uses the same architecture to catch duplicate product listings, comparing a new seller’s photos against the catalog. Because the network needs only one example per identity, it is the standard tool for one-shot and few-shot recognition, and the embeddings it produces can be indexed in a vector database for visual search.

← Back to AI Glossary