Data Augmentation for Classification FFNN

Applied Generative AI

Sarvesh Khetan
6 min readJun 19, 2024

1. Generating Data Irrespective of Class

Use the same techniques that we discussed in data augmentation for Regression FFNN

2. Generating Class Specific Data

The above techniques will generate data of any class but what if we what to generate class specific data ? i.e. we need to make sure that the generated data belongs to class 1 and not to class 0? Hence comes the following conditional versions of all the techniques wherein we feed the class to be generated information into the model !!

2.1 Converting Actual Data
a. Conditional AutoEncoders (cAE)
b. Conditional Variational AutoEncoders (cVAE)
c. Conditional Vector Quantized Variational Autoencoders (cVQ-VAE)

2.2 Converting Noise (Single Step Decoding)
a. Conditional Generative Adverserial Networks (cGANs)

2.3 Converting Actual Data (Improved)
a. Conditional AE-GAN (cAE-GAN)
b. Conditional VAE-GAN (cVAE-GAN)
c. Conditional VQ-GAN (cVQ-GAN)

2.3 Converting Noise (Multi Step Decoding)
a. Conditional Flow Based Models
b. Conditional Denoising Diffusion Probabilistic Models (cDDPM) :
— — Classifier Based Guidance
— — Classifier Free Guidance
c. Conditional Denoising Diffusion Implicit Models (cDDIM)
— — Classifier Based Guidance
— — Classifier Free Guidance

Conditional AutoEncoders (cAE)

Using AutoEncoder you can’t specify if you want to generate only class A datapoint or class B datapoints, it will automatically generate some data points irrespective of their class, while using cAE you can specify which type of datapoint you want to generate i.e. class A or class B

Conditional Variational AutoEncoders (cVAE)

Using Variational AutoEncoder you can’t specify if you want to generate only class A datapoint or class B datapoints, it will automatically generate some data points irrespective of their class, while using cVAE you can specify which type of datapoint you want to generate i.e. class A or class B

Conditional VQ-VAE (cVQ-VAE)

Using VQ-VAE you can’t specify if you want to generate only class A datapoint or class B datapoints, it will automatically generate some data points irrespective of their class, while using cVQ-VAE you can specify which type of datapoint you want to generate i.e. class A or class B

Conditional GANs (cGANs)

Using GAN you can’t specify if you want to generate only class A datapoint or class B datapoints, it will automatically generate some data points irrespective of their class, while using cGAN you can specify which type of datapoint you want to generate i.e. class A or class B

Conditional AE-GAN (cAE-GAN)

Using AE-GAN you can’t specify if you want to generate only class A datapoint or class B datapoints, it will automatically generate some data points irrespective of their class, while using cAE-GAN you can specify which type of datapoint you want to generate i.e. class A or class B

Conditional VAE-GAN (cVAE-GAN)

Using VAE-GAN you can’t specify if you want to generate only class A datapoint or class B datapoints, it will automatically generate some data points irrespective of their class, while using cVAE-GAN you can specify which type of datapoint you want to generate i.e. class A or class B

Conditional VQ-GAN (cVQ-GAN)

Using VQ-GAN you can’t specify if you want to generate only class A datapoint or class B datapoints, it will automatically generate some data points irrespective of their class, while using cVQ-GAN you can specify which type of datapoint you want to generate i.e. class A or class B

Conditional Denoising Diffusion Probabilistic Models (cDDPM)

Using DDPM you can’t specify if you want to generate only class A datapoint or class B datapoints, it will automatically generate some data points irrespective of their class, while using cDDPM you can specify which type of datapoint you want to generate i.e. class A or class B

Similarly you can add conditioning on Latent DDPM (Latent cDDPM)

Now researchers observed that this vanilla conditioning doesn’t produce good results sometimes because the model sometimes ignores the conditioning information and hence guidance was proposed as a way to explicitly control the amount of weight the model gives to the conditional information. Two most popular guidance formats are as follows :

Conditional DDPMs — Classifier Based Guidance

We have already seen score function derivation of DDPM here, now let’s see how it chances after applying class conditioning

Hence we can use a second model, a classifier, to guide the diffusion toward the target class 𝑦 during training. To achieve that, we can train a classifier 𝑓𝜙(𝑦∣𝑥𝑡) on the noisy image 𝑥𝑡 to predict its class 𝑦. Then we can use the gradients ∇log⁡(𝑓𝜙(𝑦∣𝑥𝑡)) to guide the diffusion.

Similarly, you can apply this idea to Latent DDPMs to have Latent Conditional DDPMs — classifier based guidance model

Conditional DDPMs — Classifier Free Guidance

Problem with the above method is that we will have to train a classifier and hence we wanted to do away with training a separate classifier and hence this method was developed….

Interpretation :

  • Instead of training a classifier we can build a conditional DDPM and an unconditional DDPM.
  • Because learning two separate diffusion models is expensive, we can learn both the conditional and unconditional diffusion models together in one model by training it sometimes using conditioning and sometimes without conditioning (without conditioning can be done by replacing the conditioning information with fixed constant values, such as zeros)
  • And during inference you need to run inference twice i.e. once without conditioning and once with conditioning
  • Then combine the results using the above formula i.e. (1-omega)*unconditional_result + (omega)*conditional_result, where omega is a hyperparameter

Similarly you can have Latent Conditional DDPMs — classifier free guidance

Conditional Denoising Diffusion Implicit Model (cDDIM)

Using DDIM you can’t specify if you want to generate only class A datapoint or class B datapoints, it will automatically generate some data points irrespective of their class, while using cDDIM you can specify which type of datapoint you want to generate i.e. class A or class B

Similarly you can add conditioning on Latent DDIM (Latent cDDIM)

Conditional DDIMs — Classifier Based Guidance

Same approach as we saw in DDPMs just now replace the DDPM model with DDIM

Similarly, you can apply this idea to Latent DDIMs to have Latent Conditional DDIMs — classifier based guidance model

Conditional DDIMs — Classifier Free Guidance

Same approach as we saw in DDPMs just now replace the DDPM model with DDIM

Similarly, you can apply this idea to Latent DDIMs to have Latent Conditional DDIMs — classifier free guidance model

--

--

Sarvesh Khetan

A deep learning enthusiast and a Masters Student at University of Maryland, College Park.