One Shot learning, Siamese networks and Triplet Loss with Keras


Input an image, the output is the score for each class

The One Shot Learning concept and Siamese Networks


The 3x3 pixels images can be encoded with only 2 number embeddings. With only 2 numbers, you can visualize them on a unit circle

Project Architecture for triple loss

Training with a binary classifier approach. We won’t do that
Training with the triplet approach

Preparing data for training

Triplet Batch

An example of chosen triplet. A hard one

Building our Keras model

The Neural Network

Loss function

Training Model

Evaluation and metrics

Evaluation before training our model. It’s bad

Interclass distance

Training process

Evaluation after training our model. It’s way better


References and thanks

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