A communication-efficient federated learning method based on gradient cosine similarity and differential privacy

CN119089980BActive Publication Date: 2026-08-18TONGJI UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411138937.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-19
Publication Date
2026-08-18
Estimated Expiration
2044-08-19

AI Technical Summary

Technical Problem

[0010]针对上述联邦学习在non-IID数据环境中通信效率低下的问题,本发明提出了一种基于梯度余弦相似性和差分隐私的通信高效联邦学习方法(Federated Learning withNoise-added Gradient Cosine Similarity,FedNGCS),从而提高FL训练在non-IID数据上的通信效率,并克服了派生的隐私泄露问题

Benefits of technology

[0021]本发明提高联邦学习在non-IID数据环境中的通信效率,具体而言是减少了联邦模型达到目标测试精度所需要的通信轮次。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119089980B_ABST
    Figure CN119089980B_ABST
Patent Text Reader

Abstract

The present application relates to distributed machine learning technology and privacy computing technology, and proposes a communication efficient federated learning method based on gradient cosine similarity and differential privacy. The method defines a local cumulative gradient at each user end to reflect the local data distribution of the user, and introduces differential privacy technology in the process of uploading to the server to provide privacy protection for the user; a pseudo-global gradient is defined at the server end to indicate the latest global model update direction and thus reflect the global data distribution. Based on the cosine similarity between the above two real-time updated gradients, an adaptive weighted aggregation strategy is used to accelerate the convergence of the federated model and improve the communication efficiency of the federated training.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to distributed machine learning technology and privacy computing technology, and in particular to an efficient federated learning method for communication based on gradient cosine similarity and differential privacy. Background Technology

[0002] In recent years, the application of mobile devices and the Internet of Things (IoT) has become increasingly widespread, generating massive amounts of valuable data on users' local devices. With the rapid development of machine learning (ML) technology, the value of big data can be extracted through increasingly complex and efficient model training. In the traditional machine learning paradigm, model training is centralized, requiring a large amount of data and computing resources. The centralized machine learning paradigm needs to collect raw data from users' devices, upload it to a central server for data processing, and then use it for model training. This approach has many drawbacks, including a huge communication burden caused by uploading massive amounts of data and limited possibilities for real-time model training. More importantly, centralized machine learning relies excessively on the use of sensitive raw data, posing a serious risk of privacy breaches.

[0003] Federated Learning (FL) is an emerging distributed machine learning framework and is also considered a privacy-preserving computing technology. It aims to address the inherent privacy and security issues in centralized machine learning paradigms, effectively breaking down data silos. A typical federated learning system consists of a central server and several distributed, independently participating users (individuals or organizations). Both the server and user devices possess certain computing, data storage, and communication capabilities. The general federated training process is as follows: the server broadcasts an initialized global model to several users; users train local models on their local devices using their private datasets and then transmit the updated local models to the server; after receiving a certain number of local models, the server aggregates these models to update the global model; the server broadcasts the updated global model to the users and repeats the above training and communication process until a pre-set global model performance metric or the maximum number of communication rounds is reached.

[0004] However, in real-world applications, federated learning users independently collect and store data, resulting in their local datasets often exhibiting statistically non-independent and identically distributed (non-IID) characteristics, i.e., data distribution heterogeneity. In non-IID data environments, the local model update directions of federated learning participants (reflected by gradients or the difference between the updated and unupdated models) differ significantly, leading to inefficient communication during federated training. Therefore, non-IID data has become a major challenge for federated learning technology.

[0005] McMahan et al. proposed the FedAvg method in their paper "Communication-efficient learning of deep networks from decentralized data." Its core idea is that users train local models locally and then upload the local model parameters to a central server. The server then updates the global model parameters by weighted averaging of these local models based on the size of the user's local dataset. Furthermore, to optimize the federated learning training process, FedAvg increases the amount of iterative computation on the user's local end to reduce system communication overhead and accelerate the convergence of the global model. However, FedAvg performs poorly in non-IID data environments.

[0006] Li et al. proposed the FedProx method in their paper "Federated optimization in heterogeneous networks," which improves upon FedAvg. FedProx limits the divergence of the local model compared to the latest federated model (i.e., the previous federated model) by introducing a regularization term into the local loss function, making federated training perform more smoothly in non-IID data environments. However, FedProx still cannot significantly improve the communication efficiency of federated learning in non-IID data environments.

[0007] Li et al. proposed the MOON method in their paper "Model-contrastive federated learning". MOON improves the generalization performance of federated models by performing comparative learning between the global and local models. Compared with traditional federated learning methods, MOON significantly improves the communication efficiency of federated learning. However, MOON still performs suboptimally in non-IID data environments.

