Privacy protection federal learning performance optimization method under Non-IID data distribution
By employing client-side dynamic clustering, intra-cluster contrastive learning, and adaptive differential privacy techniques, this approach addresses the issues of decreased model aggregation performance and privacy protection in federated learning under Non-IID data distributions. It enhances the model's robustness and generalization ability, achieving an optimized balance between privacy protection and performance.
Patent Information
- Application Number
- CN202510952087.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-10
- Publication Date
- 2025-11-18
AI Technical Summary
Under Non-IID data distribution, traditional federated learning methods face challenges such as decreased model aggregation performance, limited model generalization ability, and the balance between privacy protection and model performance. Existing solutions have failed to effectively address the global challenges of data heterogeneity and privacy protection.
Employing client-side dynamic clustering, intra-cluster contrastive learning, regularization mechanisms, and adaptive differential privacy techniques, clustering is performed using Jensen-Shannon divergence. A cosine similarity loss function is constructed, and L2 norm regularization and Shapley value pruning threshold optimization are combined to improve model robustness and generalization ability while also protecting privacy.
It improves the adaptability and robustness of federated learning in heterogeneous data environments, enhances the generalization ability of the model, optimizes training efficiency while satisfying privacy protection, and solves the dilemma of gradient divergence, overfitting, and the trade-off between privacy protection and model accuracy.
Smart Images

