## 3 Methods
### Loss Function  
To mitigate the influence of imbalanced datasets on the algorithm's performance, MLNet incorporates a novel loss function with tailored lesion weights. This loss function assigns higher weights to lesion regions and lower weights to non-lesion regions. By doing so, MLNet can effectively handle imbalanced datasets, prioritize the accurate segmentation of lesions, and reduce the impact of data imbalance on the final segmentation results. Specifically, this paper employs the Tversky loss function [24] and binary cross-entropy loss function (BCE loss) [25] to alleviate the negative impact of highly imbalanced datasets on the network during DR lesion segmentation tasks.  
The traditional Dice loss function treats \(FP\) (false positives) and \(FN\) (false negatives) equally [26]. However, in the case of DR datasets, there is a significant class imbalance, and the size of lesions is typically small compared to the background. This creates a challenge where the impact of \(FN\) (missing lesions) is more critical than that of \(FP\) (incorrectly identified non-lesion areas). To address this issue, the Tversky index is incorporated into the Dice loss function to create the Tversky loss function. The Tversky index is a variant of the Dice coefficient that allows for the adjustment of the relative importance of \(FP\) and \(FN\). Specifically, the Tversky loss function assigns a higher weight to \(FN\) compared to \(FP\), acknowledging the importance of correctly identifying and capturing the small lesions  
Figure 3: Lesion Perception Block (LPB) and Lesion Attention Head (LAH).  
prevalent in DR images. By prioritizing the reduction in \(FN\), the Tversky loss function helps mitigate the risk of overlooking critical lesions, leading to more reliable and clinically meaningful segmentation outcomes. The weights of \(FP\) and \(FN\) are coordinated using \(\alpha\) and \(\beta\), as shown below:  
\[\mathcal{L}_{Tversky}=1-\frac{TP}{TP+\alpha FP+\beta FN} \tag{6}\]  
where, \(\alpha\) set to 0.1 and \(\beta\) set to 0.9, this parameter configuration increases the network's sensitivity to lesions in imbalanced datasets.  
The binary cross-entropy loss function utilizes the binary cross-entropy formula to compare the predicted probabilities with the ground truth values. It utilizes the binary cross-entropy formula to quantitatively measure the dissimilarity between the predicted probabilities and the corresponding ground truth values. This loss function serves as a key optimization objective in training models to accurately segment the lesion parts from fundus images. It can be expressed as follows:  
\[\mathcal{L}_{BCE}=-[y\times\log(p)+(1-y)\times\log(1-p)] \tag{7}\]  
where \(y\) is the ground truth value; \(p\) is the predicted probability.  
Finally, the total loss function \(\mathcal{L}_{S}\) is expressed as follows:  
\[\mathcal{L}_{S}=\mathcal{L}_{Tversky}+\lambda\mathcal{L}_{BCE} \tag{8}\]  
where \(\lambda\) is the balance coefficient of the loss function, which is used to balance the influence of the two loss functions on the network's training optimization direction and is generally set to 0.5. In addition, considering that different lesions have different segmentation difficulties, inspired by RTNet [9], this paper assigns weights of [1; 1; 5; 10] to HEs, EXs, SEs, and MAs to ensure the overall segmentation accuracy. Moreover, the determination of weights was guided by comprehensive experimentation. This work conducted extensive experiments to identify optimal weight assignments that would enhance the overall segmentation accuracy.