## 3 Methodology
### Loss Function
#### 3.9.2 Unsupervised Loss  
Due to technical limitations, It is challenging to acquire the clean background image matching pictures of actual rain images, and it is even tougher to accurately extract the rainwater layer from real rainwater images. Therefore, a parameterized distribution is needed to represent the random distribution of real rain streaks. Generally, if the model is sufficiently complex and the model coefficients are set properly, a Gaussian mixture model (GMM) can represent any data distribution. Since rain occurs at various separations from the camera and the rain streaks are typically formed by raindrops of varying sizes and intensities, the effects of these raindrops at different positions may cause the observed rain streaks to exhibit a multi-modal characteristic. The Gaussian mixture model (GMM) is well-suited to capture this multi-modal distribution and represents the superposition of various raindrop features. Thus, the rain streaks are approximated using a GMM, and the corresponding expression is as follows:  
\[P_{r}\sim\sum_{k=1}^{K}\pi_{k}N(P_{r}|\mu_{rk},\Sigma_{rk}) \tag{21}\]  
where \(\pi_{k}\) represents the Gaussian mixture coefficients, and \(P_{r}\) represents the network output derained picture and the remnant of the actual rainwater picture, which are used together to estimate the actual rain streak by computing their difference. \(\mu_{rk}\) and \(\Sigma_{rk}\) represent the mean and variance of each Gaussian distribution in the GMM, respectively, \(K\) indicates the quantity of Gaussian distributions, and \(N\) is the quantity of real rainwater pictures.  
\[L_{GMM}=\sum_{k=1}^{K}\pi_{k}N(P_{r}|0,\Sigma_{rk}) \tag{22}\]  
For convenience, the mean of the Gaussian process is set to 0, and the expression is given in Equation (22) above.  
Furthermore, the expectation maximization (EM) algorithm is implemented to solve this loss function, representing the actual distribution of rain streaks. The target function is constructed for the unsupervised part, and its gradient is backpropagated to adjust the network parameters. Thus, the Gaussian mixture model applied to real rain streaks can be represented as:  
\[L_{GMM}=\sum_{k=1}^{K}\pi_{k}N(R_{\rm ip}-R_{op}|0,\Sigma_{rk}) \tag{23}\]  
where \(\pi_{k}\) represents the Gaussian mixture coefficients, \(K\) represents the number of Gaussian distributions, \(R_{ip}\) and \(R_{op}\) represent the input real rain image and the real derained image output by the network, respectively.  
Since the Gaussian mixture model can represent any continuous distribution, to greater fit the actual rainwater pattern allocation, during training, the Kullback-Leibler (KL) differences between the Gaussian distribution-acquired knowledge from artificial rain streaks and the GMM learned from real rain streaks is reduced. This allows the synthetic rain to transfer to real rain. In this process, since KL divergence is asymmetric, this chapter first computes the KL variance in the Gaussian allocation of the Gaussian mixing model of actual rain streaks and artificial rain streaks for each component, and then selects the Gaussian process with the smallest KL divergence as the real rain model, ensuring that the GMM learned from the real data has one component resembling rain, which can be represented as:  
\[D_{KL}(G_{s}||\big{|}GMM_{r})=\min D_{KL}(G_{s}\big{|}\big{|}\big{|}G_{r}^{k}) \tag{24}\]where \(G_{s}\) represents the Gaussian distribution extracted from the synthetic rain layer, \(GMM_{r}\) represents the Gaussian mixture model extracted from the real rain streaks, and \(G_{r}^{k}\) represents the \(k\) component of the Gaussian mixture model.