# DANet: A Semantic Segmentation Network for Remote Sensing of Roads Based on Dual-ASPP Structure
## 2 Materials and Methods
### Loss Function and Evaluation Metrics  
#### 2.4.1 Dice Loss  
Remote-sensing images present a significant intra-class imbalance issue with regard to road information. This information only represents a small portion of the image, while the majority of the image is background. This creates challenges in the process of semantic segmentation.  
When dealing with category imbalance problems, there are various options available at the loss level. One such option is _Dice loss_[31], which is based on the _Dice_ coefficient. The Dice coefficient is a loss function that assesses the similarity between two samples and gives values in the range of [0, 1], where higher values indicate higher similarity between the two samples. _Dice_ coefficient is shown in Equation (3):  
\[Dice=\frac{2|X\cap Y|}{|X|+|Y|}, \tag{3}\]  
Figure 5: Decoder per part of the network.  
The formula for the _Dice loss_ function can be expressed using the number of elements in the intersection between two sets, \(X\) and \(Y\), denoted by \(\mid X\cap Y\mid\). The number of elements in \(X\) and \(Y\) are denoted by \(\mid X\mid\) and \(\mid Y\mid\). The formula for the _Dice loss_ function is given in Equation (4):  
\[Dice\ loss=1-\frac{2|X\cap Y|}{|X|+|Y|}, \tag{4}\]  
And _Dice loss_ using the confusion matrix can, in turn, be expressed by the following Equation (5):  
\[Dice\ loss=1-\frac{2|X\cap Y|}{|X|+|Y|}=1-\frac{2\cdot TP}{2\cdot TP+FP+FN}, \tag{5}\]  
The structure of a binary confusion matrix is generally shown in Figure 6. As shown in Figure 6, _TP_ (true positive) refers to the number of positive samples that are correctly identified, while _TN_ (true negative) refers to the number of negative samples that are correctly identified. _FP_ (false positive) is the number of negative samples that are incorrectly classified as positive, and _FN_ (false negative) is the number of positive samples that are incorrectly classified as negative.  
In a binary classification problem, the true labeled image has only two pixel values of 0 and 1. As a result, it is possible to effectively nullify all the pixel values in the predicted segmented image that are not activated in the true labeled image. A higher confidence prediction will result in a higher Dice coefficient and a lower _Dice loss_, as shown in Equation (6):  
\[Dice\ loss=1-\frac{2\sum_{i=1}^{N}y_{i}\hat{y}}{\sum_{i=1}^{N}y_{i}+\sum_{i=1}^ {N}\hat{y}} \tag{6}\]  
In this context, the label value and predicted value of pixel \(i\) are denoted by \(y_{i}\) and \(\hat{y}\), respectively. The total number of pixel points is equal to the number of pixels in a single image multiplied by the batchsize, which is represented by \(N\).  
_Dice loss_ is more sensitive to segmentation tasks with small targets or highly unbalanced categories, and its calculation uses the ratio of intersection to concatenation to more accurately measure the similarity of prediction results to the true results. Because of its special calculation method compared with other cross-entropy loss functions, the Dice loss gradient is smoother and reduces oscillation and instability during the training process. Therefore, its application in remote sensing road semantic segmentation has greater advantages, which can directly optimize the segmentation performance and improve the accuracy and stability of the model.