# RAU-Net++: River Channel Extraction Methods for Remote Sensing Images of Cold and Arid Regions
## 3 Methods
### Weighted Loss Function  
A weighted loss function comprising cross-entropy (CE) loss, dice loss, focal loss, and Jaccard loss is employed.  
Cross-entropy loss is a commonly used loss function for multicategorization tasks. Cross-entropy loss examines each pixel and compares the difference between the model predictions and the true labels.  
The cross-entropy loss function for binary classification can be defined as Equation (7):  
\[L_{ce}=-\frac{1}{n}\left[\sum_{i=1}^{n}p_{i}\log q_{i}+(1-p_{i})\log(1-q_{i})\right] \tag{7}\]  
where \(n\) is the total number of samples, and \(p_{i}\) denotes the sample label, 1 for the positive class, and 0 for the negative class. \(q_{i}\) denotes the probability that the sample is predicted to be a positive class after training.  
In order to give more attention to hard-to-classify samples during the training process, focus loss uses a dynamic factor to adjust the weight of the difficult-to-classify and easy-to-classify samples based on the cross-entropy loss. When a sample is classified incorrectly, the probability of the correct category will be tiny, so the dynamic factor tends to 1, the loss does not change too much, and when the probability of the correct category is gradually increased tends to 1, the dynamic factor will tend to zero, indicating that the samples are easy to discriminate. Meanwhile, in the modulation factor, when \(\gamma\) is 0, the focus loss is equivalent to the cross-entropy loss, and the modulation factor will increase with \(\gamma\). The formula makes the hard-to-classify samples in the model more focalized by using a function that measures the contribution of difficult-to-classify samples to the total loss.  
Focal loss can be defined as Equation (8):  
\[L_{fac}=-\frac{1}{n}\left[\sum_{i=1}^{n}\left(\alpha(1-q_{i})^{\gamma}p_{i} \log q_{i}+(1-\alpha)q_{i}{}^{\gamma}(1-p_{i})\log(1-q_{i})\right)\right] \tag{8}\]  
where \(\alpha\) is the dynamic factor, \((1-q_{i})^{\gamma}\) is the modulation factor added to cross-entropy loss, and the adjustable hyperparameter \(\gamma\) can be used to highlight the contribution of a few samples. We set the dynamic factor \(\alpha\) to the default value of 0.25 and the adjustable hyperparameter \(\gamma\) to the default value of 2 [33].  
Dice loss is suitable for the scene of positive and negative sample imbalance. It can optimize the problem that the river occupies a small proportion in images, and the training focuses more on the mining of the river region. In contrast, the cross-entropy loss will deal with the positive and negative samples equitably, and when there is a small proportion of positive samples, it will be swamped by more negative samples.  
The dice loss function can be defined as Equation (9):  
\[L_{dice}=1-\frac{2\sum_{i=1}^{n}p_{i}q_{i}}{\sum_{i=1}^{n}p_{i}+\sum_{i=1}^{n} q_{i}} \tag{9}\]  
where \(n\) represents the total number of samples; \(p_{i}\) is the label of the samples, with 1 for the positive class and 0 for the negative class, and \(q_{i}\) is the predicted value.  
Jaccard loss, also known as intersection over union (IoU) loss, is commonly used in semantic segmentation tasks to evaluate the similarity between the segmentation results of the model and the real segmentation labels and to measure the similarity and difference between two samples by calculating the degree of overlap between the two sets.  
Jaccard loss can be defined as Equation (10):  
\[L_{Jaccard}=1-\log\left[\frac{1}{n}\sum_{i=1}^{n}\frac{p_{i}q_{i}}{(p_{i}+q_{i})- p_{i}q_{i}}\right] \tag{10}\]  
where \(n\) represents the total number of samples, \(p_{i}\) denotes the label of the sample, and \(q_{i}\) is the network prediction value.  
We use a weighted combination of CE loss, dice loss, focal loss, and Jaccard loss, which can effectively segment the boundary of the river at the pixel level.  
The final weighted loss is defined as follows:  
\[L=AL_{ce}+BL_{dice}+CL_{foc}+DL_{Jaccard} \tag{11}\]  
where \(A\), \(B\), \(C\), and \(D\) are the weight parameters of the four loss functions, respectively.