Generative Models: Autoencoders, Variational Autoencoders, GANs and Their Applications
Introduction to Generative Models
Generative Models are Artificial Intelligence models that learn the underlying patterns and characteristics of existing data and use this knowledge to generate new data similar to the original data.
Unlike traditional models that mainly classify or predict, generative models can create new content such as images, text, audio, video, and synthetic data.
For example, if a generative model is trained on thousands of images of clothes, it can learn their patterns and generate new clothing images that were not present in the original dataset.
Simple Flow:
Training Data → Learn Patterns → Generative Model → Generate New Data
Types of Generative Models
There are different types of generative models. In this unit, we focus on three important models:
1. Autoencoder (AE) → Learns a compressed representation of data and reconstructs the original data.
2. Variational Autoencoder (VAE) → Learns a probabilistic representation of data and can generate new samples.
3. Generative Adversarial Network (GAN) → Uses two competing neural networks, a Generator and a Discriminator, to generate realistic new data.
Simple understanding:
AE → Compress and Reconstruct
VAE → Learn Distribution and Generate
GAN → Generate and Compete
Real-Life Examples
1. Autoencoder (AE) – Removing Noise from Images
Suppose an old scanned photograph contains noise, spots, or distortion. An Autoencoder can learn the important features of clean images and reconstruct a cleaner version.
Noisy Image → Autoencoder → Reconstructed/Cleaner Image
Real application: Image denoising and image restoration.
2. Variational Autoencoder (VAE) – Generating New Face Images
Suppose a VAE is trained on thousands of human face images. It learns a probabilistic latent representation of facial characteristics and can sample from that latent space to create new synthetic face images.
Face Dataset → VAE learns distribution → Sample Latent Vector → New Face Image
Real application: Synthetic image generation and data augmentation.
3. Generative Adversarial Network (GAN) – Generating Realistic Synthetic Images
A GAN can learn from a large collection of images and generate new realistic-looking synthetic images. The Generator creates images while the Discriminator evaluates whether they look real or fake.
Random Noise → Generator → Synthetic Image → Discriminator → Real/Fake
Real application: Synthetic face generation, image enhancement, virtual product/design creation, and training-data augmentation.
Important Terms in Generative Models
Encoder → Converts input data into a smaller, compressed representation.
Decoder → Converts the compressed representation back into reconstructed or generated data.
Latent Space → A compressed representation where the model stores the important learned features of the data.
Latent Vector → A particular set of numerical values representing one point in the latent space.
Probability Distribution → Describes how different possible values are distributed and how likely they are.
Sampling → Selecting values from the learned probability distribution to generate new data.
Generator → The part of a GAN that creates new synthetic or fake data.
Discriminator → The part of a GAN that determines whether data is real or generated (fake).
Random Noise → Random numerical values given to the Generator as input for creating new data.
Adversarial Training → Training in which the Generator and Discriminator compete with each other and improve together.
Reconstruction → Recreating the original input from its compressed representation.
Synthetic Data → Artificially generated data that resembles real data.
Data Augmentation → Increasing the amount and variety of training data by creating additional samples.
4.1 Autoencoders (AE)
An Autoencoder (AE) is a neural network that learns to compress input data into a smaller representation and then reconstruct the original data from that representation.
Basic Architecture
Input → Encoder → Latent Space → Decoder → Reconstructed Output
For example, when an image is given to an Autoencoder:
Original Image → Encoder → Compressed Features → Decoder → Reconstructed Image
The Encoder extracts the important features and reduces the data size.
The Latent Space stores the compressed representation containing important features of the input.
The Decoder uses this compressed representation to reconstruct an image as close as possible to the original.
Main Objective
The objective of an Autoencoder is to minimize the difference between the original input and reconstructed output, called reconstruction error.
Working of an Autoencoder
The working of an Autoencoder can be understood in three main stages:
1. Encoding → The input data is passed through the Encoder, which extracts important features and converts it into a smaller representation.
2. Latent Representation → The compressed information is stored in the Latent Space. It contains the most important features learned from the input.
3. Decoding → The Decoder takes the compressed representation and reconstructs the original data.
Example
Suppose we provide an image of a shoe:
Shoe Image → Encoder → Compressed Shoe Features → Decoder → Reconstructed Shoe Image
During training, the model compares:
Original Image ↔ Reconstructed Image
The difference between them is called Reconstruction Error (or Reconstruction Loss).
The Autoencoder adjusts its weights during training to minimize this reconstruction error.
Applications of Autoencoders
Autoencoders are used in many applications where feature learning and reconstruction are required.
Image Denoising → Removes unwanted noise from images and reconstructs a cleaner image.
Dimensionality Reduction → Converts high-dimensional data into a smaller representation while preserving important information.
Anomaly Detection → Identifies unusual data by detecting samples that the Autoencoder cannot reconstruct well.
Feature Extraction → Automatically learns important features from the input data.
Image Reconstruction → Reconstructs an input image from its compressed representation.
Data Compression → Represents large input data using fewer features in the latent space.
Example: Anomaly Detection
If an Autoencoder is trained mainly on normal transactions, it learns to reconstruct normal transactions accurately.
Normal Transaction → Small Reconstruction Error
Unusual/Fraudulent Transaction → Large Reconstruction Error
How VAE Works
Unlike a normal Autoencoder, a VAE does not directly create one fixed value for each latent feature. Instead, the Encoder learns a probability distribution.
It mainly learns two values:
Mean (μ) → Represents the center of the learned distribution.
Variance (σ²) → Represents how much the values can vary around the mean.
The VAE then samples a latent vector from this distribution and sends it to the Decoder.
Simple Flow
Input Image → Encoder → Mean (μ) + Variance (σ²) → Sampling → Latent Vector → Decoder → Output Image
Simple Example
Suppose the VAE is trained on thousands of shoe images. Instead of memorizing individual shoes, it learns a structured distribution of their important features.
We can then sample a new point from this learned latent space:
New Latent Sample → Decoder → New Synthetic Shoe Image
This ability to sample from the learned distribution and generate new data is the main reason VAE is considered a generative model.
Applications of Variational Autoencoders (VAE)
Image Generation → Generates new images similar to the images used during training.
Synthetic Data Generation → Creates artificial data samples that resemble real data.
Data Augmentation → Generates additional training samples when the available dataset is limited.
Image Reconstruction → Reconstructs images from their latent representations.
Anomaly Detection → Identifies unusual samples based on reconstruction behaviour or how poorly they fit the learned distribution.
Image Denoising → Helps reconstruct cleaner versions of noisy images.
Feature Learning → Learns meaningful compressed features automatically from complex data.
Drug and Molecule Generation → Can generate new candidate molecular structures by learning patterns from existing molecular data.
0 टिप्पण्या
कृपया तुमच्या प्रियजनांना लेख शेअर करा आणि तुमचा अभिप्राय जरूर नोंदवा. 🙏 🙏