[0008] Cosine similarity is a mathematical method for measuring the degree of similarity between two non-zero vectors. Its basic idea is to measure the directional similarity by calculating the cosine of the angle between the two vectors. Given two vectors, their cosine similarity can be obtained by dividing their inner product by the product of their norms (length / magnitude, representing the size of the vector). Cosine similarity has the following characteristics: ① The range is [-1, 1]. ② The larger the cosine similarity value, the closer the directions of the two vectors are. Specifically, a value of 1 indicates that the two vectors have exactly the same direction; a value of 0 indicates that the two vectors are orthogonal; and a value of -1 indicates that the two vectors have completely opposite directions. ③ The magnitude of the vectors is not considered. The magnitude of the two vectors does not affect the calculation of cosine similarity.

[0009] Differential privacy (DP) is a privacy-preserving computation technique that protects individual data privacy by introducing controlled noise during data publishing or query processing. The core idea of ​​DP is to ensure the accuracy of data analysis results while making it difficult for attackers to deduce the original data from the analysis results, thereby maximizing user privacy protection. Differential privacy technology seeks a balance between privacy protection and data utilization and is widely used in fields such as data mining and machine learning. Summary of the Invention

[0010] To address the issue of low communication efficiency in federated learning (FL) on non-IID data environments, this invention proposes a communication-efficient federated learning method (FedNGCS) based on gradient cosine similarity and differential privacy. This improves the communication efficiency of FL training on non-IID data and overcomes the derived privacy leakage problem. Specifically, a local cumulative gradient is defined on each user's end and continuously updated during local iteration to reflect the user's local data distribution. A pseudo-global gradient is defined on the server side and continuously updated after federated aggregation to indicate the latest global model update direction. Based on the cosine similarity between the two real-time updated gradients, an adaptive weighted aggregation strategy is designed to accelerate the convergence of the federated model and improve the communication efficiency of federated training. The federated training process of this invention requires users to upload local cumulative gradients. This step introduces additional privacy leakage risks compared to the original FL method. Therefore, this invention introduces differential privacy technology as a privacy protection measure.

[0011] The technical solution of this invention is as follows:

[0012] An efficient federated learning method for communication based on gradient cosine similarity and differential privacy includes the following steps:

[0013] Step 1: Start federated learning; the server initializes the global model.

[0014] Step 2: The server determines whether the previous moment was the FL start moment or a global model aggregation moment. If so, the server randomly selects a fixed number of users to participate in a new round of training and broadcasts the latest global model to these users. If not, the server continues to use the selected user set from the previous moment to participate in training.

[0015] Step 3: Each selected user calculates the stochastic gradient on the local dataset using the gradient descent algorithm, updates the local model, and obtains the iterative local model;

[0016] Step 4: The server determines whether it is in the first communication round. If so, it proceeds to step 5; otherwise, each selected user updates its local cumulative gradient based on stochastic gradient.

[0017] Step 5: The server determines whether the current time t is the global model aggregation time. If not, it returns to step 2. If so, the server calculates the standard deviation of the global sensitivity and DP noise in sequence, and sends the standard deviation of DP noise to each selected user. The selected user clips the local cumulative gradient and adds DP noise to obtain the perturbed local cumulative gradient that meets the privacy protection requirements.

[0018] Step 6: The server determines whether the current time t is the first global model aggregation time. If so, the server assigns weights to users based on the proportion of data volume of each selected user. If not, the server calculates the cosine similarity between the perturbation local cumulative gradient and the latest pseudo-global gradient of each selected user, and assigns weights to users accordingly. The server performs weighted aggregation of the local models of all selected users to update the global model. The server updates the pseudo-global gradient.

[0019] Step 7: Repeat steps 2 to 6 until the preset model performance index or maximum number of communication rounds is reached.

[0020] Beneficial effects:

[0021] This invention improves the communication efficiency of federated learning in non-IID data environments, specifically by reducing the number of communication rounds required for the federated model to achieve the target test accuracy. Attached Figure Description

[0022] Figure 1 This is a flowchart illustrating the efficient federated learning method for communication based on gradient cosine similarity of the present invention.

[0023] Figure 2This is one of the comparison graphs showing the change in accuracy of the method of the present invention and three traditional federated learning methods with the number of communication rounds in the embodiments.

[0024] Figure 3 This is the second comparison chart showing the change in accuracy of the method of the present invention and three traditional federated learning methods with the number of communication rounds in the embodiments.

[0025] Figure 4 This is the third graph in the examples comparing the accuracy of the method of the present invention with that of three traditional federated learning methods as a function of communication rounds. Detailed Implementation

