Clustering using pretrained deep models
MNIST clustering using pretrained ResNet 18 and KMeans.
In this task, you are going to cluster MNIST dataset using a pretrained ResNet 18 model and k-means.
Load the MNIST dataset bellow. You can use either torchvision.datasets.MNIST
or sklearn.datasets.fetch_openml()
or any other way to load the dataset. Note that you won't need a validation set.
Instantiate ResNet 18 model (pretrained on imagenet) from torchvision
's model zoo.
Replace the fc
layer of the resnet with an Identity
layer so that we use the hidden features of the last layer.
Use MiniBatchKMeans
to cluster the MNIST dataset in 64 clusters.
Predict cluster for test set samples.
Draw 10 random samples per each cluster from the test set.