# A THz Passive Image Generation Method Based on Generative Adversarial Networks
## 2 Methodology
### Overall Framework  
To avoid the instability of training caused by category labels, an unsupervised GAN model is proposed to generate high-quality THz passive images by improving the model structure. Figure 1 shows the overall framework of the proposed Res-WGAN-GP. There are two deep convolutional networks in the model: a generator (G) and a discriminator (D). The generator can be thought of as analogous to a counterfeiter, trying to make counterfeit money and use it without detection, while the discriminator is analogous to the police trying to detect counterfeit currency. The competition in this game pushed both sides to refine their methods until the fakes were indistinguishable from the genuine articles [8]. Specifically, the generator model converts the input of a certain distribution to the output closest to the real sample distribution by game learning. Here, the normal distribution random noise is employed as the input of the generator. Random noise is used to ensure that the images generated by the generator are different each time. Then, the generated images and real images are mixed and sent to the discriminator. The discriminator is equivalent to a binary classifier, which is used to determine which of the mixed input images are real and which are fake. Then, the discriminator feeds the judgment result to the generator to improve the quality of the generated images through the continuous adversarial process. Early GAN models suffer from training instability [13]. To solve the problem, the loss function based on Wasserstein distance was proposed in WGAN model [12] to improve the training stability. In the WGAN model, the weight of each layer of the discriminator is controlled by a fixed threshold to make it satisfy the Lipschitz constraint, which acts on all possible input spaces. The loss functions of the discriminator (\(D\)) and generator (\(G\)) in the WGAN model are expressed as  
\[\left\{ \begin{array}{l}\text{Loss\_D}=E_{\widetilde{x}\sim P_{\text{G}}}[D( \widetilde{x})]-E_{x\sim P_{\text{data}}}\left[D(x)\right]\\ \text{Loss\_G}=-E_{\widetilde{x}\sim P_{\text{G}}}[D(\widetilde{x})]\end{array} \right. \tag{1}\]  
where \(P_{data}\) is the distribution of real data; \(P_{\text{G}}\) denotes the distribution of generated image data. \(\widetilde{x}=G(z)\) is the output of the generator, \(z\) denotes the random noise vector. Figure 1: Overall framework of Res-WGAN-GP. Such a discriminator in the WGAN model would be inclined to learn a simple mapping function and cause the problem of the gradient vanishing or exploding due to the weight clipping. In order to avoid this problem, the loss function with a gradient penalty was proposed in the WGAN-GP model [13]. Different from the sample space which the WGAN model focuses on, the WGAN-GP model only focuses on the region in the generated sample set region, the real sample set region, and the regions in between. Specifically, random sampling produces a pair of true and false samples \(x_{data},\widetilde{x}_{G}\), and then generates a random number \(\varepsilon\) between 0 and 1. \[x_{data}\,\sim\,P_{data},\,\,\,\widetilde{x}_{G}\,\sim\,P_{G},\,\,\, \varepsilon\,\sim Uniform[0,1] \tag{2}\]  
Then random interpolation sampling is carried out on the line between \(x_{data}\) and \(\widetilde{x}_{G}\) to obtain random data \(\hat{x}\)  
\[\hat{x}=\varepsilon x_{data}+(1-\varepsilon)\widetilde{x}_{G} \tag{3}\]  
The distribution of \(\hat{x}\) is defined as \(P_{\hat{x}}\). In WGAN-GP model, the gradient of the discriminator is limited to no more than 1. The discriminator hopes to increase the score difference between true and false samples, so after the discriminator is fully trained, the gradient value of the gradient will be around 1. Therefore, the added gradient penalty loss term can be set as the modulus of the discriminator gradient minus 1.