[0026] The technical solutions provided in this application will be further described below with reference to specific embodiments and accompanying drawings. The advantages and features of this application will become clearer from the following description.

[0027] This invention proposes an efficient federated learning method for communication based on gradient cosine similarity and differential privacy, aiming to improve the communication efficiency of federated learning (FL) in non-IID data environments. Figure 1 As shown, the method flow is as follows:

[0028] Step 1: Start Federated Learning. The server initializes the global model w. (0) .

[0029] Step 2: The server determines whether the previous time t-1 was the time when FL was started or the time of a certain global model aggregation.

[0030] If so, perform the following operations: ① The server randomly selects K users to form a user set. ① The user selected for local training at time t; ② The latest global model w (t-1) Broadcast to each user U m As their respective latest local models Where t = 1, ..., T; T = Rτ, R represents the total number of communication rounds, and τ represents the time required for each round of communication; M represents the total number of users participating in federated learning; m = 1, ..., M.

[0031] If not, perform the following operation: continue using the selected user set from the previous time step, i.e.

[0032] Step 3: Each selected user U m In local dataset The stochastic gradient is calculated using the gradient descent algorithm. For local models Update the local model to obtain the iterative version. in, For user U m Private datasets, Represents an F-dimensional feature vector. It represents a tag.

[0033] Step 4: The server determines whether the current time t is in the first communication round.

[0034] If so, do not perform any operation.

[0035] If not, perform the following operations: for each selected user U m Based on stochastic gradient Update the local cumulative gradient The formula is as follows:

[0036]

[0037] in, This is the latest locally accumulated gradient obtained after the update. This is the local cumulative gradient from the previous time step. Specifically, user U... m Before the first local iteration in this round of communication begins, let The reason for the reset operation is: User U m It is possible that they will participate in two consecutive rounds of federal training.

[0038] Step 5: The server determines whether the current time t is the global model aggregation time.

[0039] If not, return to step 2.

[0040] If so, perform the following operations:

[0041] ① The server calculates the global sensitivity Δs G The formula is as follows:

[0042]

[0043] Then, based on the privacy requirements of the Gaussian (∈,δ)-DP mechanism, the standard deviation σ of the DP noise is calculated, as follows:

[0044]

[0045] Where ∈>0 is the privacy budget, used to constrain the distribution differences between adjacent datasets, and δ>0 is the failure probability, used to represent the probability of constraint failure.

[0046] Next, the server sends the standard deviation σ of the DP noise to each selected user.

[0047] ② Each selected user Um Local cumulative gradient Cutting:

[0048]

[0049] Where C is the clipping threshold.

[0050] Next, the user accumulates gradients locally after cropping. By adding DP noise, we obtain the perturbed local cumulative gradient that satisfies the privacy requirements of (∈,δ)-DP. The formula is as follows:

[0051]

[0052] in, d represents Gaussian noise. Dimensions.

[0053] Finally, the user will perturb the locally accumulated gradient. Upload to the server.

[0054] Step 6: The server determines whether the current time t is the time of the first global model aggregation.

[0055] If so, the server performs the following operations:

[0056] ①Based on each selected user U m User privileges are assigned based on the percentage of data volume. User U m weight The calculation formula is as follows:

[0057]

[0058] ② Collect all selected user U m The latest local model These models are then weighted and aggregated to update the global model w. (t) The updated formula is as follows:

[0059]

[0060] ③ Update the pseudo-global gradient, as shown in the following formula:

[0061]

[0062] in, This is the latest pseudo-global gradient obtained after the update.

[0063] If not, the server will perform the following operations:

[0064] ① Calculate U for each selected user mPerturbation local cumulative gradient and the latest pseudo-global gradient Cosine similarity between The formula is as follows:

[0065]

[0066] ② For each selected user U m Grant permissions to user U m weight The calculation formula is as follows:

[0067]

[0068] ③ Collect all selected user U m The latest local model These models are then weighted and aggregated to update the global model w. (t) The updated formula is as follows:

[0069]

[0070] ④ Update the pseudo-global gradient, as shown in the following formula:

[0071]

[0072] Step 7: Repeat steps 2 to 6 until the preset model performance index or maximum number of communication rounds is reached.

[0073] This invention designs an adaptive weighted aggregation strategy, which is reflected in the fact that before each round of model weighted aggregation, the method of this invention can adapt to... The randomness of the composition of users and This strategy addresses the differences in non-IID levels among users by assigning appropriate weights to each selected user. The higher a user's local non-IID level, the more its local cumulative gradient deviates from the pseudo-global gradient, and the greater the cosine similarity between them. This strategy assigns weights to users after softmax normalization of the cosine similarity between the perturbed local cumulative gradient and the pseudo-global gradient. By restricting users with high non-IID levels, the convergence of the federated model is accelerated, and the communication efficiency of federated training is improved.

