Siamese Network Keras for Image and Text similarity.

1. Introduction

2. Theory

Siamese neural network is an artificial neural network that use the same weights while working in tandem on two different input vectors to compute comparable output vectors. 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 or more technical as a distance function for Locality-sensitive hashing.

A basic Siamese network — Source

3. Basic Working

A simple Siamese network-source

4. Siamese network for image similarity

Siamese network for image similarity

5. Siamese network for text similarity

Siamese text similarity

6. Siamese in conjunction with triplet loss

Triplet loss is a loss function for artificial neural networks where a baseline (anchor) input is compared to a positive (truthy) input and a negative (falsy) input. The distance from the baseline (anchor) input to the positive (truthy) input is minimized, and the distance from the baseline (anchor) input to the negative (falsy) input is maximized.

It is often used for learning similarity of for the purpose of learning embeddings, like word embeddings and even thought vectors, and metric learning.

Triplet loss learning
Triplet data generation
Triplet loss codesource
Siamese network with triplet loss
model training

7. Scope

8. References



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store