Figure CN120975188A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of information security research, and particularly relates to a privacy protection federated learning performance optimization method under Non-IID data distribution. BACKGROUND
[0002] With the development of artificial intelligence and distributed computing, federated learning (FL) as a decentralized distributed machine learning framework, has shown broad application prospects in privacy protection and data security. FL allows multiple clients to train models locally and only share model updates without directly transmitting raw data, thus providing an effective privacy protection solution in data security limited scenarios such as medical, financial, Internet of Things, etc.
[0003] However, in practical applications, the data of clients usually presents Non-IID characteristics, that is, the data distribution of different clients has significant differences, such as uneven label distribution, feature space heterogeneity, etc. This data heterogeneity leads to the following challenges for traditional federated learning methods:
[0004] 1. Model aggregation performance decline: Existing FL frameworks usually use methods such as FedAvg to aggregate models of each client, but Non-IID data leads to inconsistent gradient update directions of local model parameters, thus affecting the convergence stability of the global model.
[0005] 2. Limited model generalization ability: Due to different data distributions of each client, the global model may be more inclined to certain specific client data patterns, leading to uneven performance of the model on different clients.
[0006] 3. Balance between privacy protection and model performance: Differential privacy (DP) and other privacy protection technologies are widely used in FL, but direct noise addition to model parameters may further exacerbate the impact of Non-IID data on model training, making it difficult for the global model to maintain high performance while ensuring privacy security.
[0007] Although some optimization solutions have been proposed by researchers in recent years to address the above problems, these methods often focus on a single optimization direction and lack overall consideration of the performance and privacy protection of federated learning. For example, one class of methods mainly focuses on improving the convergence performance of the model, and alleviates data heterogeneity by improving the model aggregation strategy or introducing other machine learning algorithms. However, these methods often do not fully consider privacy protection requirements, which may lead to data leakage risks, thereby weakening the security of federated learning. On the other hand, some privacy protection solutions (such as optimization methods based on differential privacy) can effectively reduce the risk of data leakage, but cause great loss to the model performance in the noise addition process, thereby affecting the accuracy and generalization ability of the global model. Therefore, the existing solutions still have limitations in balancing data heterogeneity and privacy protection, and it is difficult to systematically solve the multiple challenges of federated learning in a data heterogeneous environment as a whole. SUMMARY
[0008] The purpose of the present application is to provide a privacy protection federated learning performance optimization method under Non-IID data distribution, which combines key technologies such as client dynamic clustering, intra-cluster contrast learning, regularization mechanism, and adaptive differential privacy, aiming to improve the adaptability of federated learning in a data heterogeneous environment, enhance the robustness and generalization ability of the model, and balance privacy protection and training efficiency.
[0009] To achieve the above technical purposes and effects, the present application is implemented by the following technical solutions:
[0010] A privacy protection federated learning performance optimization method under Non-IID data distribution, comprising the following steps:
[0011] S1: Client dynamic clustering: based on the data distribution characteristics of the client (including data labels and their statistical information), a hierarchical clustering algorithm based on Jensen-Shannon divergence (JS divergence) is used to dynamically cluster the clients;
[0012] S2: Intra-cluster contrast learning: within the cluster generated by clustering, a contrast loss function based on cosine similarity is constructed to maximize the similarity of models of clients in the same cluster and minimize the similarity of models of clients in different clusters;
[0013] S3: Regularization mechanism: the deviation of local model parameters and global model parameters is constrained by an L2 norm regularization term;
[0014] S4: Adaptive differential privacy: based on the Shapley value, the contribution of the client is dynamically evaluated, and the clipping threshold is adjusted according to the contribution, and noise satisfying the differential privacy budget is added in the parameter transmission.
[0015] Further, the step S1 specifically comprises the following sub-steps:
[0016] S1.1: Let the dataset of client i be D i , which contains N i samples, each with a label belonging to the set C = {c1, c2, …, c k}; Client applies Principal Component Analysis (PCA) to its local data features, reducing the original high-dimensional features to a lower dimension to retain the main feature information, obtaining the reduced data features
[0017] S1.2: Count the frequency of each label c j ∈ C in the dataset where n i,j is the number of samples in D j with label c i . Combine the frequencies of all labels into a label distribution vector f i = [f i,1 f i,2 ,…, f i,k ], and normalize it to a probability distribution to fully reflect the distribution characteristics of the data labels;
[0018] S1.3: Calculate the mean μ i and variance of the data, specifically defined as:
[0019]
[0020] where x is a sample vector in the dataset D i , and N i is the total number of samples of client i.
[0021] Finally, the normalized label distribution f i , mean μ i and variance are concatenated into a feature vector This feature vector comprehensively reflects the data distribution characteristics of client i;
[0022] S1.4: Introduce the Jensen-Shannon divergence (JS divergence). Let the feature vectors of client i and client j be and respectively, where f i and f j are the normalized label distributions of the two clients. JS divergence is used to measure the similarity of the data distribution of client i and j, and its calculation formula is:
[0023]
[0024] where, is v i and v j The average distribution of the mean distribution, KL(P||Q) represents the Kullback-Leibler divergence between distribution P and Q:
[0025]
[0026] Where x is the possible value in the sample space, P(x) and Q(x) are the probability of distribution P and Q at sample x;
[0027] The value range of JS divergence is [0, 1], and the smaller the value is, the more similar the two distributions are. For subsequent processing, we convert the JS divergence into similarity S i,j , defined as:
[0028] S i,j = 1-JS(v i ,v j )4)
[0029] Where the value range of S i,j is [0, 1], and the closer the value is to 1, the more similar the data distribution of clients i and j is. By calculating the JS divergence of all client pairs (i, j), a similarity matrix S is generated, which is in the form of:
[0030]
[0031] Where n represents the total number of clients;
[0032] S1.5: After obtaining the client similarity matrix S, the center server adopts a dynamic hierarchical clustering algorithm to classify clients with similar data distribution into the same cluster; selects a clustering linkage method to dynamically determine the number of clusters, and outputs the clustering result.
[0033] Further, the step S1.5 includes the following sub-steps:
[0034] S1.5.1: Initialization: each client is initially a separate cluster. Let there be M clients, then the initial number of clusters is M, and each cluster contains only one client.
[0035] S1.5.2: Select clustering linkage method: in hierarchical clustering, different linkage methods will affect the formation of clusters, and the linkage strategies include:
[0036] Average linkage: the similarity between clusters is the average of all point pairs.
[0037] Complete linkage: the minimum similarity between clusters is the minimum value of all point pairs.
[0038] Single linkage: similarity between clusters is the maximum similarity between any pair of points.
[0039] S1.5.3: Dynamically determine the number of clusters: to avoid the negative effects of over-aggregation or over-separation, dynamically adjust the number of clusters by evaluating the quality of clusters.
[0040] S1.5.4: Output clustering results: when the clustering ends, the system returns the following results: the optimal number of clusters K and the corresponding silhouette coefficient; the clustering label C of each client i , where C i ∈{1,2,…,K}.
[0041] Further, the step S1.5.3 specifically includes:
[0042] Calculate the silhouette coefficient: the silhouette coefficient is used to evaluate the consistency of data within the cluster and the separation of data between clusters, and is defined as:
[0043]
[0044] Where a is the average similarity of a certain client with other clients within its cluster, and b is the average similarity of the client with the nearest neighbor cluster. The value range of the silhouette coefficient is [-1, 1], and the closer the value is to 1, the better the clustering effect.
[0045] Adjust the clustering parameters: by limiting the maximum number of clusters K Max and selecting the optimal linkage method, avoid high computational complexity while optimizing the clustering effect. When the current value of the silhouette coefficient is better than the previous best value, update the optimal number of clusters K and the corresponding clustering label.
[0046] Further, the step S2 specifically includes the following sub-steps:
[0047] In the obtained clustering results, let cluster C k contain N k clients, and the local model of each client is represented as ω i . For cluster C k , the models (ω i , ω j ) of any two in-cluster clients are regarded as positive sample pairs, and the goal is to maximize the similarity of their feature representations to improve intra-cluster consistency; at the same time, the client model from other clusters C' k is regarded as a negative sample pair, and the goal is to reduce its similarity with cluster C ksimilarity of inner models to ensure the separability between different clusters. To measure the similarity between models, the cosine similarity function is adopted, which is defined as:
[0048]
[0049] When cos(ω i ,ω j ) approaches 1, it means that the features of two models are highly similar; when cos(ω i ,ω j ) approaches -1, it means that the features of two models are significantly different.
[0050] Based on the above definition, a contrastive loss function is further constructed to optimize the relationship between the models of clients in the same cluster:
[0051]
[0052] where y = 1 means that ω i and ω j belong to the same cluster as a positive sample pair; y = -1 means that ω i and ω j do not belong to the same cluster as a negative sample pair.
[0053] To achieve the optimization goal of intra-cluster contrastive learning, the method minimizes the contrastive loss of positive sample pairs and maximizes the separability of negative sample pairs in the cluster C k , and the specific objective function is defined as:
[0054]
[0055] where P k is the set of intra-cluster positive sample pairs; N k is the set of inter-cluster negative sample pairs; τ is a temperature parameter used to adjust the sensitivity of the loss function.
[0056] Finally, the overall goal of intra-cluster contrastive learning is obtained by weighted average calculation of the loss of all clusters:
[0057]
[0058] Further, the regularization mechanism in step S3 specifically includes:
[0059] In the local model updating stage, a regularization term is introduced to constrain the difference between the local model parameters and the global model parameters, which is defined as:
[0060]
[0061] where θ iθi represents the local model parameter vector of client i globe θ represents the global model parameter vector of the current round, λ is the regularization intensity coefficient, is the square of the L2 norm. This regularization term enhances the robustness of the global model by minimizing the distance between the local model and the global model.
[0062] Finally, combining intra-cluster contrastive learning and regularization mechanism, the local learning objective of each client is defined by the following formula:
[0063] l loss = l sup + λ1l con + λ2l prox (12)
[0064] where l sup is the loss function of the local supervised learning task of client i, l con is the intra-cluster contrastive learning loss defined by formula (10), l prox is the regularization term defined by formula (11). λ1 and λ2 control the relative weight of the contrastive learning loss term and the regularization term in the total loss, respectively.
[0065] Further, the step S4 specifically includes the following sub-steps:
[0066] S4.1: Shapley value calculation: Let the client set be divided into G groups, and the client set of each group is The calculation of Shapley value within each group only needs to consider the contribution of the subset within the group, which is given by the following formula:
[0067]
[0068] where represents the set of all possible permutations of clients within group g, S π,i represents the subset before client i joins in permutation π, and v(S) is the model accuracy after the subset S participates in global model training.
[0069] S4.2: Dynamic adjustment of clipping threshold: based on the calculation results of Shapley value, the clipping threshold is dynamically adjusted to realize adaptive differential privacy. The adaptive clipping threshold formula is as follows:
[0070]
[0071] where T0 is the global basic clipping threshold; is the normalized Shapley value, which is used to measure the relative contribution of client i.
[0072] S4.3: Smoothing mechanism: In order to avoid the clipping threshold from dramatic fluctuation during training, a smoothing mechanism is further introduced:
[0073]
[0074] where, is the clipping threshold of client i in the t-th round; alpha is a smoothing coefficient in [0, 1], which controls the weight of the historical value and the current value of the clipping threshold, thereby ensuring the stability of the threshold adjustment.
[0075] Finally, the local model is globally aggregated to obtain the global model. Moreover, it is determined whether the maximum federated learning round is reached, and if not, the iteration training is continued.
[0076] The beneficial effects of the present application are:
[0077] The present application aims at the three major challenges of federated learning under Non-IID data distribution: convergence shock caused by gradient divergence, generalization decline caused by local model overfitting, and the trade-off dilemma between privacy protection and model accuracy. The present application proposes the following innovative solutions: first, the heterogeneity is accurately quantified by fusing the multi-dimensional feature vector of label distribution, mean and variance, and the symmetry JS divergence, and the clustering structure is dynamically optimized by combining the contour coefficient, to establish a homogeneity basis for gradient aggregation; then, during the local model training stage, the cosine constraint of contrastive learning is used to strengthen the tightness of the intra-cluster model features (minimize the intra-cluster model distance), and at the same time, the L2 regular elastic anchor is used to anchor the local and global parameter deviation, to realize the dynamic balance of local individualization and global consistency; finally, during the local model transmission stage, the Shapley value is used to quantify the contribution of each client and establish a positive correlation mapping of the clipping threshold (high contribution low clipping, low contribution high noise), combined with the smoothing mechanism to maintain stability, so that the privacy resources are optimally allocated according to the utility, breaking through the privacy-accuracy trade-off dilemma.
[0078] The hierarchical clustering algorithm based on Jensen-Shannon divergence of the present application accurately represents the data heterogeneity by constructing a multi-dimensional feature vector fusing label distribution, mean and variance, overcoming the one-sidedness of traditional single label statistics and the evaluation bias caused by the asymmetry of KL divergence. By using the similarity matrix generated based on JS divergence, the clustering structure and linking strategy are dynamically adjusted by combining the contour coefficient, to ensure that the clients in the same cluster meet the distribution alignment condition, and by using PCA dimension reduction to retain the key distribution features and compress the calculation dimension, a homogeneity basis for gradient aggregation is formed.
[0079] The intra-cluster contrastive learning of the present application uses cosine similarity constraint to establish a feature space optimization framework, which forces the intra-cluster model parameters to maximize the feature tight coupling in the positive sample pair optimization of the contrastive learning objective function (by minimizing 1-cos(ω i ,ω j) zoom in the same cluster model), negative sample pair optimization (suppress cross-cluster similarity by max(0, cos(ω i ,ω j )) to promote the minimization of the inter-cluster model to form a feature isolation barrier, and the temperature parameter τ fine-tunes the feature space density to improve the robustness of the distribution mutation. The L2 regularization mechanism cooperates to establish an elastic anchor point by constraining the deviation of the local model θ i and the global model θ globe . Finally, combined with the multi-objective function weight coefficients λ1 and λ2, the local personalization and global generalization requirements are dynamically balanced (increasing λ1 enhances intra-cluster consistency, and increasing λ2 enhances global consistency), and the conduction of local overfitting errors in the federal link is blocked.
[0080] The present application quantifies the marginal contribution of the client based on the grouping calculation strategy of the Shapley value, and accordingly establishes a positive correlation mapping between the pruning threshold and the contribution. The high-contribution client gradient retains complete feature information (threshold relaxation, small gradient pruning amplitude), the low-contribution client accepts strong noise protection (threshold tightening, high noise addition ratio), and the threshold stability is maintained through the smoothing coefficient α. Compared with the fixed noise scheme, the noise energy efficiency ratio of the core gradient direction is improved under the same privacy budget, realizing the optimal trade-off between privacy loss and model accuracy.
[0081] The present application proposes a privacy protection federated learning performance optimization method to address the challenges of federated learning in privacy protection, model convergence and generalization ability under Non-IID data distribution. The present application improves the performance of federated learning model while effectively alleviating the impact of data heterogeneity through client dynamic clustering, intra-cluster contrast learning, regularization mechanism and adaptive differential privacy, and optimizes the generalization ability of the model under the premise of meeting the privacy protection requirements.
[0082] Of course, implementing any product of the present application does not necessarily need to achieve all the advantages described above at the same time. BRIEF DESCRIPTION OF DRAWINGS
[0083] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiment description. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without creative labor.
[0084] Figure 1 It is a schematic diagram of the overall process of the present application;
[0085] Figure 2 It is a schematic diagram of the specific scene of federated learning;
[0086] Figure 3A schematic diagram of a local training process for each client cluster;
[0087] Figure 4 A flowchart of a Shapley-based adaptive differential privacy mechanism. DETAILED DESCRIPTION
[0088] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative labor fall within the scope of protection of the present application.
[0089] Embodiment 1
[0090] The privacy protection federated learning performance optimization method for Non-IID data distribution described in this embodiment includes the following steps:
[0091] S1: Client dynamic clustering: according to the data distribution characteristics of the client (including data labels and statistical information thereof), a hierarchical clustering algorithm based on Jensen-Shannon divergence (JS divergence) is used to dynamically cluster the clients.
[0092] S2: Intra-cluster contrast learning: within the cluster generated by clustering, a contrast loss function based on cosine similarity is constructed to maximize the similarity of the models of the clients in the same cluster and minimize the similarity of the models of the clients in different clusters.
[0093] S3: Regularization mechanism: the deviation of the local model parameters from the global model parameters is constrained by an L2 norm regularization term.
[0094] S4: Adaptive differential privacy: based on the Shapley value, the contribution degree of the client is dynamically evaluated, the clipping threshold is adjusted according to the contribution degree, and noise satisfying the differential privacy budget is added in the parameter transmission.
[0095] Embodiment 2
[0096] In this embodiment, a privacy protection federated learning performance optimization method suitable for Non-IID data distribution is as shown in Figure 1 The specific steps are as follows:
[0097] S1: Client dynamic clustering: according to the data distribution characteristics of the client (including data labels and statistical information thereof), the clients are dynamically clustered. The clustering method calculates the data distribution difference between the clients based on Jensen-Shannon divergence (JS divergence), and a dynamic hierarchical clustering algorithm is used for clustering to optimize the collaborative training effect of federated learning.
[0098] S2: Intra-cluster contrastive learning: By constructing a contrastive loss function based on cosine similarity definition, the model features of intra-cluster clients are optimized. The contrastive learning aims to maximize the similarity of the same cluster models (positive sample pairs) and minimize the similarity of different cluster models (negative sample pairs) to reduce the interference between cluster features and improve the generalization ability of the model.
[0099] S3: Regularization mechanism: By introducing a regularization term to control the deviation between the cluster center model and the global model. The regularization term is based on L2 norm, which is used to constrain the distance between local model parameters and global model parameters, so as to reduce the model drift in the process of federated learning training and improve the stability of the global model.
[0100] S4: Adaptive differential privacy: Introduce Shapley value to dynamically measure the marginal contribution of each client to the global model, and adjust the clipping threshold based on the contribution value to achieve dynamic balance between privacy protection and model performance. During the transmission of model parameters, adaptive clipping and noise addition operations are performed on local model parameters to ensure that the privacy budget constraint of differential privacy is met, while reducing the negative impact of privacy protection on model performance.
[0101] As shown in Figure 2 Before S1, the center server will issue an initial global model to the clients. Then, S1 of the present embodiment specifically includes:
[0102] (1) Calculate the local data distribution features: In this stage, each client extracts the features of its local data distribution to represent the global characteristics and statistical information of the data. Let the data set of client i be D i , which contains N i samples, and the label of each sample belongs to the set C = {c1, c2, …, c k}. First, to solve the problem of high dimensionality of data features, the client applies principal component analysis (PCA) to its local data features, reducing the original high-dimensional features to a lower dimension to retain the main feature information, obtaining the reduced data features This dimension reduction process not only retains the main feature dimensions, but also effectively reduces the computational complexity. Next, the frequency of each label c j ∈ C in the data set is calculated where n i,j is the number of samples with label c j in D i . The frequencies of all labels are combined into a label distribution vector f i = [f i,1 f i,2 ,…,f i,k], and normalized to a probability distribution to fully reflect the distribution characteristics of the data labels. In addition, to capture the statistical information of the data, the mean i and variance of the data are calculated
[0103]
[0104] Finally, the normalized label distribution f i , the mean i and the variance are concatenated into a feature vector This feature vector comprehensively reflects the data distribution characteristics of client i.
[0105] (2) Calculate the similarity between clients: In order to quantify the similarity between the data distributions of clients, we introduce the Jensen-Shannon divergence (JS divergence). Let the feature vectors of client i and client j be and where f i and f j are the normalized label distributions of the two clients. JS divergence is used to measure the similarity of the data distributions of clients i and j, and its calculation formula is
[0106]
[0107] where is the mean distribution of v i and v j , and KL(P||Q) represents the Kullback-Leibler divergence between distributions P and Q:
[0108]
[0109] The value range of JS divergence is [0, 1], and the smaller the value, the more similar the two distributions. For subsequent processing, we convert the JS divergence to a similarity S i,j , defined as:
[0110] S i,j = 1-JS(v i ,v j )(4)
[0111] where the value range of S i,j is [0, 1], and the closer the value is to 1, the more similar the data distributions of clients i and j. By calculating the JS divergence of all client pairs (i, j), a similarity matrix S is generated, which is in the form of:
[0112]
[0113] Where n represents the total number of clients.
[0114] (3) Client clustering: After obtaining the similarity matrix S of clients, the central server uses a dynamic hierarchical clustering algorithm to group clients with similar data distribution into the same cluster. The specific steps are as follows:
[0115] Initialization: Each client is initially a separate cluster. Let there be M clients, then the initial number of clusters is M, and each cluster contains only one client.
[0116] Select clustering linkage method: In hierarchical clustering, different linkage methods will affect the formation of clusters. The following three linkage strategies are tried:
[0117] Average linkage: The similarity between clusters is the average of all point pairs.
[0118] Complete linkage: The minimum similarity between clusters is the minimum value of all point pairs.
[0119] Single linkage: The similarity between clusters is the maximum value of all point pairs.
[0120] Dynamically determine the number of clusters: To avoid the negative effects of over-aggregation or over-separation, this method dynamically adjusts the number of clusters by evaluating the quality of the clusters. The specific steps include:
[0121] Calculate the Silhouette Coefficient: The Silhouette Coefficient is used to evaluate the consistency of data within the cluster and the separation of data between clusters, defined as:
[0122]
[0123] Where a is the average similarity of a client with other clients in its cluster, and b is the average similarity of the client with the nearest neighbor cluster. The Silhouette Coefficient ranges from -1 to 1, and the closer the value is to 1, the better the clustering effect.
[0124] Adjust the clustering parameters: By limiting the maximum cluster number K Max and selecting the optimal linkage method, the clustering effect is optimized while avoiding high computational complexity. When the current value of the Silhouette Coefficient is better than the previous best value, update the best cluster number K and the corresponding clustering label.
[0125] Output clustering results: When clustering is complete, the system returns the following results: the best cluster number K and the corresponding Silhouette Coefficient; the clustering label C of each client i , where C i ∈{1,2,…,K}.
[0126] As Figure 3 shown, after obtaining the execution result of S1, S2 and S3 are performed, and the specific steps are as follows:
[0127] First, in the obtained clustering result, let the cluster C k contain N k clients, and the local model of each client is represented as ω i . The local training process of each cluster after clustering is shown in the figure. For cluster C k , the models (ω i , ω j ) of any two clients in the same cluster are regarded as a positive sample pair (such as the connecting line of the left / right ellipse area model in the figure), and the goal is to maximize the similarity of their feature representations to improve the intra-cluster consistency; at the same time, the client model k from other cluster C' k is regarded as a negative sample pair (such as the connecting line of the different color models across the ellipse area in the figure), and the goal is to reduce the similarity between it and the models in cluster C k to ensure the separation between different clusters. In order to measure the similarity between models, this method uses a cosine similarity function, which is defined as:
[0128]
[0129] Where, when cos (ω i , ω j ) is close to 1, it means that the features of the two models are highly similar; when cos (ω i , ω j ) is close to -1, it means that the features of the two models are significantly different.
[0130] Based on the above definition, a contrast loss function is further constructed to optimize the model relationship of the clients in the cluster:
[0131] As Figure 3 shown, the intra-cluster contrast learning mechanism is specifically manifested as:
[0132]
[0133] Where, y = 1 means that ω i and ω j belong to the same cluster, and as a positive sample pair, the positive sample pair loss (such as the inside of the left / right ellipse in Figure 3 ) forces the intra-cluster models to be closer; y = -1 means that ω i and ω j do not belong to the same cluster, and as a negative sample pair, the negative sample pair loss (such as the interval between different ellipses in Figure 3 ) suppresses the cross-cluster similarity.
[0134] To achieve the optimization goal of intra-cluster contrastive learning, this method focuses on cluster C. k In this study, the objective function is defined as follows: Minimize the contrastive loss of positive sample pairs while maximizing the separability of negative sample pairs.
[0135]
[0136] Among them, P k It is the set of positive sample pairs within the cluster; N k It is the set of negative sample pairs between clusters; τ is the temperature parameter used to adjust the sensitivity of the loss function.
[0137] Finally, the overall objective of intra-cluster contrastive learning is obtained by calculating a weighted average of the losses across all clusters:
[0138]
[0139] For regularization mechanisms in S3, such as Figure 3 As shown by the dashed one-way arrow, the specific steps are as follows:
[0140] During the local model update phase, a regularization term is introduced to constrain the difference between the local model parameters and the global model parameters, defined as follows:
[0141]
[0142] Where, θ i θ represents the local model parameters of client i. globe Let represent the global model parameters, and λ be the regularization strength coefficient. This regularization term enhances the robustness of the global model by minimizing the distance between the local model and the global model.
[0143] Finally, combining intra-cluster contrastive learning and regularization mechanisms, the local learning objective for each client is defined by the following formula:
[0144] l loss =l sup +λ1l con +λ2l prox (12)
[0145] Among them, l sup λ1 and λ2 are the cross-entropy loss of the supervised task, respectively controlling the weights of the contrastive learning loss and the regularization term on the overall objective.
[0146] like Figure 4 As shown, after local training is completed, the S4 adaptive differential privacy mechanism is executed. This process consists of two core stages:
[0147] Phase 1: Shapley value estimation (upper right of the figure)
[0148] (1) Client grouping: As shown in the right flow of the figure, the client set is randomly divided into G groups
[0149] (2) Partial permutation sampling: In each group, a limited permutation combination approximation calculation is sampled to avoid the full permutation overhead. The Shapley value calculation formula is as follows:
[0150]
[0151] where S π,i represents the subset before client i joins in permutation π; v(S) is the model accuracy after the subset S participates in global model training.
[0152] Phase two: adaptive differential privacy based on Shapley value (lower right part of the figure)
[0153] (3) Dynamic adjustment of clipping threshold: based on the calculation result of Shapley value, the clipping threshold is dynamically adjusted to realize adaptive differential privacy. The adaptive clipping threshold formula is as follows:
[0154]
[0155] where T0 is the global basic clipping threshold; is the normalized Shapley value, which is used to measure the relative contribution of client i.
[0156] (4) Smoothing mechanism: in order to avoid the sharp fluctuation of the clipping threshold in the training process, a smoothing mechanism is further introduced:
[0157]
[0158] where is the clipping threshold of client i in the t-th round; α ∈ [0, 1] is the smoothing coefficient, which controls the weight of the historical value and the current value of the clipping threshold, so as to ensure the stability of the threshold adjustment.
[0159] Finally, the local model is globally aggregated to obtain the global model. Moreover, it is judged whether the maximum federated learning round number is reached. If not, the iterative training is continued.
[0160] The preferred embodiments of the application disclosed above are only to facilitate the elucidation of the application. The preferred embodiments do not describe all the details of the application and limit the application to the specific embodiments described. Obviously, many modifications and variations can be made in light of the teachings above. The description is chosen and described in order to best explain the principles of the application and its practical application to thereby enable others skilled in the art to best utilize the application and get the best results from the application. The application is only limited by the claims and their full scope and equivalents.
Claims
1. A performance optimization method for privacy-preserving federated learning under Non-IID data distribution, characterized in that, Includes the following steps: S1: Client-side dynamic clustering: Based on the data distribution characteristics of the clients, a hierarchical clustering algorithm based on Jensen-Shannon divergence is used to dynamically cluster the clients; S2: Intra-cluster contrastive learning: Within the clusters generated by clustering, a contrastive loss function based on cosine similarity is constructed to maximize the similarity of client models within the same cluster and minimize the similarity of client models in different clusters; S3: Regularization mechanism: The deviation between local model parameters and global model parameters is constrained by the L2 norm regularization term; S4: Adaptive Differential Privacy: Dynamically evaluates client contribution based on Shapley value, adjusts pruning threshold according to contribution, and adds noise that meets differential privacy budget during parameter transmission.
2. The privacy-preserving federated learning performance optimization method under Non-IID data distribution as described in claim 1, characterized in that: Step S1 specifically includes the following sub-steps: S1.1: Let the dataset of client i be D. i , which contains N i There are 3 samples, and the label of each sample belongs to the set C = {c1, c2, ..., c3}. k The client applies Principal Component Analysis (PCA) to its local data features, reducing the original high-dimensional features to a lower dimension to retain the main feature information, thus obtaining the dimensionality-reduced data features. S1.2: Statistical data for each label c in the dataset j Frequency of ∈C Where n i,j For the tag c j In D i The number of samples in the dataset; combining the frequencies of all labels into a label distribution vector f. i =[f i,1 f i,2 ,…,f i,k The data is then normalized into a probability distribution to fully reflect the distribution characteristics of the data labels. S1.3: Calculate the mean μ of the data i and variance Specifically defined as: Where x is the dataset D i A sample vector, N i Let i be the total number of samples for client i; The normalized label distribution f i Mean μ i and variance Concatenate into feature vectors This feature vector comprehensively reflects the data distribution characteristics of client i; S1.4: Jensen-Shannon divergence is introduced; let the eigenvectors of client i and client j be respectively... and Where f i and f j This represents the normalized label distribution of two clients; JS divergence is used to measure the similarity of the data distributions of clients i and j, and its calculation formula is: in, It is v i and v j The mean distributions of P and Q are given by KL(P||Q), where KL(P||Q) represents the Kullback-Leibler divergence between distributions P and Q. Where x is a possible value in the sample space, and P(x) and Q(x) are the probabilities of distributions P and Q on sample x; The JS divergence ranges from [0, 1], with smaller values indicating greater similarity between the two distributions. For ease of subsequent processing, we convert the JS divergence into a similarity score S. i,j Defined as: With i,j =1-JS(in i ,in j ) (4) Among them, S i,j The value of is in the range of [0, 1]. The closer the value is to 1, the more similar the data distributions of clients i and j are. By calculating the JS divergence of all client pairs (i, j), a similarity matrix S is generated, in the form of: Where n represents the total number of clients; S1.5: After obtaining the client similarity matrix S, the central server uses a dynamic hierarchical clustering algorithm to group clients with similar data distributions into the same cluster; it selects a clustering linking method to dynamically determine the number of clusters and outputs the clustering results.
3. The privacy-preserving federated learning performance optimization method under Non-IID data distribution as described in claim 1, characterized in that: Step S1.5 includes the following sub-steps: S1.5.1: Initialization: Each client is initially treated as a separate cluster; if there are M clients in total, then the initial number of clusters is M, and each cluster contains only one client; S1.5.2: Choosing a Clustering Linkage Method: In hierarchical clustering, different linking methods affect cluster formation. Linking strategies include: Average link method: The inter-cluster similarity is the average of the similarities of all point pairs; Fully linked method: The minimum similarity between clusters is the minimum value among all point pairs; Single-link method: The inter-cluster similarity is taken as the maximum value among all point pair similarities; S1.5.3: Dynamically determine the number of clusters: To avoid the negative effects of over-aggregation or over-separation, the number of clusters is dynamically adjusted by evaluating the quality of the clusters; S1.5.4: Output Clustering Results: After clustering is complete, the system returns the following results: the optimal number of clusters K and the corresponding silhouette coefficients; the clustering label C for each client. i C i ∈{1,2,…,K}.
4. The privacy-preserving federated learning performance optimization method under Non-IID data distribution as described in claim 1, characterized in that: Step S1.5.3 specifically includes: Calculate the silhouette coefficient: The silhouette coefficient is used to evaluate the consistency of data within a cluster and the segregation of data between clusters, and is defined as: Where 'a' is the average similarity between a client and other clients in its cluster, and 'b' is the average similarity between the client and its nearest neighbor clusters; the silhouette coefficient ranges from [-1, 1], and the closer the value is to 1, the better the clustering effect. Adjusting clustering parameters: By limiting the maximum number of clusters K Max The optimal linking method is selected to optimize clustering performance while avoiding excessive computational complexity; when the current value of the silhouette coefficient is better than the previous best value, the optimal number of clusters K and the corresponding clustering labels are updated.
5. The privacy-preserving federated learning performance optimization method under Non-IID data distribution as described in claim 1, characterized in that: Step S2 specifically includes the following sub-steps: In the clustering results obtained, let cluster C be... k Contains N k There are 1 client, and the local model for each client is represented by ω. i For cluster C k The model (ω) of any two clients in the same cluster i ,ω j ( ) are considered positive sample pairs, with the goal of maximizing the similarity of their feature representations to improve intra-cluster consistency; simultaneously, samples from other clusters C are considered... ' k Client model Treating them as negative sample pairs, the goal is to reduce their correlation with cluster C. k The similarity of the internal models is used to ensure the separation between different clusters; to measure the similarity between models, this method uses the cosine similarity function, which is defined as: Where, when cos(ω i ,ω j When cos(ω) is close to 1, it indicates that the features of the two models are highly similar; when cos(ω) is close to 1, it indicates that the features of the two models are highly similar. i ,ω j When the value is close to -1, it indicates that the feature differences between the two models are significant; Based on the above definition, a contrastive loss function is further constructed to optimize the model relationship between clients within the cluster: Where y = 1 represents ω i and ω j Belonging to the same cluster, they are considered positive sample pairs; y = -1 indicates ω i and ω j Those not belonging to the same cluster are treated as negative sample pairs; To achieve the optimization goal of intra-cluster contrastive learning, this method focuses on cluster C. k In this study, the objective function is defined as follows: Minimize the contrastive loss of positive sample pairs while maximizing the separability of negative sample pairs. Among them, P k It is the set of positive sample pairs within the cluster; N k It is the set of negative sample pairs between clusters; τ is the temperature parameter used to adjust the sensitivity of the loss function; Finally, the overall objective of intra-cluster contrastive learning is obtained by calculating a weighted average of the losses across all clusters:
6. The privacy-preserving federated learning performance optimization method under Non-IID data distribution as described in claim 1, characterized in that: The regularization mechanism in step S3 specifically includes: during the local model update phase, a regularization term is introduced to constrain the difference between the local model parameters and the global model parameters, defined as: Where, θ i θ represents the local model parameter vector of client i. globe This represents the global model parameter vector for the current round, where λ is the regularization strength coefficient. The square of the L2 norm; this regularization term enhances the robustness of the global model by minimizing the distance between the local and global models; Finally, combining intra-cluster contrastive learning and regularization mechanisms, the local learning objective for each client is defined by the following formula: in, It is the loss function for the local supervised learning task on client i. It is the intra-cluster contrastive learning loss defined by formula (10). The regularization term is defined by formula (11); λ1 and λ2 control the relative weights of the contrastive learning loss term and the regularization term in the total loss, respectively.
7. The privacy-preserving federated learning performance optimization method under Non-IID data distribution as described in claim 1, characterized in that: Step S4 specifically includes the following sub-steps: S4.1: Shapley value calculation: Let the client set be... Divided into groups G, each group has a set of clients. The Shapley value within each group only needs to consider the contribution of subsets within the group, as given by the following formula: in, S represents the set of all possible permutations of clients within group g. π,i v(S) represents the subset before client i is added in the permutation π; v(S) is the model accuracy after subset S participates in the global model training. S4.2: Dynamically Adjusting the Pruning Threshold: Based on the Shapley value calculation, the pruning threshold is dynamically adjusted to achieve adaptive differential privacy; the adaptive pruning threshold formula is as follows: Where T0 is the global basic pruning threshold; It is the normalized Shapley value, used to measure the relative contribution of client i; S4.3: Smoothing Mechanism: To avoid drastic fluctuations in the pruning threshold during training, a smoothing mechanism is further introduced: in, α is the pruning threshold for client i in round t; α∈[0,1] is the smoothing coefficient, which controls the weight of the historical and current values of the pruning threshold, thereby ensuring the stability of the threshold adjustment.
Citation Information
Cited By
Model decoupling federated learning method and system based on frequency analysis
CN122021811A