Now that we have a basic understanding of siamese networks, we will explore them in detail. The architecture of a siamese network is shown in the following figure:

As you can see in the preceding figure, a siamese network consists of two identical networks, both sharing the same weights and architecture. Let's say we have two inputs, and
. We feed Input
to Network
, that is,
, and we feed Input
to Network
, that is,
.
As you can see, both of these networks have the same weights, , and they will generate embeddings for our input,
and
. Then, we feed these embeddings to the energy function,
, which will give us similarity between the two inputs. It can be expressed as follows:

Let's say we use Euclidean distance as our energy function; then the value of will be low if
and
are similar. The value of
will be large if the input values...