Deep Learning Assignment – V
1. Compare generative and discriminative models with suitable
examples. Discuss their objectives, learning approaches,
advantages, and limitations.
Generative Model (Generator G) Discriminative Model (Discriminator D)
Generates new data samples similar to real Classifies data as real or fake.
data.
Learns the underlying data distribution. Learns the boundary between different
classes.
Takes random noise (z) as input and produces Takes data sample (x) as input and predicts
synthetic data G(z). its class label (y).
Learns the probability distribution P(X). Learns the conditional probability P(Y|X).
Goal: PG(X) ≈ Pdata(X). Goal: D(X) = P(Y = Real | X).
Objective is to fool the discriminator by Objective is to correctly identify real and fake
generating realistic samples. samples.
Maps latent space to data space: G : Z → X. Maps data to class labels: D : X → Y.
Example: DCGAN Generator, RGAN Example: CNN, ResNet, VGG, GAN
Generator. Discriminator.
Advantage: Can create realistic images, Advantage: Provides accurate classification
videos, and time-series data. and feedback.
Limitation: May suffer from mode collapse Limitation: Over-training can lead to
and difficult evaluation. vanishing gradients and unstable training.
2. Explain the architecture of a Generative Adversarial Network
(GAN). Describe the roles of the Generator and Discriminator
• A Generative Adversarial Network (GAN) consists of two neural networks, namely the
Generator (G) and the Discriminator (D), which compete with each other in a zero-sum
game.
• The goal of a GAN is to generate data that is similar to real-world data.
Architecture of GAN :
1. The Generator takes a random noise vector zzz as input.
2. It generates synthetic (fake) data samples.
3. The Discriminator receives both real data and generated data.
4. It classifies each sample as real or fake.
5. The Generator tries to fool the Discriminator.
6. The Discriminator tries to correctly identify real and fake samples.
7. Through continuous training, both networks improve their performance.
Role of the Generator (G) :
• Acts as the data creator.
• Converts random noise into realistic data samples.
• Aims to generate outputs that resemble real data.
• Learns through feedback received from the Discriminator.
• Objective: To fool the Discriminator.
Role of the Discriminator (D) :
• Acts as a binary classifier.
• Distinguishes between real and generated data.
• Assigns a probability score indicating whether the input is real.
• Learns directly from both real and fake samples.
• Objective: To correctly classify real and fake data.
3. Describe the training procedure of a GAN. Explain the minimax
game formulation and discuss how the Generator and
Discriminator are updated iteratively.
• The training of a Generative Adversarial Network (GAN) is based on a minimax game
between two neural networks: the Generator (G) and the Discriminator (D).
• The Generator tries to create realistic data, while the Discriminator tries to distinguish
real data from fake data.
Minimax Game Formulation :
The objective function of a GAN is:
• The Discriminator tries to maximize this function by correctly classifying real and fake
samples.
• The Generator tries to minimize this function by generating data that fools the
Discriminator.
Training Procedure :
Iterative Updates :
• The Discriminator and Generator are updated alternately.
• The Discriminator improves its ability to detect fake data.
• The Generator improves its ability to generate realistic data.
• This process continues until the generated data becomes very similar to real data.
4. Derive and explain the objective (loss) functions used in a standard
GAN. Discuss how the Generator and Discriminator losses
influence the training process.
In a Generative Adversarial Network (GAN), the Generator (G) and Discriminator (D) are
trained using opposite objectives. This creates a minimax game between the two networks.
GAN Objective Function :
• D(x) = Probability that input x is real.
• G(z) = Fake data generated from random noise z.
• E = Expected value.
• The Discriminator tries to maximize this function.
• The Generator tries to minimize this function.
1. Discriminator Loss
The Discriminator acts as a binary classifier.
Objective:
• Assign a high probability to real data.
• Assign a low probability to generated (fake) data.
Loss Function:
• Maximizes log D(x) for real samples.
• Maximizes log(1 − D(G(z))) for fake samples.
2. Generator Loss
The Generator tries to fool the Discriminator.
Objective:
• Generate data that looks real.
• Make the Discriminator classify fake samples as real.
Loss Function:
• Minimizes log(1 − D(G(z))).
• In practice, the Generator often uses −log(D(G(z))) because it provides stronger learning
signals.
Influence on Training Process :
1. The Discriminator learns to distinguish real and fake samples.
2. The Generator learns to create more realistic samples.
3. Both networks are trained alternately.
4. If the Discriminator becomes too strong, the Generator receives weak gradients and
learning slows down.
5. If the Discriminator is too weak, it provides poor feedback to the Generator.
6. Proper balance between the two networks is essential for stable training.
7. Training continues until the generated data becomes very similar to real data.
5. Analyse the major challenges encountered during GAN training,
such as mode collapse, non-convergence, and vanishing gradients.
Suggest possible solutions to these issues.
Challenges in GAN Training and Their Solutions
1. Vanishing Gradients
Analysis :
During the initial stages of training, the generator produces poor-quality samples. The
discriminator easily classifies them as fake, giving:
D(G(z)) ≈ 0
The generator tries to minimize:
log(1 − D(G(z)))
When D(G(z)) is close to 0, the gradient becomes very small, causing the generator to learn
slowly or stop learning completely.
Solutions :
• Use Non-Saturating Loss: maximize log(D(G(z))) instead of minimizing log(1 − D(G(z))).
• Use Wasserstein GAN (WGAN).
• Use Least Squares GAN (LSGAN).
• Prevent the discriminator from becoming too powerful.
2. Mode Collapse
Analysis :
Mode collapse occurs when the generator produces only a limited variety of outputs instead of
learning the entire data distribution. As a result, many generated samples look very similar.
Effects :
• Reduced diversity of generated data.
• Failure to capture all patterns present in real data.
Solutions :
• Use Conditional GAN (cGAN).
• Apply Mini-batch Discrimination.
• Use Feature Matching techniques.
• Adopt WGAN or LSGAN for more stable training.
3. Non-Convergence and Training Imbalance
Analysis :
GAN training is a minimax game:
min G max D V(D,G)
The generator and discriminator compete continuously, making convergence difficult. If the
discriminator is too strong, the generator receives weak feedback. If it is too weak, the
generator learns incorrect patterns.
Solutions :
• Follow DCGAN architecture guidelines:
o Use strided convolutions instead of pooling.
o Use Batch Normalization.
o Use ReLU in the generator and LeakyReLU in the discriminator.
• Use the Adam optimizer with:
o Learning rate = 0.0002
o β₁ = 0.5
• Apply Spectral Normalization and Gradient Penalty.
6. Explain the concept of Conditional GAN. How does conditioning
information modify the architecture and objective of a standard
GAN? Discuss its advantages with examples.
Concept of Conditional GAN :
A Conditional GAN (cGAN) is an extension of the standard GAN that uses additional
information (condition y) to guide the data generation process. Unlike a standard GAN, where
outputs depend only on random noise, a cGAN generates outputs based on both random noise
(z) and conditioning information (y).
The condition can be:
• Class labels
• Text descriptions
• Images
• Attributes or other auxiliary information
This enables controlled and targeted generation of data.
Architecture Modifications :
Generator (G):
• Standard GAN: Input = Random noise (z)
• cGAN: Input = Random noise (z) + Condition (y)
• Generates a sample: G(z|y)
Discriminator (D):
• Standard GAN: Input = Data sample (x)
• cGAN: Input = Data sample (x) + Condition (y)
• Determines whether the pair (x, y) is real or fake.
Objective Function :
Standard GAN:
V(D,G) = E[log D(x)] + E[log(1 − D(G(z)))]
Conditional GAN:
V(D,G) = E[log D(x|y)] + E[log(1 − D(G(z|y)|y))]
Advantages :
1. Controlled Generation – Produces outputs according to the specified condition.
2. Higher Quality Outputs – Additional information improves generation accuracy.
3. Reduced Ambiguity – Generates samples belonging to the desired class.
4. Wide Applicability – Useful in image synthesis, translation, and data augmentation.
Applications :
• MNIST Digit Generation: Generate a specific digit (0–9) using its label.
• Image-to-Image Translation (Pix2Pix): Convert sketches to photos, black-and-white
images to color images, etc.
• Text-to-Image Synthesis: Generate images from textual descriptions.
• Super-Resolution: Convert low-resolution images into high-resolution images.
7. Compare a standard GAN and a Conditional GAN in terms of
architecture, input requirements, output control, and practical
applications.
Feature Standard GAN Conditional GAN (cGAN)
1. Basic Concept Generates data using only Generates data based on
random noise. random noise and additional
conditioning information.
2. Generator Input Receives only random noise Receives random noise (z)
vector (z). along with condition (y) such
as labels, text, or images.
3. Discriminator Input Receives only data sample (x) Receives both data sample
and classifies it as real or (x) and condition (y) to verify
fake. if the sample matches the
condition.
4. Input Requirements Requires only unlabeled Requires labeled data or
training data and random paired inputs in addition to
noise. random noise.
5. Output Control Uncontrolled generation; Controlled generation;
output depends entirely on output can be directed to a
random noise. specific class or characteristic
using y.
6. Training Objective Learns to distinguish real and Learns to distinguish real and
fake samples. fake samples while satisfying
the given condition.
7. Practical Applications Random image generation, Image-to-Image Translation
data synthesis, and learning (Pix2Pix), Text-to-Image
data distributions. Synthesis, Super-Resolution
(SRGAN),
8. Describe the architecture and working of a Recurrent Conditional
GAN (RCGAN). Explain how recurrent networks enable the
generation of sequential or time-series data.
Recurrent Conditional GAN (RCGAN) :
• A Recurrent Conditional GAN (RCGAN) is an extension of the Conditional GAN (cGAN)
designed for generating sequential and time-series data.
• It uses Recurrent Neural Networks (RNNs), typically LSTM units, in both the Generator
and Discriminator to capture temporal dependencies.
Architecture :
1. Generator (G)
• Receives a sequence of random noise vectors (zₜ) and conditioning information (yₜ) at
each time step.
• Uses LSTM layers to process the sequence.
• Generates a synthetic time-series sequence that follows the given condition.
2. Discriminator (D)
• Receives real or generated sequences along with the condition (yₜ).
• Uses LSTM layers to analyze temporal patterns.
• Classifies whether the sequence is real or fake based on all time steps.
Working of RCGAN :
1. Random noise sequence (zₜ) and condition (yₜ) are given to the Generator.
2. The Generator produces a synthetic sequence.
3. The Discriminator receives both real and generated sequences with the corresponding
condition.
4. It determines whether the sequence is real or fake.
5. Through adversarial training, the Generator learns to create realistic sequences while
the Discriminator learns to distinguish them.
How Recurrent Networks Enable Sequential Data Generation :
• LSTMs contain an internal memory that stores information from previous time steps.
• This enables the model to learn temporal dependencies and long-term relationships in
sequential data.
• Each output depends not only on the current input but also on past inputs.
• Therefore, RCGAN can generate realistic continuous sequences that preserve time-
dependent patterns.
Advantages :
• Captures temporal dependencies effectively.
• Generates realistic sequential and time-series data.
• Supports controlled generation through conditioning information.
Applications :
• ECG and healthcare signal generation.
• Speech and audio synthesis.
• Financial and stock-market data simulation.
• Sensor data generation for autonomous vehicles
9. Discuss any four real-world applications of GANs. Describe the
architecture, training process, and expected outcomes.
Real-World Applications of GANs :
1. Image-to-Image Translation
Architecture
• Uses a Conditional GAN (cGAN).
• Generator receives an input image (e.g., sketch, black-and-white image) and generates a
translated image.
• Discriminator checks whether the generated image matches the input condition.
Training Process
• Generator creates translated images.
• Discriminator distinguishes between real and generated image pairs.
• Both networks are trained adversarially until realistic translations are produced.
Expected Outcomes
• Sketch → Realistic Photo
• Black & White → Color Image
• Day Scene → Night Scene
• Satellite Image → Map
2. Text-to-Image Synthesis
Architecture
• Uses a Conditional GAN (cGAN).
• Generator takes random noise and a text description as input.
• Discriminator verifies whether the generated image matches the given text.
Training Process
• Text descriptions are encoded and provided as conditions.
• Generator learns to create images matching the text.
• Discriminator evaluates image-text consistency.
Expected Outcomes
• Generates realistic images directly from textual descriptions.
• Example: A description of a bird can produce an image matching its color, shape, and
features.
3. Medical Time-Series Generation
Architecture
• Uses a Recurrent Conditional GAN (RCGAN) with LSTM networks.
• Generator creates synthetic physiological signals.
• Discriminator analyzes temporal patterns in the generated sequences.
Training Process
• Sequential data and conditions are processed through LSTMs.
• Generator produces synthetic time-series data.
• Discriminator evaluates whether the sequence is real or fake.
Expected Outcomes
• Generation of realistic ECG, heart-rate, blood pressure, and ICU monitoring data.
• Helps in medical research and training while preserving patient privacy.
4. Automotive Sensor Modeling for Autonomous Driving
Architecture
• Uses RCGAN with LSTM-based Generator and Discriminator.
• Conditioned on factors such as vehicle speed, direction, and environment.
Training Process
• Learns temporal behavior of sensor readings and errors.
• Generator creates realistic sensor data sequences.
• Discriminator validates authenticity of generated sequences.
Expected Outcomes
• Generates realistic sensor errors and driving data.
• Used in autonomous vehicle simulation and safety testing.
• Reduces the need for extensive real-world testing.