Machine learning: Lab: invariance of DNNs

Are DNNs spatially invariant? #

Good image classifiers should have spatial invariance properties. Mathematically speaking, a classifier \[f:\mathbb{R}^n \rightarrow \{1,2, \ldots k\} \] is spatially invariant if whenever \(\tau: \mathbb{R}^n \rightarrow \mathbb{R}^n\) is a spatial transformation such as a translation or rotation, then \(f(\tau(\vec{x}))=f(\vec{x})\). That is, the classification of a feature vector does not change. We will study whether our dense neural network classifier is spatially invariant. As always, we will use a Colab notebook in our work.

Procedure #

Follow the outline below and the hints in the Colab notebook as your proceed.

  1. Start by downloading the MNIST data set and spend a minute or two reacquainting yourself with the images and the original labels.
  2. Build and train a classifier for all ten digits. You will have to choose a variety of hyperparameters, but a classifier with validation accuracy of at least 97% is reasonably within reach.
  3. Apply a variety of spatial transformations to the images in the testing data. How does the accuracy of your model change?
  4. Do you expect that dense neural networks used for image recognition are spatially-invariant?