# Class Imbalanced Medical Image Classification Based on Semi-Supervised Federated Learning
## 2 Materials and Methods
### Pseudo-Label Construction  
In the construction of semi-supervised loss, we borrowed the pseudo-label construction framework of ReMixMatch [24]. However, medical images require higher stability of the model in the classification task compared to natural images, because the classification of disease recognition often depends on local pixel points. If the model is not strong against interference, the model obtains more ambiguous label information when the unlabeled images are less informative or when the image quality is poor. To address this problem, we present the stable selector pseudo-label construction method, which aims to further improve the stability of the network for unlabeled images by screening more stable samples of unlabeled images to generate pseudo-labels with sufficient label information. The stability selector estimates the predictive stability of the model for unlabeled samples by calculating the difference in probability distribution between the features of the unlabeled augmented samples and the perturbed adversarial samples after going through the model. The process is as follows: we pass a batch of unlabeled weakly enhanced data \(x_{u}\) through the pre-training network \(f_{i}(\theta)\) to obtain the general label prediction \(y_{i}^{\mu}\). At the same time, we pass the added perturbed unlabeled adversarial sample \(d(x_{u})\) into the  
Figure 4: The training method in the local client network and the composition of the class-balanced auxiliary. network to obtain the perturbed label prediction \(d\left(y_{i}^{u}\right)\). Finally, we input both \(y_{i}^{u}\) and \(d\left(y_{i}^{u}\right)\) into the generator to obtain the adversarial perturbation vector \(r_{i}^{u}\). \(r_{i}^{u}\) is denoted as  
\[r_{i}^{u}=\underset{K}{arg\underset{K}{\text{min}}}Div(y_{i}^{u},d(y_{i}^{u})) \tag{4}\]  
where \(K\) is the maximum selection hyperparameter and \(Div(\cdot)\) is a function of the scatter between the predicted labels of the augmented samples and the perturbed adversarial samples. In our experiments we used the KL scatter. However, the above selector has a problem, because the selector uses randomly generated perturbation terms in the interval of \(\pm\)0.5, because when the perturbation is 0, the gradient of \(Div(\cdot)\) with respect to the perturbation is constant 0. At this time, the selector is not able to improve the network stability. For this problem we use a sample once for the network training scatter, with respect to the average gradient of the perturbation to approximate the perturbation, which is represented in the experiment as follows. \[\overline{g}=\
abla_{d(x_{u})}Div(y_{i}^{u},d(y_{i}^{u})) \tag{5}\]  
\[r_{i}^{u}=\underset{K}{arg\underset{K}{\text{min}}}Div(f_{i}(p(\eta|x_{u}), \theta);f_{i}(p(\eta|\overline{g}),\theta)) \tag{6}\]  
where \(\
abla\) is the average gradient operation. Finally, we selected the predicted labels corresponding to the first \(K\)-minimum scatter to participate in the pseudo-label construction. Then we introduced the distribution alignment proposed by ReMixMatch [24], which makes the predicted labels fit the class ratio to further overcome the class imbalance problem; The semi-supervised pseudo-label construction process is shown in Figure 5. First, we designate the K stable predicted pseudo-labels screened as the prediction \(q\) of one batch of unlabeled data and define the edge class distribution as \(Y_{dist}=\xi\times\left(N_{D_{L}}/N_{D_{U}}\right)\). Then, the K unlabeled data after each round of screening are input into the network to get the label prediction and are stored. When the next round of prediction is finished, it will be averaged with the previous prediction, and when the 129 th round of prediction is finished, it will replace the prediction of the 1 st round, and the average of each round. The prediction after each round is averaged so that it is the distribution of unlabeled data predictions \(\overline{Y}_{dist}\).