--- title: Autoencoder clustering/default behavior --- [Main page](https://hackmd.io/@hpcfung/Main_Page) **Abstract:** an autoencoder consists of an encoder and a decoder. During training, the encoder maps an input (in this case, an image from MNIST) to latent space, then the decoder maps it back into an image. During training, the goal of an auto encoder is for the reconstructed image to resemble the original image as closely as possible. Github code: https://github.com/hpcfung/CodingProjects/tree/main/Auto_Clustering In the following, I used an autoencoder implemented in pytorch. ![](https://i.imgur.com/JOaFYxX.png) (Original image and reconstructed image, side-by-side) In a variational autoencoder, there is a lot of structure in the latent space, because the regularizer there essentially enforces the manifold hypothesis (see 5.11.3 of Goodfellow, Bengio, and Courville's book, Deep Learning). To see this visually, see the first picture in https://www.tensorflow.org/tutorials/generative/cvae. I wondered if the latent space of a "regular" autoencoder is also structured, so I used an autoencoder where the latent space is 3-dimensional. Then, for each digit, I plotted its latent representation as a 3D vector, using plotly: <iframe src="https://hpcfung.github.io/wavelength300regularizer0drift0time1637444010offset0.html" width="700" height="700" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe> (default behavior, without any regularizer) Each color represents a different type of digit (0,2,4,6,8; see the legend on the top right). Indeed, we see that an autoencoder also performs some sort of clustering in the latent space. Perhaps this can be coupled with a nearest neighbor algorithm to perform classification. Note that the training is done using unlabelled data, so this is a form of unsupervised learning. I also tried to implement [different regularizers](https://hackmd.io/@hpcfung/autoencoder_clustering) to exaggerate the clustering, but without much success. (Note: those are less well-documented...)