# Single Image Reflection Removal Based on Residual Attention Mechanism
## 3 Proposed Method
### Loss Function  
In this section, we present the loss functions utilized in the RABRRN network training. Let T and R be the ground truth of the transmission layer and reflection layer, respectively, and the predicted transmission layer and reflection layer at iteration t are denoted as \(\hat{\text{T}}_{\text{t}}\) and \(\hat{\text{R}}_{\text{t}}\), respectively. **Pixel Loss and Structural Similarity Loss**: Pixel loss is used to penalize pixel-level differences between T and \(\hat{\text{T}}_{\text{t}}\). The objective is to reduce the error between the generated transmission layer and the ground truth. Since the L\({}_{1}\) loss has a stable gradient for whatever input value does not lead to the gradient explosion problem, we utilize the \(L_{1}\) loss function  
Figure 4: ConvLSTM structure. to calculate the pixel loss as a more robust solution. Summing up the reasons, our pixel loss is summarized as:  
\[\mathcal{L}_{pixel}=\sum_{\mathcal{T}\in\mathcal{D}}\sum_{t=1}^{N}\theta^{N-t} \mathcal{L}_{1}\Big{(}\mathbb{T},\hat{\mathbb{T}}_{t}\Big{)} \tag{2}\]  
in which \(\theta\) is defined at 0.85. [PERSON] [33] proposed that in image restoration, the combination of SSIM (Structural Similarity Index Measure) [34] loss and \(L_{1}\) loss is better than \(L_{2}\) loss. Because of the computational simplicity, most of the previous research used only pixel loss, but it may lead to the generation of blurred images because it is different from the human visual perception of natural images. Therefore, to provide more natural visual results, we took the human visual perception of natural images into consideration when designing the loss function. In our reflection removal task, the SSIM is used to calculate the degree of similarity between the estimated \(\mathbb{T}\) and \(\hat{\mathbb{T}}_{t}\) and their associated ground truth. The SSIM is described as:  
\[\text{SSIM}(\mathbb{T},\hat{\mathbb{T}}_{t})=\frac{(2\mu_{\mathbb{T}}\mu_{ \hat{\mathbb{T}}_{t}}+C_{1})(2\sigma_{\hat{\mathbb{T}}_{t}}+C_{2})}{(\mu_{ \mathbb{T}}^{2}+\mu_{\hat{\mathbb{T}}_{t}}^{2}+C_{1})(\sigma_{\hat{\mathbb{T} }}^{2}+\sigma_{\hat{\mathbb{T}}_{t}}^{2}+C_{2})} \tag{3}\]  
where \(\mu_{\mathbb{T}}\) and \(\mu_{\hat{\mathbb{T}}_{t}}\) are the means of \(\mathbb{T}\) and \(\hat{\mathbb{T}}_{t}\), \(\sigma_{\hat{\mathbb{T}}}\) and \(\sigma_{\hat{\mathbb{T}}_{t}}\) are the variances in \(\mathbb{T}\) and \(\hat{\mathbb{T}}_{t}\), and \(\sigma_{\hat{\mathbb{T}}_{t}}\) is their corresponding covariances. SSIM measures the similarity between the real and generated images in three dimensions: contrast, luminance, and structure. Therefore, similar to [27], which also adopts \(\mathcal{L}_{t}^{\text{SSIM}}=1-\text{SSIM}(\mathbb{T},\hat{\mathbb{T}}_{t})\) as the loss term in each iteration \(t\), the \(\mathcal{L}_{\text{SSIM}}\) used in this paper is formulated as:  
\[\mathcal{L}_{SSIM}=\sum_{\mathcal{T}\in\mathcal{D}}\sum_{t=1}^{N}\theta^{N-t} \mathcal{L}_{t}^{\text{SSIM}} \tag{4}\]  
in which \(\theta\) is defined at the same value as \(\mathcal{L}_{pixel}\). The mixture of pixel loss and SSIM loss is defined as follows:  
\[\mathcal{L}_{mix}=\beta\mathcal{L}_{\text{SSIM}}+(1-\beta)\mathcal{L}_{pixel} \tag{5}\]  
in which the \(\beta\) set value is 0.84 according to [33]. **Adversarial Loss:** Noticeably, MSE loss networks based on simple convolutional neural networks tend to produce images with unnatural and blurred backgrounds because the image generated with this loss function is the average of several natural solutions. In order to avoid this problem, [PERSON] proposed adversarial loss [31]. Adversarial loss is used to encourage the generative network to output images that match natural image distribution. The occurrence of color bias and blurred images is a common problem in reflection removal tasks. Therefore, in our approach, applying adversarial loss can better guide the generation of more natural images.