## 2 What Is a Generative Adversarial Network?
### Exploring the Process  
Depending on the nature of the problem to be solved, two types of approaches are identified in machine learning: discriminative models and generative models. Given some observable variables \(\mathcal{X}\) and some target variable \(\mathcal{Y}\) that depends on \(\mathcal{X}\), the discriminative models learn to estimate \(\mathcal{Y}\) from \(\mathcal{X}\). Instead, generative models seek to estimate a probability distribution \(P_{r}\). Generally, these models take a training set consisting of samples from the distribution \(P_{r}\) and learn to represent an estimate of this distribution. The result is a probability distribution \(P_{g}\) that can be expressed explicitly, operating directly with its density function \(p_{g}\), or implicitly, by generating samples from it. A GAN is an implicit generative model. Formally, it is a structured probabilistic model based on latent variables \(z\) and observable variables \(x\). The core of the GAN methodology is based on a two-player game: a generator, which produces samples that ideally come from the distribution of the training set, and a discriminator, which tries to differentiate between samples from the generator and the training set [8; 9]. Both players are described in detail below:  
* The generator is a differentiable function \(G:\mathcal{Z}\times\mathbb{R}^{g}\rightarrow\mathcal{X}\) that has latent variables \(z\in\mathcal{Z}\) taken from a known prior distribution \(P_{z}\) and some parameters \(\theta\in\mathbb{R}^{g}\), and outputs a sample \(x\in\mathcal{X}\). Denote \(G_{\theta}:\mathcal{Z}\rightarrow\mathcal{X}\) to the parameter generator \(\theta\). * The discriminator is a differentiable function \(D:\mathcal{X}\times\mathbb{R}^{d}\rightarrow\mathbb{R}\) that takes a sample \(x\in\mathcal{X}\) and some parameters \(\omega\in\mathbb{R}^{d}\) and calculates a value that quantifies how real or synthetic the sample is. Denote \(D_{\omega}:\mathcal{X}\rightarrow\mathbb{R}\) to the discriminator parameter \(\omega\). In practice, both players are implemented with neural networks. The choice of the type of neural network to use for the generator and discriminator is free. As imaging is the field in which GANs are most widely used, the models with the best results use a convolutional neural network (CNN) architecture for the generator and discriminator [10; 11]. The training of a GAN is the process by which the parameters of the neural network are adjusted so that the generator produces images or synthetic data that are more and more similar to the real data, and the discriminator is able to distinguish with greater precision between the images generated and the real ones. The goal is for the generator to produce images that are increasingly difficult to distinguish from real images and for the discriminator to be increasingly accurate in its task of distinguishing between generated and real images. For this, the generator and the discriminator have cost functions defined in terms of the parameters of both. The generator seeks to minimize its cost function \(C^{G}(\theta,\omega)\) by controlling only its parameters \(\theta\) and, similarly, the goal of the discriminator is to minimize its cost function \(C^{D}(\theta,\omega)\) modifying only its \(\omega\) parameters. The solution to this game is a Nash equilibrium, a tuple \((\theta^{*},\omega^{*})\) that is a local minimum of \(C^{G}\) concerning \(\theta\) and of \(C^{D}\) to \(\omega\). In general, the cost functions are chosen to minimize a metric (distance, divergence, etc.) between the distribution of the training set \(P_{r}\) and the distribution of the generator \(P_{g}\). Finally, the training of a GAN is achieved using stochastic gradient descent (or any of its variants). At each step, two sets or batches are sampled: a batch of real samples \(x_{r}\) from the training set and a batch of latent variables \(z\) taken from the known distribution \(P_{z}\).