DeepLearning Unit IV Notes
DeepLearning Unit IV Notes
UNIT-IV
AUTO ENCODERS
What are Autoencoders?
An autoencoder neural network is an
Unsupervised Machine learning algorithm that is designed
to receive an input and transform it into a different
representation. Autoencoders can be used to compress the
data and reduce its dimensionality.
Autoencoders are a specific type of feedforward neural
networks where the input is the same as the output. They
compress the input into a lower-dimensional code and then
reconstruct the output from this representation. The code is a
compact “summary” or “compression” of the input, also
Architecture
An Autoencoder consists of three layers:
1. Encoder : It compresses the input image into a latent space
representation. It encodes the input image as a compressed
representation in a reduced dimension. The compressed image
is a distorted version of the original image.
2. Code : The Code layer represents the compressed input fed to
the decoder layer.
3. Decoder : This layer decodes the encoded image back to the
original dimension. The decoded image is a lossy
reconstruction of the original image and it is reconstructed from
the latent space representation.
The layer between the encoder and decoder, ie. the code is also
Architecture
The encoder compresses the input and produces the
code, the decoder then reconstructs the input only
using this code.
To build an autoencoder we need 3 things: an
encoding method, decoding method, and a loss
function to compare the output with the target.
Architecture
Both the encoder and
decoder are fully-
connected feedforward
neural networks.
Code is a single layer
of an ANN with the
dimensionality of our
choice. The number of
nodes in the code layer
is
a hyperparameter that Fig. Detailed visualization of an autoencoder
Architecture
First the input passes through the encoder, which is a
fully-connected ANN, to produce the code.
The decoder, which has the similar ANN structure,
then produces the output only using the code.
The goal is to get an output identical with the input.
Note that the decoder architecture is the mirror
image of the encoder. The only requirement is the
dimensionality of the input and output needs to be
the same.
Properties and Hyperparameters
Properties of Autoencoders:
1. Data-specific: Autoencoders are only able to
compress data similar to what they have been
trained on.
2. Lossy: The decompressed outputs will be degraded
compared to the original inputs.
3. Learned automatically from examples: It is easy
to train specialized instances of the algorithm that
will perform well on a specific type of input.
Properties and Hyperparameters
Hyperparameters of Autoencoders: There
are 4 hyperparameters that we need to set before training an
autoencoder:
1. Code size: It represents the number of nodes in the middle layer.
Smaller size results in more compression.
2. Number of layers: The autoencoder can consist of as many
layers as we want.
3. Number of nodes per layer: The number of nodes per layer
decreases with each subsequent layer of the encoder, and
increases back in the decoder. The decoder is symmetric to the
encoder in terms of the layer structure.
Applications of Autoencoders
Image Coloring
Autoencoders are used for converting any black and white
picture into a colored image. Depending on what is in the picture,
it is possible to tell what the color should be.
Applications of Autoencoders
Feature variation
It extracts only the required features of an image and generates
the output by removing any noise or unnecessary interruption.
Applications of Autoencoders
Denoising Image
The input seen by the autoencoder is not the raw input but a
stochastically corrupted version. A denoising autoencoder is thus
trained to reconstruct the original input from the noisy version.
Applications of Autoencoders
Dimensionality Reduction
The reconstructed image is the same as our input but with
reduced dimensions. It helps in providing the similar image with a
reduced pixel value.
Applications of Autoencoders
Watermark Removal
It is also used for removing watermarks from images or
1. Denoising autoencoders
2. Sparse autoencoders
3. Deep autoencoders
4. Variational Autoencoders (for generative modelling)
1. Denoising Autoencoders
A denoising autoencoder is a neural network model
that removes noise from corrupted or noisy data by
learning to reconstruct the original data from the noisy
version. It is trained to minimize the difference
between the original and reconstructed data.
Denoising autoencoders can be stacked to form deep
networks for improved performance.
The architecture can be adapted to other data types,
such as images, audio, and text. Adding noise can be
customized, e.g., Salt-and-Pepper, Gaussian noise.
1. Denoising Autoencoders
In denoising autoencoders, we feed a noisy version of
the image, where noise has been added via digital
alterations. The noisy image is fed to the encoder-
decoder architecture, and the output is compared with
the ground truth image.
1. Architecture of Denoising
Autoencoders
The architecture of a denoising autoencoder (DAE) is
similar to that of a standard autoencoder. It consists of
an encoder, which maps the input data to a lower-
dimensional representation, or encoding, and a
decoder, which maps the encoding back to the
original data space.
Encoder:
Encoder is a neural network with one or more hidden
layers.
1. Architecture of Denoising
Autoencoders
Decoder:
Decoder is an expansion function that reconstructs
layers.
Architecture of Denoising Autoencoders
During training, the DAE is given a set of clean input
examples and the corresponding noisy versions of
these examples. The goal is to learn a function that
maps the noisy input to the clean output using
the encoder-decoder architecture. This is typically
done using a reconstruction loss function that
measures the difference between the clean input and
the reconstructed output. The DAE is trained to
minimize this loss by updating the weights of the
encoder and decoder through backpropagation.
Application of DAE
Denoising autoencoders (DAEs) have many
applications in computer vision, speech processing, and
natural language processing. Some examples include:
Image denoising:
DAEs can be used to remove noise from images, such as
Gaussian noise or salt-and-pepper noise.
Fraud detection:
DAEs can be used to identify fraudulent transactions by
learning to reconstruct normal transactions from noisy
versions.
Application of DAE
Data imputation:
DAEs can impute missing values in a dataset by learning
to reconstruct the missing values from the remaining
data.
Data compression:
DAEs can compress data by learning a compact data
representation in the encoding space.
Anomaly detection:
DAEs can identify anomalies in a dataset by learning to
reconstruct normal data and then flagging difficult inputs
1. Denoising Autoencoders
1. Denoising Autoencoders
2. Sparse autoencoders
A sparse autoencoder is simply an autoencoder whose
training criterion involves a sparsity penalty.
The idea behind Sparse Autoencoders is that we can
achieve an information bottleneck (same information
with fewer neurons) without reducing the number of
neurons in the hidden layers. The number of neurons in the
hidden layer can be greater than the number in the input
layer.
According to the sparsity constraint, only some percentage
of nodes can be active in a hidden layer. The neurons with
2. Sparse autoencoders
Regularization in sparse autoencoders is a
technique used to control the learning process
and encourage the network to produce sparse
representations in the hidden layers.
The idea is to introduce additional constraints or
penalties during training that guide the autoencoder
to use only a subset of its neurons for each input,
resulting in a sparse activation pattern. This helps in
learning more meaningful and informative features
while preventing overfitting.
2. Sparse autoencoders
L1 Regularization: L1 regularization adds a penalty term
to the loss function that is proportional to the absolute
values of the weights. This encourages many weights to
become exactly zero, effectively forcing some neurons to
be inactive for certain inputs and promoting sparsity.
Kullback-Leibler (KL) Divergence Regularization: KL
divergence regularization imposes a constraint on the
activations of the hidden units to follow a specific target
distribution, often a Bernoulli distribution. This encourages
the activation of neurons to be either close to zero or one,
leading to sparsity.
2. Sparse autoencoders
2. Sparse autoencoders
Applications:
1. Dimensionality Reduction: Sparse autoencoders can be used
to perform dimensionality reduction on high-dimensional data.
By learning a compact representation of the input data in the
hidden layers, they can help reduce the amount of data while
preserving important features.
2. Data Compression: Sparse autoencoders can be used for
data compression, where the network learns a compact
representation of the input data. This compressed
representation can be stored or transmitted more efficiently
than the original data
2. Sparse autoencoders
Applications:
3. Collaborative Filtering: In recommendation systems, sparse
autoencoders can learn representations of users and items
based on their interactions in a user-item matrix. These learned
representations can then be used to provide personalized
recommendations.
4. Document Representation: For natural language processing
tasks, sparse autoencoders can be used to learn meaningful
representations of text documents. These representations can
capture semantic information and assist in tasks like document
classification and clustering.
3. Deep Autoencoders
A deep autoencoder extends the concept of a simple
autoencoder by adding more layers, making it capable of
learning more complex and abstract representations of
input data.
It is composed of two, symmetrical deep-belief networks-
1. First four or five shallow layers representing the encoding
half of the net.
2. The second set of four or five layers that make up the
decoding half.
3. Deep Autoencoders
generated data
generator loss, which penalizes the Generator for