71 min total

Generative AI

Autoencoders

Autoencoders

Researchers used to panic and suffer due to the lack of unsupervised approaches to train NNs prior to emergence of Autoencoders.

Autoencoder ~ (1991)

AEs were solely created to address unsupervised representation learning and data compression. Previous work on linear PCA and representation learning did lay out the backbone and it's not like AE came out of blue.

Is a neural network made up of two parts:

  1. Encoder network: compresses high-dimensional input data into low-dimensional embedding vector
  2. Decoder network: decompresses given embedding vector back to original domain.
GenAI / Mid 01 — Autoencoders

Auto encoders were originally created for unsupervised representation learning and data compression as previous work in linear PCA only dealt in linear dimensions, real world data is however non-linear. Auto encoders quickly became used for pretraining classifiers. In early days of Deep learning(2006-2012) training deep networks was hard because of vanishing/exploding gradients, lack of labelled data, bad weight initialization. Bottleneck forces model to learn important features from raw data, once trained decoder was discarded, encoders weights were appended by a deep supervised classifier and entire model was fine-tuned with labelled data, the model converged faster and generalized better.

Plot of colored latent space of an AE that is trained on Fashion MNIST clothes.

GenAI / Mid 01 — Autoencoders
GenAI / Mid 01 — Autoencoders

Applications of Autoencoders

  1. Image denoising

Auto encoders were also used for image denoising and there are many examples of AE denoising in our slide

GenAI / Mid 01 — Autoencoders
GenAI / Mid 01 — Autoencoders

linear PCA vs Deep AE performance

GenAI / Mid 01 — Autoencoders
  1. Principal component Analysis

Non-linear PCA arch. 1991 that was actually named as AE in recent times

GenAI / Mid 01 — Autoencoders
  1. Text retrieval
GenAI / Mid 01 — Autoencoders
GenAI / Mid 01 — Autoencoders
  1. Similar Image Search
GenAI / Mid 01 — Autoencoders
  1. Deconvolution

Technique is used to do image super-resolution, semantic segmentation

GenAI / Mid 01 — Autoencoders
GenAI / Mid 01 — Autoencoders

Sparse Autoencoders (SAEs) ~(mid-2000s)

Is a type of autoencoder that enforces sparsity constraints on hidden layer.

  • Sparsity prevents overfitting,
  • enhances feature extraction.
  • We ensure that only a few neurons activate for any given input

Ways to achieve Sparsity

  1. L1 regularization

We achieve sparsity by adding a penalty term to loss function L1 regularization

: net output activation value of bottle neck layer's i'th neuron

Higher λ → more sparsity

  1. KL Divergence

Another way is to enforce sparsity by measuring difference between average neuron activation and target sparsity level p. KL Divergence enforces sparsity by penalizing neurons that are too active.

P is a percentage value which means only p% of neurons should be active at a time

: target activation value e.g. 5% of neurons should be active at a time

: actual activation of neuron j

measures how different actual neuron activation is from desired sparsity p

If too many neurons are active , KL loss is high, penalizing the network

GenAI / Mid 01 — Autoencoders
X10.55
X20.72
110.42
120.72
210
220.3
310.15
320.09
410.44
420.03
430.55
510.55
610.71
710.29
810.97
820.55
830.97
910.71
920.7
930.22
GenAI / Mid 01 — Autoencoders

Learning rate = 0.5, ReLU activation at each neuron

GenAI / Mid 01 — Autoencoders

: pre activation values at layer n

: weight gradients at layer n

: activation function gradients

activation net output from previous layer

Z : pre activation value at neuron

A: activation output

Q1) Do forward pass

Q2) Compute reconstruction error

Q3) Perform backward pass, update weights

Ans1)

NeuronCalculation
10.7494
20.216
30.1473
40.417231
50.22947705
60.29623401
70.12099699
80.50288852
90.39691185

Ans2)

GenAI / Mid 01 — Autoencoders — notes
X10.55
X20.72

Ans3)

GenAI / Mid 01 — Autoencoders