The Wayback Machine - https://web.archive.org/web/20240709045952/https://www.geeksforgeeks.org/selection-of-gan-vs-adversarial-autoencoder-models/
Open In App

Selection of GAN vs Adversarial Autoencoder models

Last Updated : 21 Feb, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we are going to see the selection of GAN vs Adversarial Autoencoder models.

Generative Adversarial Network (GAN)

The Generative Adversarial Network, or GAN, is one of the most prominent deep generative modeling methodologies right now. The primary distinction between GAN and VAE is that GAN seeks to match the pixel level distribution rather than the data distribution, and it optimizes the model distribution to the genuine distribution in a different method.

What is the process through which GAN creates an image? Images are nothing more than vectors of pixel values. Random values, on the other hand, cannot be utilized to create a picture of an item. To make a picture of a dog seem like a dog, the pixels must have a certain value and be placed in a specific manner. As a result, we may state that the vectors must follow a specific distribution in order to resemble a dog. As a result, the goal of GAN is to take a random vector as an input and convert it into a pixel distribution that matches our intended output.

As a result, the latent variables or GAN inputs themselves have no significance other than the meaning provided by the network. Any point in the latent space will be mapped to a meaningful output by the model.

Training a GAN network:

Despite the fact that we know GAN alters the input to follow the object distribution, how does GAN optimize the network to learn the output distribution? There are “direct” and “indirect” methods for doing this. By comparing the genuine distribution with the created distribution, determining the errors, and adjusting the networks appropriately, the “direct” technique is used. The Generative Matching Network (GMN) used this method. The genuine distribution of the production, on the other hand, is likely to be complicated. Unlike a Gaussian distribution, which can be described using just the mean and variance. Explicitly expressing both the real and produced distributions would be challenging. Instead, the distributions are compared using samples from the actual and created distributions. We can estimate the distribution and examine the difference using samples of genuine and created data.

GAN, on the other hand, takes an “indirect” method, using a separate network, the discriminator, to categorize actual and produced data. In a nutshell, the GAN architecture is made up of two parts: the discriminator, which is taught to classify both genuine and produced data, and the generator, which is educated to mislead the discriminator into classifying the false samples as real.

Process of training the GANs:

  1. Train the Discriminator by freezing the weight of the generator (only update discriminator), use the generator to create false samples (initially, this will be noise as the generator is untrained at first), sample the real samples and train the discriminator using actual and fictitious examples (using the real and fake label).
  2. Then, train the Generator by setting the discriminator’s weight to zero (only update generator), use the generator to create false samples and then train the generator with the discriminator output using the bogus samples as input
  3. Repeat Step 1 and 2

Adversarial Networks

The Adversarial Autoencoder (AAE) is a brilliant concept that combines the autoencoder architecture with GAN’s adversarial loss notion. It works in a similar way to the Variational Autoencoder (VAE), except instead of KL-divergence, it utilizes adversarial loss to regularize the latent code.

To fit the encoded latent coding into a normal distribution, VAE uses KL-divergence (the difference between distributions) (or any arbitrary distribution that was chosen). AAE substitutes this with adversarial loss, which adds an extra discriminator component and makes the encoder the generator. Unlike GAN, where the generator’s output is the created picture and the discriminator’s input is both genuine and false images, AAE’s generator creates a latent code and attempts to convince the discriminator that the latent code is sampled from the specified distribution. The discriminator, on the other hand, will determine if a particular latent code was created by the autoencoder (fake) or a random vector drawn from the normal distribution (real).

Three different types of encoders to choose from:

  1. The encoder will attempt to compress the input into specified characteristics expressed as vector z, which is the same encoder used in autoencoder.
  2. Instead of encoding each feature into a single value, the Gaussian Posterior encoder will store the gaussian distribution of each feature using two variables, mean and variance.
  3. The characteristics are also encoded as distribution using the Universal Approximator Posterior. We do not, however, assume that the feature distribution follows a Gaussian distribution. The encoder in this example will be a function f(x, n), where x is the input and n is random noise with any possible distribution.

As a result, the AAE architecture is made up of the following elements:

  • The encoder will take the input and convert it into a lower-dimensional format (latent code z)
  • The decoder will turn the latent code z into the resulting picture.
  • The discriminator uses the encoded latent code z (fake) from the autoencoder as well as a random vector z selected from the specified distribution (real). It will verify whether or not the input is genuine.

