# Generative Adversarial Network (GAN)

https://developers.google.com/machine-learning/gan

This course was recommended: https://github.com/johnowhitaker/aiaiart

- Really good introductory video about GANs by Computerphile
- Tips for training them https://github.com/soumith/ganhacks
- Some really cool applications: https://github.com/nashory/gans-awesome-applications#3d-object-generation
- Tutorial on how to train a GAN: https://www.youtube.com/watch?v=Mng57Tj18pc&ab_channel=DigitalSreeni

Generative adversarial networks (GAN) framework has been established as a viable solution for image distribution learning tasks.

(Explanation of GAN applied to image generation) GANs are composed of two Neural Nets, one called the generator and one called the discriminator.

- The
**generator network**creates new synthetic images trying to fool a discriminator network - The
**discriminator network**learns to tell a fake, synthesized image from a real one.

The competition between both networks allows them to improve, until the generator network becomes so good that the fake synthesized images cannot be distinguished from real ones.

### Mathematical Formalization

Formally, the generative model is pitted against an adversary: a discriminative model that learns to determine whether a sample is from the model distribution or the data distribution.

$D$ and $G$ play the following two-player minimax game with value function $V(G,D)$: $min_{G}max_{D}V(D,G)=E_{x∼p_{data}(x)}[gD(x)]+E_{z∼p_{z}(z)}[g(1−D(G(z)))]$

where

- $D$ and $G$ are differentiable functions represented by an MLP
- $D(x)$ represents the probability that x came from the data rather than $p_{g}$
- D is trained to
**maximize**the probability of assigning the correct label to both training examples and samples from G. The discriminative model estimates the probability that an input image is drawn from $p_{data}$- D = discriminative model

- G takes z as input and outputs an image, trained to minimize $g(1−D(G(z)))$:
- G = generative model.

With a GAN, given enough iterations, $p_{z}$ converges to $p_{data}$. In other words, from a random vector, $z$, the network $G$ can synthesize an image, $G(z)$, that resembles one that is drawn from the true distribution, $p_{data}$.

The discriminator is a traditional CNN, The generator works by taking in random noise and creating an output.

### Wasserstein GAN

Wasserstein Metric GAN: https://www.youtube.com/watch?v=xs9uibPODGk&ab_channel=Oneworldtheoreticalmachinelearning

Wasserstein GAN Paper: https://arxiv.org/pdf/1701.07875.pdf