[0074] Experimental verification:

[0075] To visually demonstrate the effectiveness and superiority of this method, the following experimental results are provided.

[0076] The FedNGCS method proposed in this invention was implemented using PyTorch and compared with three classic FL methods: FedAvg (proposed in the paper "Communication-efficient learning of deep networks from decentralized data"), FedProx (proposed in the paper "Federated optimization in heterogeneous networks"), and MOON (proposed in the paper "Model-contrastive federated learning"). Three sets of image classification experiments demonstrate the superiority of the proposed FedNGCS method under non-IID data conditions.

[0077] In this embodiment, three widely used public datasets were selected: MNIST, FashionMNIST, and CIFAR-10. Two neural network models were built for different datasets: for the single-channel datasets MNIST and FashionMNIST, a CNN (Convolutional Neural Network) model, abbreviated as CNN-M, was trained, containing 2 convolutional layers, 2 max pooling layers, 2 fully connected layers, and 1 softmax layer; for the three-channel dataset CIFAR-10, a CNN model, abbreviated as CNN-C, was trained, containing 3 convolutional layers, 2 max pooling layers, 3 fully connected layers, and 1 softmax layer. The non-IID data environment setup method in this embodiment is as follows: Ten users with IDs from 1 to 10 participate in federated training. Each user's data volume is a random value between 400 and 800, and the data volumes of each user are unequal. Users with IDs 1, 2, and 3 randomly obtain sample data of one fixed category from the training set; users with IDs 4, 5, 6, and 7 randomly obtain sample data of two fixed categories from the training set; and users with IDs 8, 9, and 10 randomly obtain sample data of all categories from the training set. To more intuitively compare the communication efficiency of each method, the focus is on observing the number of communication rounds required for each method to reach the target accuracy. In the "MNIST+CNN-M" experimental group, the target accuracy is set to 95%; in the "FashionMNIST+CNN-M" experimental group, the target accuracy is set to 80%; and in the "CIFAR-10+CNN-C" experimental group, the target accuracy is set to 40%.

[0078] Other key experimental hyperparameter settings are as follows: maximum number of communication rounds R = 200; number of local iterations per round τ = 3; number of users participating in training per round K = 5. Referring to the paper "Federated learning with differential privacy: Algorithms and performance analysis", the following settings are made: privacy budget = 10; failure probability δ = 0.001; pruning threshold C is the median of the L2 norms of all parameters to be pruned; the batch size used by each user for training is equal to their local data volume. Specifically, in the CNN-M experiment, the initial learning rate is set to 0.01, and the decay rate is set to 0.995; in the CNN-C experiment, the initial learning rate is set to 0.1, and the decay rate is set to 0.992.

[0079] Experimental results based on three public datasets are as follows: Figure 2 , Figure 3 and Figure 4 As shown in Table 1, the number of communication rounds required for each method to achieve the target accuracy in the three sets of experiments is listed in Table 1, corresponding to... Figure 2 , Figure 3 and Figure 4 The experimental data showing the best communication efficiency are highlighted in bold. For experiments that did not reach the target accuracy after the maximum number of communication rounds, the experimental data are marked with the "N / A" symbol, and the highest test accuracy achieved during training is recorded in parentheses.

[0080] Experimental results show that, compared with FedAvg, FedProx and MOON, the FedNGCS proposed in this invention can effectively accelerate the convergence speed of the model, thereby improving communication efficiency.

[0081] Table 1: Number of communication rounds required for the method of this invention and three traditional federated learning methods to achieve the target accuracy.

[0082]

[0083] The above description is merely a description of preferred embodiments of this application and is not intended to limit the scope of this application in any way. Any changes or modifications made by those skilled in the art based on the above-disclosed technical content should be considered as equivalent and valid embodiments and fall within the scope of protection of the technical solution of this application.

Claims

