Given the output of the Distriminator D, we can utilize a binary cross-entropy loss as usual discriminators would. We can simply the loss function if we knew which
inputs were generated, \( \hat{x} \), and which came from the original data distribution \( x \).
\begin{equation}
J_D = - [t \log(D(x)) + (1-t) \log(1-D(x))]
\end{equation}
We can simplify the loss function if we knew which inputs were generated, \( \hat{x} \), and which came from the original data distribution \( x \).
\begin{equation}
J_D = - [\log(D(x)) + \log(1-D(\hat{x}))]
\end{equation}
We can rewrite this back into a format with expectation values as,
\begin{align}
J_D
&= - [t \log(D(x)) + (1-t) \log(1-D(x))] \\
&= \mathbb{E}_{X \sim p(x)} \big [ \log{D(x)} \big ] + \mathbb{E}_{Z \sim p(z)} \big [ \log{(1-D(Z))} \big ]
\end{align}
We know that since the generated samples come from G(z), then we have,
\begin{align}
J_D
&= - [t \log(D(x)) + (1-t) \log(1-D(x))] \\
&= \mathbb{E}_{X \sim p(x)} \big [ \log{D(x)} \big ] + \mathbb{E}_{Z \sim p(z)} \big [ \log{(1-D(Z))} \big ] \\
&= \mathbb{E}_{X \sim p(x)} \big [ \log{D(x)} \big ] + \mathbb{E}_{Z \sim p(z)} \big [ \log{(1-D(G(z)))} \big ]
\end{align}
Finally, we know that since a discriminator is looking to discriminate between a real and fake image, we are looking to reduce the error; in other words, minimizing the error as.
\begin{align}
J_D
&= \max_{D} \mathbb{E}_{X \sim p(x)} \big [ \log{D(x)} \big ] + \mathbb{E}_{Z \sim p(z)} \big [ \log{(1-D(G(z)))} \big ]
\end{align}
We know from the description of a GAN that a Generator G is attempting to fool the Discriminator into believing the generated samples are real
\begin{equation}
J_G = - J_D
\end{equation}
We can simply the loss function if we knew which inputs were generated, \( \hat{x} \), and which came from the original data distribution \( x \).
\begin{align}
J_G
&= \min_{G} -J_D \\
&= \min_{G} \mathbb{E}_{X \sim p(x)} \big [ \log{D(x)} \big ] + \mathbb{E}_{Z \sim p(z)} \big [ \log{(1-D(G(z)))} \big ]
\end{align}
Together we call this is a mini-max loss function.
\begin{align}
J_G
&= \min_{D} \max_{G} -J_D \\
&= \max_{G} \mathbb{E}_{X \sim p(x)} \big [ \log{D(x)} \big ] + \mathbb{E}_{Z \sim p(z)} \big [ \log{(1-D(G(z)))} \big ]
\end{align}