The encoder and discriminator are the two fundamental distinctions between AAE and GAN, as seen in the architecture above. Unlike GAN, AAE uses an image as its input rather than a random vector z. This is accomplished by including an encoder at the beginning. Furthermore, AAE attempts to make the latent code follow a normal distribution (or your chosen distribution). This is accomplished by altering the discriminator jobs to anticipate whether a latent code z is created by the autoencoder or derived from a normal distribution. Unlike GAN, where the discriminator’s job is to predict whether a given picture is genuine or false, here the discriminator’s job is to predict whether a given image is real or fake (fake).

Applications

One of the exciting applications of Adversarial Autoencoder is in the anomaly detection and localization tasks, an unsupervised method to detect the anomaly is needed. Autoencoder can be trained to reconstruct an anomaly image to a normal image, the anomaly can be detected by calculating the difference between the reconstructed image without the anomaly and the original anomaly image.



Similar Reads

What is so special about Generative Adversarial Network (GAN)
Fans are ecstatic for a variety of reasons, including the fact that GANs were the first generative algorithms to produce convincingly good results, as well as the fact that they have opened up many new research directions. In the last several years, GANs are considered to be the most prominent machine learning research, and since then, GANs have re
5 min read
Generative Adversarial Network (GAN)
GAN(Generative Adversarial Network) represents a cutting-edge approach to generative modeling within deep learning, often leveraging architectures like convolutional neural networks. The goal of generative modeling is to autonomously identify patterns in input data, enabling the model to produce new examples that feasibly resemble the original data
15+ min read
ML | AutoEncoder with TensorFlow 2.0
This tutorial demonstrates how to generate images of handwritten digits using graph mode execution in TensorFlow 2.0 by training an Autoencoder. An AutoEncoder is a data compression and decompression algorithm implemented with Neural Networks and/or Convolutional Neural Networks. the data is compressed to a bottleneck that is of a lower dimension t
4 min read
Implement Deep Autoencoder in PyTorch for Image Reconstruction
Since the availability of staggering amounts of data on the internet, researchers and scientists from industry and academia keep trying to develop more efficient and reliable data transfer modes than the current state-of-the-art methods. Autoencoders are one of the key elements found in recent times used for such a task with their simple and intuit
8 min read
Implementing an Autoencoder in PyTorch
Autoencoders are a type of neural network which generates an "n-layer" coding of the given input and attempts to reconstruct the input using the code generated. This Neural Network architecture is divided into the encoder structure, the decoder structure, and the latent space, also known as the "bottleneck". To learn the data representations of the
7 min read
How is Autoencoder different from PCA
In this article, we are going to see how is Autoencoder different from Principal Component Analysis (PCA). Role of Dimensionality Reduction in MLWe often come into the curse of dimensionality issues in machine learning projects, when the amount of data records is not a significant component of the number of features. This often causes issues since
3 min read
Implement Convolutional Autoencoder in PyTorch with CUDA
Autoencoders are a type of neural network architecture used for unsupervised learning tasks such as data compression, dimensionality reduction, and data denoising. The architecture consists of two main components: an encoder and a decoder. The encoder portion of the network compresses the input data into a lower-dimensional representation, while th
4 min read
Convolutional Variational Autoencoder in Tensorflow
In the age of Generative AI, the creation of generative models is very crucial for learning and synthesizing complex data distributions within the dataset. By incorporating convolutional layers with Variational Autoencoders, we can create a such kind of generative model. In this article, we will discuss about CVAE and implement it. Convolutional Va
10 min read
Contractive Autoencoder (CAE)
In this article, we will learn about Contractive Autoencoders which come in very handy while extracting features from the images, and how normal autoencoders have been improved to create Contractive Autoencoders. What is Contarctive AutoEncoder?Contractive Autoencoder was proposed by researchers at the University of Toronto in 2011 in the paper Con
5 min read
Super Resolution GAN (SRGAN)
SRGAN was proposed by researchers at Twitter. The motive of this architecture is to recover finer textures from the image when we upscale it so that it's quality cannot be compromised. There are other methods such as Bilinear Interpolation that can be used to perform this task but they suffer from image information loss and smoothing. In this paper
5 min read
Article Tags :
Practice Tags :