# Single Image Reflection Removal Based on Residual Attention Mechanism
## 3 Proposed Method
### Loss Function
The adversarial loss in our reflection removal task is defined as:  
\[\mathcal{L}_{adv}=\sum_{\mathcal{T}\in\mathcal{D}}-\log D\Big{(}\mathbb{T}, \hat{\mathbb{T}}\Big{)} \tag{6}\]  
**Reconstruction Loss:** For the predicted transmission and reflection layers, we generate reflection images using an image synthesis operation. Then, the reconstructed loss function is constructed from the composed picture and the original reflection image. The experimental results show that the reconstructed loss works well. The experimental results demonstrate that the rebuilt loss is effective. One possible explanation is that the two branch networks share the same network topology and have complementary goals. With the same network structure, they could be simultaneously either under-trained or over-trained, so the error of the reconstruction loss will be doubled if both sub-networks are in an under-trained or over-trained state. Therefore, the use of reconstruction loss in our task minimizes the error in both branch networks to ensure that the predicted reflection image (recombination of the transmission and reflection layers) is similar to the original input. We use the mean least squared error (MSE) to calculate the reconstruction loss, and the perceptual distance between the reconstructed image and the input image is defined as:  
\[\mathcal{L}_{res}=\sum_{\mathcal{T}\in\mathcal{D}}\sum_{l=1}^{N}\mathcal{L}_{MSE }\Big{(}\mathrm{I},\hat{\mathrm{I}}_{\mathrm{t}}\Big{)} \tag{7}\]  
**Multi-scale Perceptual Loss:** To extract features for perceptual loss, we utilize a pre-trained VGG-19 network [35]. The multi-scale perceptual loss collects features from multiple decoder levels and inputs them into convolution layers to generate outputs of various resolutions, and then the distance between the generated image and real image is calculated. We can gain additional contextual information from multiple layers of input by employing this loss in training. The loss function is defined as:  
\[\mathcal{L}_{MP}=\sum_{\mathcal{T}\in\mathcal{D}}\sum_{j=1,3,5}^{N}\gamma^{ \mathrm{j}}\mathcal{L}_{VGG}\bigg{(}\mathrm{T},\hat{\mathrm{T}}_{\mathrm{j}} \bigg{)} \tag{8}\]  
where \(\mathcal{L}_{\mathrm{VGG}}\) represents the loss between VGG features, \(\hat{\mathrm{T}}_{\mathrm{j}}\) represents the output of the last j layer at time step N, and \(\mathrm{T}_{\mathrm{j}}\) represents the ground truth value at the same scale as \(\hat{\mathrm{T}}_{\mathrm{j}}\). We set \(\gamma^{1}\)=1, \(\gamma^{3}\)=0.8, and \(\gamma^{5}\)=0.6, respectively. In the VGG-19 network, we compare the features of the conv1_2 and conv2_2 layers. **Total Loss:** In general, the total loss function for our network training is defined as:  
\[\mathcal{L}=\lambda_{1}\mathcal{L}_{\mathrm{mix}}+\ \lambda_{2}\mathcal{L}_{ \mathrm{adv}}+\ \lambda_{3}\mathcal{L}_{\mathrm{res}}+\ \lambda_{4}\mathcal{L}_{\mathrm{MP}} \tag{9}\]  
Experimental results showed that mixture loss objective functions play a key role in obtaining high quality results. Therefore, the weights are set to 2. Reconstruction loss is beneficial in guiding the two sub-networks to work together, allowing the generation of visually better transmission images, so the weight parameter of the reconstruction loss function is also set to 2. In addition, the experimentally verified adversarial loss and perceptual loss are set to 0.25 and 0.1, respectively. Therefore, the weights of each loss in the experiment are set as follows: \(\lambda_{1}=2\), \(\lambda_{2}=0.25\), \(\lambda_{3}=2\), and \(\lambda_{4}=0.01\).