GAN
Generative model(unsupervised): 데이터 $\mathbf{x}$의 manifold를 잘 표현하는 latent random variable
($\mathbf{z}$)을 구한 다음, 알고 싶은 target분포(e.g. 이미지 $\mathbf{x}$)를 예측하는 모델
Loss Function
$\mathbf{x}\sim p_{data}(\mathbf{x})$: $p_{data}(\mathbf{x})$분포에서 샘플링된 $\mathbf{x}$
$\mathbf{z}\sim p_{data}(\mathbf{z})$: $p_{\mathbf{z}}(\mathbf{z})$분포에서 샘플링된 $\mathbf{z}$
${\color{blue}D}(\mathbf{x})$: real image로 판단할 확률 $(0 \leq D(\mathbf{x})\leq 1)$
Least Square GAN
에서는 $({\color{blue}D}(G(\mathbf{z})) - 1)^2$Least Square GAN
에서는 ${\color{blue}D}(G(\mathbf{z}))^2$ loss_D = -tf.reduce_mean(tf.log(discriminator(X)) + tf.log(1 - discriminator(G)))
parameter
는 고정Least Square GAN
에서는 $(D({\color{red}G}(\mathbf{z}))-1)^2$ loss_G = -tf.reduce_mean(tf.log(discriminator(G)))
ConvLayer(4개)
에서 Adam optimizer(beta1
=0.5, beta2
=0.999)를 사용하게 실험적으로 성능이 좋게 나옴최적화를 위한 극값이 존재하는가?
\[\begin{align} {\color{red} \min_G} {\color{blue} \max_D }V({\color{blue}D},{\color{red}G}) & = E_{\mathbf{x}\sim p_{data}(\mathbf{x})}{\color{blue}[}\log {\color{blue}D}(\mathbf{x}){\color{blue}]} +E_{\mathbf{z}\sim p_{\mathbf{z}}(\mathbf{z})}{\color{red} [}{\color{blue} [}\log(1-{\color{blue}D}({\color{red}G}(\mathbf{z}))){\color{blue} ]}{\color{red} ]} \\ & = \int_\mathbf{x} p_{data}(\mathbf{x}) \log {\color{blue}D}(\mathbf{x}) d\mathbf{x} + \int_\mathbf{z} p_{\mathbf{z}}(\mathbf{z}) {\color{red} [}{\color{blue} [}\log(1-{\color{blue}D}({\color{red}G}(\mathbf{z}))){\color{blue} ]}{\color{red} ]} d\mathbf{z} \\ & = \int_\mathbf{x} p_{data}(\mathbf{x}) \log {\color{blue}D}(\mathbf{x}) d\mathbf{x} + \int_\mathbf{x} p_{\mathbf{g}}(\mathbf{x}){\color{blue} [}\log(1-{\color{blue}D}(\mathbf{x})){\color{blue} ]} d\mathbf{x} ,\quad \because {\color{red}G} \text{ fixed} \\ 0 & = \frac{d}{d{\color{blue}D}}[p_{data}(\mathbf{x}) \log {\color{blue}D}(\mathbf{x})+p_{\mathbf{g}}(\mathbf{x}){\color{blue} [}\log(1-{\color{blue}D}(\mathbf{x})){\color{blue} ]}] \\ 0 & = \frac{p_{data}(\mathbf{x})}{D(\mathbf{x})} - \frac{p_{\mathbf{g}}(\mathbf{x})}{1-D(\mathbf{x})}\\ 0 & = \frac{p_{data}(\mathbf{x})(1-D(\mathbf{x}))-p_{\mathbf{g}}(\mathbf{x})D(\mathbf{x})}{D(\mathbf{x})(1-D(\mathbf{x}))} \\ 0 & = p_{data}(\mathbf{x})(1-D(\mathbf{x}))-p_{\mathbf{g}}(\mathbf{x})D(\mathbf{x}) \\ D(\mathbf{x}) & = \frac{p_{data}(\mathbf{x})}{p_{data}(\mathbf{x})+p_{\mathbf{g}}(\mathbf{x})}, \quad \therefore \text{it's true} \end{align}\]최적화를 위한 최대/최소가 존재하는가?
\[\begin{align} {\color{red} \min_G} {\color{blue} \max_D }V({\color{blue}D},{\color{red}G}) & =\int_\mathbf{x} p_{data}(\mathbf{x}) \log {\color{blue}D}(\mathbf{x}) d\mathbf{x} + \int_\mathbf{x} p_{\mathbf{g}}(\mathbf{x}){\color{blue} [}\log(1-{\color{blue}D}(\mathbf{x})){\color{blue} ]} d\mathbf{x} ,\quad \because {\color{red}G} \text{ fixed}\\ & = \int_\mathbf{x} p_{data}(\mathbf{x}) \log \frac{p_{data}(\mathbf{x})}{p_{data}(\mathbf{x})+p_{\mathbf{g}}(\mathbf{x})} d\mathbf{x} + \int_\mathbf{x} p_{\mathbf{g}}(\mathbf{x}){\color{blue} [}\log( \frac{p_{\mathbf{g}}(\mathbf{x})}{p_{data}(\mathbf{x})+p_{\mathbf{g}}(\mathbf{x})} ){\color{blue} ]} d\mathbf{x}\\ & ={\color{average}-\log4} + \int_\mathbf{x} p_{data}(\mathbf{x}) \log \frac{p_{data}(\mathbf{x})}{\frac{p_{data}(\mathbf{x})+p_{\mathbf{g}}(\mathbf{x})}{\color{average}2}} d\mathbf{x} + \int_\mathbf{x} p_{\mathbf{g}}(\mathbf{x}){\color{blue} [}\log( \frac{p_{\mathbf{g}}(\mathbf{x})}{\frac{p_{data}(\mathbf{x})+p_{\mathbf{g}}(\mathbf{x})}{\color{average}2}} ){\color{blue} ]} d\mathbf{x} \\ & = -\log4 + KL(p_{data}(\mathbf{x})||\frac{p_{data}(\mathbf{x})+p_{\mathbf{g}}(\mathbf{x})}{2}) + KL(p_{\mathbf{g}}(\mathbf{x})||\frac{p_{data}(\mathbf{x})+p_{\mathbf{g}}(\mathbf{x})}{2})\\ &= -\log4 + 2 \times JSD(p_{data}(\mathbf{x})|| p_{\mathbf{g}}(\mathbf{x})), \quad \therefore \text{JSD is non-negative, so it's true} \end{align}\]Reference
https://www.youtube.com/watch?v=odpjk7_tGY0
https://www.youtube.com/watch?v=0MxvAh_HMdY