Manifold Learning, Autoencoders, and Generative Models
In many problems, data represented in a high-dimensional space (e.g., thousands of pixels in an image) does not fill that space. It lies on or near a lower-dimensional, non-linear structure called a manifold. Manifold learning discovers and models this low-dimensional structure. We explore data manifolds and introduce two classes of models—autoencoders and generative models—that learn and exploit them.
The Manifold Hypothesis
The manifold hypothesis says that many datasets, from images of faces to audio signals, are concentrated near a low-dimensional manifold. Consider a set of images of a person's face. While each image is a point in a high-dimensional pixel space, the variations between the images can be described by fewer factors, such as the angle of the head, the lighting conditions, and the facial expression. These are the intrinsic coordinates of the "face manifold."
This helps with:
- Dimensionality Reduction: By finding a low-dimensional representation (or embedding) of the data, we can simplify subsequent learning tasks.
- Data Generation: If we learn a model of the manifold, we can sample new points from it, generating new data samples (e.g., images of faces that have never existed).
- Anomaly Detection: Points that lie far from the learned manifold can be identified as anomalies.
Autoencoders: Learning a Compressed Representation
An autoencoder is a neural network that learns a compressed, low-dimensional representation of data. It consists of two components:
- The Encoder (\(g_e\)): This part of the network takes a high-dimensional input \(\mathbf{x}\) and maps it to a low-dimensional latent vector \(\mathbf{h}\). This latent vector is the compressed representation or embedding of the input.
- The Decoder (\(g_d\)): This part of the network takes the latent vector \(\mathbf{h}\) and attempts to reconstruct the original high-dimensional input \(\mathbf{x}\).
- The Generator (\(G\)): Takes a random noise vector \(\mathbf{z}\) as input and generates a data sample \(G(\mathbf{z})\) (e.g., an image). It tries to produce outputs that are indistinguishable from real data.
- The Discriminator (\(D\)): A binary classifier. It takes a sample (either real from the training set or fake from the generator) and determines whether it is real or fake.
The network is trained by minimizing the reconstruction error—the difference between the original input \(\mathbf{x}\) and the reconstructed output \(\hat{\mathbf{x}}\) (e.g., using mean squared error). The network has a "bottleneck" layer in the middle, where the dimensionality is lower than the input and output layers. This bottleneck forces the network to learn a compressed representation in the latent space \(\mathbf{h}\), as it must retain enough information to reconstruct the original input.
A linear autoencoder resembles Principal Component Analysis (PCA), a method for linear dimensionality reduction. By using non-linear activation functions in the encoder and decoder, neural network autoencoders can learn non-linear manifolds.
Generative Models
A standard autoencoder learns to compress and decompress data, but not to generate new data from scratch. The latent space it learns may not be structured to make sampling easy. Generative models are designed to generate data. They learn the probability distribution of the data, \(P(\mathbf{x})\), so they can generate new samples from that distribution. Two types of deep generative models are Variational Autoencoders (VAEs) and Generative Adversarial Networks (GANs).
Variational Autoencoders (VAEs)
A VAE is a probabilistic version of the autoencoder. Instead of mapping an input to a single point in the latent space, the VAE encoder maps it to the parameters (mean and variance) of a probability distribution. A point \(\mathbf{h}\) is sampled from this distribution and fed to the decoder to reconstruct the input.
This approach encourages the latent space to be smooth and continuous. It forces the distributions learned for different inputs to overlap, so points that are close in the latent space decode to similar outputs. After training, we can generate new data by sampling a random point \(\mathbf{h}\) from a standard Gaussian distribution and passing it through the decoder.
Generative Adversarial Networks (GANs)
GANs use a two-player game between two networks that compete:
The training process is a game. The discriminator learns to tell real and fake samples apart. The generator learns to fool the discriminator. This competition drives both networks to improve. Over time, the generator learns to produce more realistic samples, and at equilibrium, the generated data distribution should be close to the real data distribution. GANs can produce images, though training can be unstable.
Conclusion
Manifold learning explains the structure of high-dimensional data. Autoencoders learn low-dimensional representations of this structure for tasks like dimensionality reduction and anomaly detection. Generative models like VAEs and GANs learn to represent the data manifold and generate new data points that lie on it. These models have changed fields like computer vision, creating images and designs by learning the structure of the world from data.