Siamese Neural Network

Anon842 pts0 comments

Siamese neural network - Wikipedia

Jump to content

Search

Search

Donate

Create account

Log in

Personal tools

Donate

Create account

Log in

Siamese neural network

6 languages

Català<br>فارسی<br>Français<br>Հայերեն<br>한국어<br>Русский

Edit links

From Wikipedia, the free encyclopedia

Neural network working on two input vectors

A Siamese neural network (sometimes called a twin neural network ) is an artificial neural network that uses the same weights while working in tandem on two different input vectors to compute comparable output vectors.[1][2][3] Often one of the output vectors is precomputed, thus forming a baseline against which the other output vector is compared. This is similar to comparing fingerprints but can be described more technically as a distance function for locality-sensitive hashing.[citation needed]

It is possible to build an architecture that is functionally similar to a twin network but implements a slightly different function. This is typically used for comparing similar instances in different type sets.[citation needed]

Uses of similarity measures where a twin network might be used are such things as recognizing handwritten checks, automatic detection of faces in camera images, and matching text queries with indexed documents[4]. The perhaps most well-known application of twin networks are face recognition, where known images of people are precomputed and compared to an image from a turnstile or similar. It is not obvious at first, but there are two slightly different problems. One is recognizing a person among a large number of other persons, that is the facial recognition problem. DeepFace is an example of such a system.[3] In its most extreme form this is recognizing a single person at a train station or airport. The other is face verification, that is for example, to verify whether a photo in a passport matches the face of the passport's owner. The twin network might be the same, but the implementation can be quite different.

Learning<br>[edit]

Learning in twin networks can be done with triplet loss or contrastive loss. For learning by triplet loss a baseline vector (anchor image) is compared against a positive vector (truthy image) and a negative vector (falsy image). The negative vector will force learning in the network, while the positive vector will act like a regularizer. For learning by contrastive loss there must be a weight decay to regularize the weights, or some similar operation like a normalization.

A distance metric for a loss function may have the following properties[5]

Non-negativity:

{\displaystyle \delta (x,y)\geq 0}

Identity of Non-discernibles:

{\displaystyle \delta (x,y)=0\iff x=y}

Commutativity:

{\displaystyle \delta (x,y)=\delta (y,x)}

Triangle inequality:

{\displaystyle \delta (x,z)\leq \delta (x,y)+\delta (y,z)}

In particular, the triplet loss algorithm is often defined with squared Euclidean (which unlike Euclidean, does not have triangle inequality) distance at its core.

Predefined metrics, Euclidean distance metric<br>[edit]

The common learning goal is to minimize a distance metric for similar objects and maximize for distinct ones. This gives a loss function like

min

max

{\displaystyle {\begin{aligned}\delta (x^{(i)},x^{(j)})={\begin{cases}\min \ \|\operatorname {f} \left(x^{(i)}\right)-\operatorname {f} \left(x^{(j)}\right)\|\,,i=j\\\max \ \|\operatorname {f} \left(x^{(i)}\right)-\operatorname {f} \left(x^{(j)}\right)\|\,,i\neq j\end{cases}}\end{aligned}}}

{\displaystyle i,j}

are indexes into a set of vectors

{\displaystyle \operatorname {f} (\cdot )}

function implemented by the twin network

The most common distance metric used is Euclidean distance, in case of which the loss function can be rewritten in matrix form as

{\displaystyle \operatorname {\delta } (\mathbf {x} ^{(i)},\mathbf {x} ^{(j)})\approx (\mathbf {x} ^{(i)}-\mathbf {x} ^{(j)})^{T}(\mathbf {x} ^{(i)}-\mathbf {x} ^{(j)})}

Learned metrics, nonlinear distance metric<br>[edit]

A more general case is where the output vector from the twin network is passed through additional network layers implementing non-linear distance metrics.

if

then

is small

otherwise

is large

{\displaystyle {\begin{aligned}{\text{if}}\,i=j\,{\text{then}}&\,\operatorname {\delta } \left[\operatorname {f} \left(x^{(i)}\right),\,\operatorname {f} \left(x^{(j)}\right)\right]\,{\text{is small}}\\{\text{otherwise}}&\,\operatorname {\delta } \left[\operatorname {f} \left(x^{(i)}\right),\,\operatorname {f} \left(x^{(j)}\right)\right]\,{\text{is large}}\end{aligned}}}

{\displaystyle i,j}

are indexes into a set of vectors

{\displaystyle \operatorname {f} (\cdot )}

function implemented by the twin network

{\displaystyle \operatorname {\delta } (\cdot )}

function implemented by the network joining outputs from the twin network

On a matrix form the previous is often approximated as a Mahalanobis distance for a linear space as[6]

{\displaystyle \operatorname {\delta } (\mathbf {x} ^{(i)},\mathbf {x}...

network operatorname displaystyle delta twin distance

Related Articles