This repository contains Siamese Network for MNIST DATASET.
In Siamese Networks, we take an input image of a person and find out the encodings of that image, then we take the same network without performing any updates on weights and biases and feed this network an input image of a different person and again predict it's encodings. Now we compare these two encodings to check whether there is a similarity between the two images. These two encodings act as a latent feature representation of the images. Images with the same person have similar features/encodings. Using this, we compare and tell if the two images have the same person or not.
This network is tested on simplest MNIST DATASET, a large database of handwritten digits that is commonly used for training various image processing systems. It contains 60,000 training images and 10,000 testing images.
The dataset is available in both Tensorflow and PyTorch. Tensorflow loads the dataset in Numpy arrays whereas PyTorch APIs loads the same dataset in Torch Tensors.
3-layer fully connected neural network with shared weights.
The repository contains both PYTORCH and TENSORFLOW models .
- Python 3.6
- Tensorflow 1.10.0 / PyTorch 0.2.1
Tensorflow Output:
Training Data:
Epoch: 48500 Loss: 0.075
Epoch: 49000 Loss: 0.095
Epoch: 49500 Loss: 0.053
PyTorch Output:
Training Data:
Epoch: 48500 Loss: 0.054
Epoch: 49000 Loss: 0.068
Epoch: 49500 Loss: 0.051
For Visualization, I used the code of the following repo: https://github.com/ywpkwon/siamese_tf_mnist/blob/master/visualize.py