In this tutorial, we will do the following things in the order listed here:
- Data preprocessing: Creating pairs
- Creating a Siamese network architecture
- Training it using the small MNIST dataset
- Visualizing the embeddings
Perform the following steps to carry out the exercise:
- First, import all the libraries needed using the following code:
# -*- encoding: utf-8 -*-import argparseimport torchimport torchvision.datasets as dsetsimport randomimport numpy as npimport timeimport matplotlib.pyplot as pltfrom torch.autograd import Variablefrom torchvision import transformsimport pickleimport torchimport torch.nn as nn
As we learned in the theoretical Understanding Siamese networks section, as part of data preprocessing, ...