1. A communication-efficient federated learning method based on gradient cosine similarity and differential privacy, characterized in that, Including the following steps: Step 1: Start federated learning; the server initializes the global model. Step 2: The server determines whether the previous moment was the FL start moment or a global model aggregation moment. If so, the server randomly selects a fixed number of users to participate in a new round of training and broadcasts the latest global model to these users. If not, the server continues to use the selected user set from the previous moment to participate in training. Step 3: Each selected user calculates the stochastic gradient on the local dataset using the gradient descent algorithm, updates the local model, and obtains the iterative local model; Step 4: The server determines whether it is in the first communication round. If so, it proceeds to step 5; otherwise, each selected user updates its local cumulative gradient based on stochastic gradient. Step 5: The server determines the current time. Is it the time for global model aggregation? If not, return to step 2. If so, the server calculates the standard deviation of the global sensitivity and the DP noise in sequence, and sends the standard deviation of the DP noise to each selected user. The selected user then clips the local cumulative gradient and adds the DP noise to obtain the perturbed local cumulative gradient that meets the privacy protection requirements. Step 6: The server determines the current time. If it is the first time for global model aggregation, the server assigns weights to users based on the proportion of data volume of each selected user; if not, the server calculates the cosine similarity between the perturbation local cumulative gradient and the latest pseudo-global gradient of each selected user, and assigns weights to users accordingly; the server performs weighted aggregation of the local models of all selected users to update the global model; the server updates the pseudo-global gradient. Step 7: Repeat steps 2 to 6 until the preset model performance index or maximum number of communication rounds is reached; In step 4, when the server determines the current time... If it is not in the first communication round, perform the following operations: Each selected user Based on stochastic gradient Update the local cumulative gradient The formula is as follows: ; in, This is the local model from the previous time step. , This is the latest locally accumulated gradient obtained after the update. The local cumulative gradient of the previous time step; user Before the first local iteration in this round of communication begins, let This is used as a reset operation.

2. The efficient federated learning method for communication based on gradient cosine similarity and differential privacy as described in claim 1, characterized in that, Step 2: The server determines the previous moment. Is it the moment when FL is enabled or the moment of a global model aggregation? If so, perform the following operations: ① The server randomly selects... A user set consists of 10 users. , representing a moment Users selected for local training; ② The latest global model Broadcast to each user As their respective latest local models ;in, ; , Represents the total number of communication rounds. This represents the time required for each round of communication; ; , The total number of users participating in federated learning; ; If not, then continue using the selected user set from the previous time step, i.e. .

3. The efficient federated learning method for communication based on gradient cosine similarity and differential privacy as described in claim 2, characterized in that, Step 3: Each selected user In local dataset The stochastic gradient is calculated using the gradient descent algorithm. For local models Update the local model to obtain the iterative version. ;in, For users Private datasets, Represents a 3D eigenvectors It represents a tag.

4. The efficient federated learning method for communication based on gradient cosine similarity and differential privacy as described in claim 3, characterized in that, In step 5, when the server determines the current time... When aggregating the time for the global model, the following operations are performed: ① The server calculates the global sensitivity. The formula is as follows: ; Then, according to Gauss - To protect privacy in the DP mechanism, the standard deviation of the DP noise is calculated. The formula is as follows: ; in, A privacy budget is used to constrain the distribution differences between adjacent datasets. This represents the failure probability, used to indicate the probability of a constraint failing. Next, the server will calculate the standard deviation of the DP noise. Distribute to each selected user; ② Each selected user Local cumulative gradient Cutting: ; in, This is the clipping threshold; Next, the user accumulates gradients locally after cropping. By adding DP noise, the desired result is obtained. -DP privacy protection requires perturbation of locally accumulated gradients The formula is as follows: ; in, Indicates Gaussian noise. express The dimension; Finally, the user will perturb the locally accumulated gradient. Upload to the server.

5. The efficient federated learning method for communication based on gradient cosine similarity and differential privacy as described in claim 4, characterized in that, Step 6: If the current time At the moment of the first global model aggregation, the server performs the following operations: ①Based on each selected user The percentage of data volume is used to empower users; users weight The calculation formula is as follows: ; ② Collect all selected users The latest local model Then, these models are weighted and aggregated to update the global model. The updated formula is as follows: ; ③ Update the pseudo-global gradient, as shown in the following formula: ; in, This is the latest pseudo-global gradient obtained after the update; If the current time If it is not the first time the global model is aggregated, the server performs the following operations: ① Calculate the number of selected users Perturbation local cumulative gradient and the latest pseudo-global gradient Cosine similarity between The formula is as follows: ; ② For each selected user To grant permissions, users weight The calculation formula is as follows: ; ③ Collect all selected users The latest local model Then, these models are weighted and aggregated to update the global model. The updated formula is as follows: ; ④ Update the pseudo-global gradient, as shown in the following formula: 。

Citation Information

Patent Citations

  • Cluster resource scheduling method and device, cluster system and readable storage medium

    CN116684420A

  • Communication efficient federal learning method based on differential privacy and dynamic weighted aggregation strategy

    CN118333138A