Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Mathematical Formulation of GANs | GAN Fundamentals
Quizzes & Challenges
Quizzes
Challenges
/
Generative Adversarial Networks Basics

bookMathematical Formulation of GANs

To understand the training of Generative Adversarial Networks (GANs), you need to look at their mathematical foundation. The process is formalized as a minimax game between two neural networks: the generator (GG) and the discriminator (DD). The objective function that governs this game is:

minGmaxDV(D,G)=Expdata[logD(x)]+Ezpz[log(1D(G(z)))]\min_G \max_D V(D, G) = \mathbb{E}_{x \sim p_{data}}[\log D(x)] + \mathbb{E}_{z \sim p_z}[\log(1 - D(G(z)))]

This equation describes how GG and DD are trained in opposition to each other. The generator tries to produce data that looks like the real data, while the discriminator tries to distinguish between real and generated data.

Note
Definition

Adversarial loss is the core objective function used in GANs. It quantifies how well the generator fools the discriminator and how accurately the discriminator distinguishes real from fake data. The adversarial loss is crucial because it drives both networks to improve: the generator learns to create more realistic samples, and the discriminator becomes better at detecting fakes.

In this context, the expectations Expdata\mathbb{E}_{x \sim p_{data}} and Ezpz\mathbb{E}_{z \sim p_z} represent averages over samples drawn from specific probability distributions. The distribution pdatap_{data} is the true data distribution, meaning real examples from your dataset. The distribution pzp_z is a simple, known distribution such as uniform or normal, from which you sample random noise vectors zz.

The generator, G(z)G(z), takes a noise vector zz and transforms it into a synthetic data sample. The discriminator, D(x)D(x), takes a data sample xx (which can be real or generated) and outputs the probability that xx is real. The loss function combines two terms: one that rewards the discriminator for correctly identifying real data, and one that rewards it for correctly identifying fake data generated by GG.

To see how the loss is computed, imagine a single training step. First, you sample a batch of real data xx from pdatap_{data} and a batch of noise zz from pzp_z. The discriminator receives both real and generated samples. For each real sample, it computes D(x)D(x), and for each fake sample G(z)G(z), it computes D(G(z))D(G(z)).

The discriminator's loss is the sum of the log-probabilities for real samples being classified as real and fake samples being classified as fake:

LossD=(1mi=1mlogD(x(i))+1mi=1mlog(1D(G(z(i)))))\text{Loss}_D = -\left(\frac{1}{m} \sum_{i=1}^{m} \log D(x^{(i)}) + \frac{1}{m} \sum_{i=1}^{m} \log(1 - D(G(z^{(i)})))\right)

The generator aims to make D(G(z))D(G(z)) close to 1, so its loss is:

LossG=1mi=1mlogD(G(z(i)))\text{Loss}_G = -\frac{1}{m} \sum_{i=1}^{m} \log D(G(z^{(i)}))

Both networks update their parameters using gradients from these losses, leading to the adversarial process that defines GAN training.

question mark

Which statement best describes the purpose of the GAN loss function?

Select the correct answer

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 1. Chapitre 3

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

Awesome!

Completion rate improved to 8.33

bookMathematical Formulation of GANs

Glissez pour afficher le menu

To understand the training of Generative Adversarial Networks (GANs), you need to look at their mathematical foundation. The process is formalized as a minimax game between two neural networks: the generator (GG) and the discriminator (DD). The objective function that governs this game is:

minGmaxDV(D,G)=Expdata[logD(x)]+Ezpz[log(1D(G(z)))]\min_G \max_D V(D, G) = \mathbb{E}_{x \sim p_{data}}[\log D(x)] + \mathbb{E}_{z \sim p_z}[\log(1 - D(G(z)))]

This equation describes how GG and DD are trained in opposition to each other. The generator tries to produce data that looks like the real data, while the discriminator tries to distinguish between real and generated data.

Note
Definition

Adversarial loss is the core objective function used in GANs. It quantifies how well the generator fools the discriminator and how accurately the discriminator distinguishes real from fake data. The adversarial loss is crucial because it drives both networks to improve: the generator learns to create more realistic samples, and the discriminator becomes better at detecting fakes.

In this context, the expectations Expdata\mathbb{E}_{x \sim p_{data}} and Ezpz\mathbb{E}_{z \sim p_z} represent averages over samples drawn from specific probability distributions. The distribution pdatap_{data} is the true data distribution, meaning real examples from your dataset. The distribution pzp_z is a simple, known distribution such as uniform or normal, from which you sample random noise vectors zz.

The generator, G(z)G(z), takes a noise vector zz and transforms it into a synthetic data sample. The discriminator, D(x)D(x), takes a data sample xx (which can be real or generated) and outputs the probability that xx is real. The loss function combines two terms: one that rewards the discriminator for correctly identifying real data, and one that rewards it for correctly identifying fake data generated by GG.

To see how the loss is computed, imagine a single training step. First, you sample a batch of real data xx from pdatap_{data} and a batch of noise zz from pzp_z. The discriminator receives both real and generated samples. For each real sample, it computes D(x)D(x), and for each fake sample G(z)G(z), it computes D(G(z))D(G(z)).

The discriminator's loss is the sum of the log-probabilities for real samples being classified as real and fake samples being classified as fake:

LossD=(1mi=1mlogD(x(i))+1mi=1mlog(1D(G(z(i)))))\text{Loss}_D = -\left(\frac{1}{m} \sum_{i=1}^{m} \log D(x^{(i)}) + \frac{1}{m} \sum_{i=1}^{m} \log(1 - D(G(z^{(i)})))\right)

The generator aims to make D(G(z))D(G(z)) close to 1, so its loss is:

LossG=1mi=1mlogD(G(z(i)))\text{Loss}_G = -\frac{1}{m} \sum_{i=1}^{m} \log D(G(z^{(i)}))

Both networks update their parameters using gradients from these losses, leading to the adversarial process that defines GAN training.

question mark

Which statement best describes the purpose of the GAN loss function?

Select the correct answer

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 1. Chapitre 3
some-alt