# Suppression of Multiple Reflection Interference Signals in GPR Images Caused by Rebar Using VAE-GAN
## 2 Materials and Methods
### Loss Function  
The loss function of the model consists of the following components: VAE loss, adversarial loss, and cycle consistency loss.  
The VAE loss includes both the reconstruction loss and the Kullback-Leibler (KL) divergence. The former aims to maintain content consistency between the generated images and the original input images by using a pixel-level loss function to measure the differences between them. The latter aims to minimize the difference between the posterior distribution of the generated latent variables and the standard normal distribution. This encourages the encoder to learn the latent space with good representation, enabling the generator to produce realistic images. The formulas for VAE loss are shown in Equations (1) and (2):  
\[L_{\text{VAE}_{1}}(E_{A},G_{A}) =\lambda_{0}\text{KL}\big{(}q_{1}(z_{A}|x)\|p_{\eta}(z)\big{)}- \lambda_{1}\mathbb{E}_{z_{A}\sim q_{1}(z_{A}|x)}\left[\log p_{G_{A}}(x|z_{A})\right] \tag{1}\] \[L_{\text{VAE}_{2}}(E_{B},G_{B}) =\lambda_{0}\text{KL}\big{(}q_{2}(z_{B}|y)\|p_{\eta}(z)\big{)}- \lambda_{1}\mathbb{E}_{z_{B}\sim q_{2}(z_{B}|y)}\left[\log p_{G_{B}}(y|z_{B})\right] \tag{2}\]  
Figure 3: The overall structure of the CSA module and the respective attention network structures. (**a**) CSA module. (**b**) Spatial attention module. (**c**) Channel attention module.  
The adversarial loss forces the generator to learn the mapping relationship between the two image domains. During training, the discriminator optimizes its ability to classify real and generated images correctly by maximizing the probability of correctly identifying real images and generated ones. The generator optimizes its image generation ability by minimizing the discriminator's probability of recognizing the generated images, making the generated images visually resemble the real images. The formulas for the adversarial loss are shown in Equations (3) and (4):  
\[L_{\text{GAN}_{1}}(E_{B},G_{A},D_{A}) =\lambda_{2}\mathbb{E}_{x\sim p(x)}[\log D_{A}(x)]+\lambda_{2} \mathbb{E}_{z_{B}\sim q_{2}(z_{B}|y)}[\log(1-D_{A}(G_{A}(z_{B})))] \tag{3}\] \[L_{\text{GAN}_{2}}(E_{A},G_{B},D_{B}) =\lambda_{2}\mathbb{E}_{y\sim p(y)}[\log D_{B}(y)]+\lambda_{2} \mathbb{E}_{z_{A}\sim q_{1}(z_{A}|x)}[\log(1-D_{B}(G_{B}(z_{A})))] \tag{4}\]  
The cycle consistency loss ensures that during the mapping between image domains, the generated image can return to the original domain and should be as close as possible to the original image. This loss helps preserve important features and structures of the original image, enhancing the quality and stability of image translation. The formulas for the cycle consistency loss are shown in Equations (5) and (6):  
\[L_{\text{cyc}_{1}}(E_{A},G_{A},E_{B},G_{B}) =\lambda_{3}\text{KL}\big{(}q_{1}(z_{A}|x)\|p_{\eta}(z)\big{)}+ \lambda_{3}\text{KL}\Big{(}q_{2}(z_{B}|x^{A\to B})\|p_{\eta}(z)\Big{)}\] \[-\lambda_{4}\mathbb{E}_{z_{B}\sim q_{2}(z_{B}|x^{A\to B})}[\log p_{G_{A} }(x|z_{B})] \tag{5}\] \[L_{\text{cyc}_{2}}(E_{B},G_{B},E_{A},G_{A}) =\lambda_{3}\text{KL}\big{(}q_{2}(z_{B}|y)\|p_{\eta}(z)\big{)}+ \lambda_{3}\text{KL}\Big{(}q_{1}(z_{A}|y^{B\to A})\|p_{\eta}(z)\Big{)}\] \[-\lambda_{4}\mathbb{E}_{z_{A}\sim q_{1}(z_{A}|y^{B\to A})}[\log p_{G_ {B}}(y|z_{A})] \tag{6}\]  
The formula for the total loss is obtained, as shown in Equation (7). The weight values for each part are \(\lambda_{0}=\lambda_{3}=0.01\), \(\lambda_{1}=\lambda_{4}=10\), and \(\lambda_{2}=1\).  
\[L_{\text{total}} =L_{\text{VAE}_{1}}(E_{A},G_{A})+L_{\text{VAE}_{2}}(E_{B},G_{B} )+L_{\text{GAN}_{1}}(E_{B},G_{A},D_{A})\] \[+L_{\text{GAN}_{2}}(E_{A},G_{B},D_{B})+L_{\text{cyc}_{1}}(E_{A},G _{A},E_{B},G_{B})+L_{\text{cyc}_{2}}(E_{B},G_{B},E_{A},G_{A}) \tag{7}\]