# Federated Pseudo-Sample Clustering Algorithm:
## 4 Lpfl-Gd
### Core Idea and Algorithm Flow  
The method proposed in this paper is to deal with the problem that personalized federated learning cannot adapt to the heterogeneous label environment. The central idea is to replace the sharing method of random sampling by screening samples and correcting labels. Therefore, it is necessary to use local data \(D_{i}\) to train the local model \(M_{i}\) and generator \(G_{i}\) to obtain new parameters \(w_{i}\) and \(g_{i}\). After local training is completed, the generator \(G_{i}\) needs to generate a sample set \(Dr_{i}\) containing local features instead of the local dataset and upload it to the central server. The client part of the federated training round is complete. After all the samples are uploaded by the client, the central server merges all the samples into a new collection \(Cd\), \(Cd=\sum\limits_{i=1}^{N}Dr_{i}\). Then, the most critical part of this paper is to cluster the collection \(Cd\) using the DBSCAN clustering algorithm, divide the \(Cd\) into several clusters, screen the clusters corresponding to the local dataset for each client, and perform label correction on the whole cluster according to the labels of the local dataset, and finally obtain the sample set \(Cd_{i}\) for the client to expand the dataset. The \(Cd_{i}\) is delivered to the corresponding client and merged with the local dataset \(Cd_{i}\). At this point, the first round of federal training is completed, and subsequent training repeats the first round of federal training until the entire federal training is completed.  
As shown in Figure 1, we outline the overall steps and process of the proposed approach.  
\begin{table}
\begin{tabular}{l l} \hline \hline
**Parameter** & **Meaning** \\ \hline \(M_{i}\) & The local model of the \(i\)-th client \\ \(w_{i}\) & The model parameters of the local model \(M_{i}\) \\ \(G_{i}\) & The generator model of the \(i\)-th client \\ \(g_{i}\) & The model parameters of the generator model \(G_{i}\) \\ \(D_{i}\) & The local dataset of the \(i\)-th client \\ \(Dr_{i}\) & The new sample set generated by the generator of the \(i\)-th client \\ \(Cd\) & The set of samples uploaded by all clients \\ \(Cd_{i}\) & The subset of samples selected by the central server for the \(i\)-th client \\ \hline \hline \end{tabular}
\end{table}
Table 2: System parameters.  
1. Train the generator and classifier using the local dataset to generate a new sample set and then upload the sample set to the central server;
2. After collecting the sample sets uploaded by all clients, the central server performs clustering on all samples;
3. After clustering is completed, shared samples are selected for each client and the sample labels are corrected;
4. The local client receives the sample set sent by the central server, merges it with its own dataset, and continues training the local model. Then, steps 1 to 4 are repeated.  
LPFL-GD is a label-personalized federated learning method and its algorithmic process is shown in Algorithm 1.  
```
0:\(\{M_{i}(w_{i}),G_{i}(g_{i}),D_{i}|1\leq i\leq N\}\)
0:\(\{w_{i}|1\leq i\leq N\}\)
1:for each round \(r=1,\ldots,R\)do
2:for each client \(C_{i}\) in parallel do
3: Update the parameters \(w_{i}\), \(g_{i}\) by training \(M_{i}\) and \(G_{i}\) on \(D_{i}\).
4: Generate sample set \(D_{ri}\) by \(G_{i}\).
5: Upload the \(D_{ri}\) to the central server.
6:endfor
7:for each client \(C_{i}\) in parallel do
8: Merge the sample set \(D_{ri}\) into \(Cd\).
9:endfor
10: Cluster the sample set \(Cd\) using the DNSCAN algorithm.
11:for each client \(C_{i}\) in parallel do
12: Select randomly a subset of samples \(Cd_{i}\) from \(Cd\).
13: Correct the labels in \(Cd_{i}\).
14:endfor
15:for each client \(C_{i}\) in parallel do
16: Merge the sample set \(Cd_{i}\), sent by the central server, into \(D_{i}\).
17: Update the parameters \(w_{i}\), \(g_{i}\) by training \(M_{i}\) and \(G_{i}\) on the new \(D_{i}\).
18:endfor
19:endfor
```  
**Algorithm 1** LPFL-GD