71 min total

Generative AI

Variational autoencoder notes

Variational autoencoder notes

Go through video lecture on variational autoencoder and write reflective summary (1 Page, 11 Times New Roman, and without line spacing) in your own words. Clearly explain difference b/w VAE and beta-VAE. Write and describe formulas for various loss functions.

Dimensionality Reduction:

Real-world problems often involve high-dimensional data (images, text, audio) where the underlying data-generating process exists in a much lower-dimensional space. Machine learning techniques aim to compress this high-dimensional data into a smaller, more manageable space. VAEs represent one popular approach for this dimensionality reduction.

A standard autoencoder consists of two main components:

[a] Encoder: A series of neural network layers (fully connected or convolutional) that compress input data into a smaller representation (bottleneck). [b] Decoder: A series of neural network layers that attempt to reconstruct the original input from the compressed bottleneck representation.

Training Process:

The autoencoder is trained by comparing the reconstructed output with the original input using a pixel-to-pixel difference to create a loss function. This allows the network to learn how to effectively compress and decompress the data.

Bottleneck Dimensionality Effects:

The size of the bottleneck (latent space) affects reconstruction quality since with a 2D hidden representation, reconstructions appear fuzzy but recognizable and increasing the dimensionality of the latent representation yields clearer, sharper reconstruction and this illustrates the trade-off between compression and information preservation.

Specialized Autoencoder Variants

Denoising Autoencoders

This variant works by taking a clean image and adding noise to it, passing the noisy image through the encoder-decoder architecture, training the network to reconstruct the original clean image, forcing the encoder to learn how to remove noise from inputs

Neural Inpainting

This technique involves cropping a section of an image and replacing it with blank pixels then feeding this modified image through the network and Training the network to reconstruct the original complete image. Applications include removing watermarks or objects from images

Variational Autoencoders

Unlike standard autoencoders that map inputs to fixed vectors, variational autoencoders map inputs onto probability distributions. This is achieved by replacing the bottleneck vector with two separate vectors: One representing the mean (μ) of the distribution, Another representing the standard deviation (σ) of the distribution

When feeding data through the decoder, a sample is drawn from this distribution rather than using a fixed vector.

The Reparameterization Trick

A key challenge in training VAEs is that gradients cannot flow through a sampling operation. The reparameterization trick solves this by representing the latent vector as: z = μ + σ × ε. Where ε is drawn from a standard normal distribution (mean 0, std 1). This separates the stochastic part (ε) from the trainable parameters (μ and σ). Allowing backpropagation to flow through the network while maintaining stochasticity

Disentangled Variational Autoencoders

Disentangled VAEs aim to ensure different neurons in the latent space learn uncorrelated features. Implementation requires only adding a hyperparameter (β) to the loss function that weights the KL divergence term. This encourages the network to only use a specific latent variable if it provides significant benefit or otherwise maintain the normal distribution

Applications

The core concept of disentangled VAEs is extracting causal features from high-dimensional spaces that generalize to domains outside training data. Particularly promising for reinforcement learning, where sparse rewards make training slow and difficult and Agents could operate on compressed representations instead of full input space moreover This could potentially improve learning efficiency

Practical Trade-offs

There's a clear trade-off in the degree of disentanglement [a] Too little disentanglement: The network may overfit, learning to reconstruct training data but failing to generalize [b] Too much disentanglement: High-definition details may be lost, potentially hurting performance