Bottom-up hierarchical federated learning method based on privacy protection
By adopting a privacy-preserving bottom-up hierarchical federated learning method in federated learning, and using homomorphic encryption and a combination of oversampling and undersampling, the global, local and local imbalance problems are solved, and the model performance and training efficiency are improved. , while protecting the privacy of client data.
Patent Information
- Application Number
- CN202410741542.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-11
- Publication Date
- 2024-10-01
AI Technical Summary
Existing federated learning methods are difficult to solve global, local and local imbalance problems at the same time when dealing with class imbalance problems, and cannot achieve efficient model training while protecting data privacy, resulting in reduced model performance and low training efficiency.
It adopts a bottom-up hierarchical federated learning method based on privacy protection, calculates global data distribution through homomorphic encryption, combines oversampling and undersampling to achieve data distribution balance, and utilizes a hierarchical federated architecture and a client bottom-up selection framework. Asynchronous updates are implemented to resolve three class imbalance issues.
It effectively improves the classification performance and training efficiency of the model, ensures the privacy protection of client data, avoids data leakage, and achieves a balance between global and local distribution.
Smart Images

Figure CN118734183A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of machine learning, and in particular relates to a bottom-up hierarchical federated learning method based on privacy protection. Background Art
[0002] With the development of big data and artificial intelligence technology, machine learning has been widely used in various fields. The performance of machine learning models is highly dependent on the amount and quality of their training data. Classic machine learning model training strategies require that the training data be centralized in one place, which means that data collected on different devices needs to be transmitted to a centralized server for processing, which brings risks in terms of privacy, security, and processing. Federated learning is considered a promising technology to address these risks. FL is a distributed training framework that utilizes a set of heterogeneous edge devices (e.g., client laptops and mobile phones) and a central server to coordinate the learning process. FL allows edge devices to collaboratively train a machine learning model without exposing the local data of one edge device to other clients or central servers.
[0003] FL's distributed architecture faces several challenges in model training, including communication cost, system heterogeneity, and statistical heterogeneity. In particular, statistical heterogeneity refers to the fact that training data are not independent and identically distributed among edge devices in the network, but optimization algorithms usually assume that training data are independent and identically distributed. Studies have shown that statistical heterogeneity may lead to slower convergence, sometimes even divergence, and cause significant performance degradation in model training. Therefore, the class imbalance problem is more challenging in FL. The class imbalance problem contains local imbalance and global imbalance as well as mismatched imbalance, which makes it crucial to develop techniques to handle different types of class imbalance problems. In the FL framework, the local or global data distribution of the client dataset is crucial to solving the class imbalance problem, but the distribution of client data is usually kept confidential to protect the privacy of the client.
[0004] Existing methods usually deal with the class imbalance problem through sampling, modifying loss functions, and hierarchical federation, but these methods usually require access to global data distribution information and cannot solve the three class imbalance problems at the same time. Therefore, it is impossible to achieve efficient model training while protecting data privacy. Summary of the invention
[0005] In order to solve the three class imbalance problems while protecting privacy and improve the classification performance and training efficiency of the model, the present invention proposes a bottom-up hierarchical federated learning method based on privacy protection, which includes the following steps:
[0006] Obtaining the global data distribution obtained by the central server after performing distribution evaluation on the data received in encrypted form from each client;
[0007] Perform mixed sampling combining oversampling and undersampling on local data according to the global data distribution, so that the global data distribution after sampling reaches a balanced state;
[0008] Different servers are selected from the bottom up to be added to the established n local servers according to their local data distribution, so that the data distribution in each server is finally close to a balanced data distribution.
[0009] Obtain the global model sent by the central server to the local server, and update the global model asynchronously until the last client sends the updated global model back to the local server. Each local server uploads the updated model to the central server for aggregate update, and iterates repeatedly.
[0010] Further, the global data distribution is obtained by the following steps:
[0011] During the system initialization phase, the central server generates a pair of public keys PK and private keys SK; the public key is used to encrypt data, and the private key is used to decrypt data, and sends them to each client;
[0012] Each client uses the public key to authenticate its data locally. i Encrypt and get the ciphertext data E(D i ), and distribute the ciphertext data to E(D i ) upload to the central server;
[0013] After receiving the ciphertext data uploaded by all clients, the central server uses the properties of homomorphic encryption to operate on the ciphertext data; all data distributions are summed up to obtain the global data distribution in ciphertext form E(V) = E(D1) + E(D2) + ... + E(D n ); then send the calculated global data distribution E(V) to each client;
[0014] After the client receives the global data distribution E(V) in ciphertext form from the central server, it decrypts it using the private key SK provided by the central server to obtain the global data distribution E(V) in plaintext form.
[0015] Input the global data distribution E(V) and the original local data of each client, and identify the majority class and minority class in the global data distribution respectively;
[0016] For each minority class p globally k , use the ADASYN algorithm to generate synthetic samples of the minority class, and calculate the number of samples required to be synthesized by the following formula:
[0017] G pk =(num majority -num pk )×β
[0018] Among them, G pk It is a minority class p k The number of samples to be synthesized, num majority Indicates the number of majority class samples, num pk represents the minority class p k The number of existing samples, β is a proportional factor used to control the number of synthetic samples generated for minority class samples. β determines the proportional relationship between the number of generated minority class samples and the number of majority class samples.
[0019] For each minority class sample in client c First calculate p in client c k The number of samples in each category
[0020]
[0021] Where N c is the total number of samples in client c, and N is the total number of samples of all clients.
[0022] For each minority class sample calculate The proportion of samples of other classes in the K nearest neighbors That is, the proportion of other categories of samples in the K nearest neighbors of the sample; normalization The normalization formula is as follows:
[0023]
[0024] Calculate the number of generated samples
[0025]
[0026] in is p in client c k The number of samples of the class.
[0027] To synthesize new samples, When, from Select a minority class sample s from the K nearest neighbors nn ,Then generate new synthetic samples using the formula:
[0028]
[0029] where s ynis a new synthetic sample, is the sample in each minority class, s nn is from Select a minority class sample from the K nearest neighbors, λ is a random number between 0 and 1;
[0030] For the majority class, K-means clustering is used for undersampling. For each majority class p, k samples are randomly selected as the initial cluster centers. Each sample is assigned to the nearest cluster center according to the calculated distance. The cluster centers are updated until the centers no longer change. Then the number of samples that should be extracted for each majority class is calculated:
[0031] G p =(num p -num majority )
[0032] Among them G p is the number of samples selected for each majority class, num p Indicates the number of existing samples of the majority class p, num minority Represents the number of minority class samples;
[0033] Finally, the same number of samples are randomly selected from each cluster as part of the training data set to achieve mixed sampling.
[0034] Furthermore, the steps for the client to select a server from the bottom up are as follows:
[0035] Create n local servers;
[0036] If there is no client in the local server, the client is randomly assigned to the local server; when all local servers have at least one client, the remaining clients to be selected will use cosine similarity to calculate the effect of joining different local servers. The cosine similarity calculation formula is:
[0037]
[0038] Where V′ represents the balanced global distribution, v j Represents client c j Data distribution on vl i ls for the local server i The larger the cosine similarity, the closer the local server data distribution is to the balanced distribution after the client joins. According to this principle, the optimal local server is selected until all clients are assigned to a local server.
[0039] Furthermore, the specific steps of the aggregation update of the model are as follows:
[0040] The central server initializes the global model parameter w0 and sends it to n local servers simultaneously;
[0041] After the local server receives the global model w0, it sends the global model parameter w0 to the first client c1. Client c1 uses local data to perform E rounds of training, updates the model parameters, obtains w1, and sends it to the local server.
[0042] The local server sends the updated parameter w1 to the next client c2. Client c2 performs E rounds of local training on the global model parameter w0, updates the global model parameter to w2, and sends the updated w2 to the local server.
[0043] Repeat the above process until the last client c managed by the local server m Completed round E of local training;
[0044] Repeat the above steps to update the process until the first round of E is executed l All local servers upload the updated parameters to the central server for aggregate update to obtain a new global model w'.
[0045] Continue to repeat the above steps until the set global training round E is reached.
[0046] Furthermore, the client trains the global model in the following steps:
[0047] The convolutional neural network (CNN) is used as the model structure. The input layer receives a grayscale image of size 28x28, passes through two convolutional layers, two pooling layers, and two fully connected layers; finally, it is connected to an output layer with 10 neurons; the activation function uses Softmax to convert the output value into a probability distribution, i.e., the prediction result; this model structure is suitable for the classification task of the MNIST dataset, and extracts image features and classifies them through a series of convolutional, pooling, and fully connected layers;
[0048] Calculate the cross entropy loss function, calculate the cross entropy loss between the prediction result output by the Softmax layer and the true label, and measure the difference between the network output and the true label.
[0049] Calculate the gradient of the cross entropy loss function and use the stochastic gradient descent algorithm to update the network parameters according to the gradient of the loss function;
[0050] The back propagation algorithm is used to calculate the gradient of the loss function with respect to the network parameters, and the network parameters are updated according to the gradient and the stochastic gradient descent algorithm to minimize the loss function; the above steps are repeated until the set training round ES is reached.
[0051] The present invention proposes a privacy-preserving bottom-up hierarchical federated learning method, which solves the global imbalance problem by combining oversampling and undersampling, and then uses a two-layer federated structure to solve the local imbalance problem. Different from the existing sampling methods, the present invention first uses a hybrid sampling method to achieve global data distribution balance. Since the sampling method requires the server to access the data distribution, in order to avoid client privacy leakage, the present invention adopts a homomorphic encryption method to calculate and broadcast the data distribution in ciphertext form. Since the data after sampling still has the problem of local imbalance, the present invention adopts a hierarchical federated architecture, using different local servers to manage clients of different distribution types. At the same time, in order to avoid data leakage to the local server, the present invention adopts a client bottom-up selection framework, and in order to be able to treat the clients managed by each group of local servers as a whole to achieve local balance, asynchronous updates are implemented in each local server. This method can balance the local distribution while avoiding the local server directly accessing the client's data distribution.
[0052] The present invention adopts a suitable framework to solve three types of imbalance problems in federated learning, and at the same time takes into account the problem of client privacy protection. Existing methods usually only take into account one type of imbalance problem and it is difficult to achieve privacy protection at the same time. The present invention is conducive to improving model training efficiency and protecting user privacy. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 A flowchart of the privacy-preserving bottom-up hierarchical federated learning method provided by the present invention;
[0054] Figure 2 Bottom-up hierarchical federated learning framework diagram DETAILED DESCRIPTION
[0055] The principles and features of the present invention are described below in conjunction with the accompanying drawings. The examples given are only used to explain the present invention and are not used to limit the scope of the present invention.
[0056] refer to Figure 1 The present invention provides a bottom-up hierarchical federated learning method based on privacy protection, comprising the following steps:
[0057] Step 1: Each client uploads its local data distribution to the server in a homomorphic encrypted manner. After receiving the encrypted data distribution from each client, the server evaluates the distribution to obtain the global data distribution and sends the global data distribution back to each client in encrypted form.
[0058] The homomorphic encryption process in step 1 includes the following steps:
[0059] Step 1.1: During the system initialization phase, the server generates a pair of public keys PK and private keys SK. The public key is used to encrypt data, and the private key is used to decrypt data, and sends them to each client.
[0060] Step 1.2: Each client uses the public key to authenticate its data D locally. i Encrypt and get the ciphertext data E(D i ), and distribute the ciphertext data to E(D i ) to the server.
[0061] Step 1.3: After receiving the ciphertext data uploaded by all clients, the server uses the properties of homomorphic encryption to operate on these ciphertext data. All data distributions are summed up to obtain the global data distribution in ciphertext form E(V) = E(D1) + E(D2) + ... + E(D n ). Then the calculated global data distribution E(V) is sent to each client.
[0062] Step 1.4: After the client receives the global data distribution E(V) in ciphertext form from the server, it decrypts it using the private key SK provided by the server to obtain the global data distribution E(V) in plaintext form.
[0063] Step 2: After receiving the global data distribution from the server, the client performs a mixed sampling of oversampling and undersampling on the local data according to the global data distribution, so that the global data distribution after sampling reaches a balanced state.
[0064] The hybrid sampling method combining client oversampling and undersampling in step 2 is as follows:
[0065] Step 2.1: Input the global data distribution E(V) and the original local data of each client, and identify the majority class and minority class in the global data distribution respectively.
[0066] Step 2.2: For each minority class p globally k , use the ADASYN algorithm to generate synthetic samples of the minority class, and calculate the number of samples required to be synthesized by the following formula:
[0067] G pk =(num majority -num pk )×β
[0068] Among them, G pk It is a minority class p k The number of samples to be synthesized, num majority Indicates the number of majority class samples, num pk represents the minority class p kThe number of existing samples, β is a proportional factor used to control the number of synthetic samples generated for minority class samples. β determines the proportional relationship between the number of generated minority class samples and the number of majority class samples.
[0069] For each minority class sample in client c First calculate p in client c k The number of samples in each category
[0070]
[0071] Where N c is the total number of samples in client c, and N is the total number of samples of all clients.
[0072] For each minority class sample calculate The proportion of samples of other classes in the K nearest neighbors That is, the proportion of other categories of samples in the K nearest neighbors of the sample; normalization The normalization formula is as follows:
[0073]
[0074] Calculate the number of generated samples
[0075]
[0076] in is p in client c k The number of samples of the class.
[0077] To synthesize new samples, When, from Select a minority class sample s from the K nearest neighbors nn ,Then generate new synthetic samples using the formula:
[0078]
[0079] where s yn is a new synthetic sample, is the sample in each minority class, s nn is from Select a minority class sample from the K nearest neighbors, λ is a random number between 0 and 1;
[0080] Step 2.3: For the majority class, use K-means clustering for undersampling. For each majority class p, randomly select k samples as the initial cluster center, assign each sample to the nearest cluster center according to the calculated distance; update the cluster center until the center no longer changes; then calculate the number of samples that should be extracted for each majority class:
[0081] G p =(num p -num majority );
[0082] Among them G p is the number of samples selected for each majority class, num p Indicates the number of existing samples of the majority class p, num minority Represents the number of minority class samples;
[0083] Finally, an equal number of samples are randomly selected from each cluster as part of the training dataset.
[0084] Step 3: Create Figure 2 As shown in the n local servers, the client selects to join different servers from the bottom up according to its local data distribution, so that the data distribution in each server is finally close to a balanced data distribution.
[0085] In step 3, the method of establishing n local servers and enabling the client to select servers from the bottom up is as follows:
[0086] Step 3.1. Create n local servers.
[0087] Step 3.2: If there is no client in the local server, randomly assign the client to the local server. When all local servers have at least one client, the remaining clients to be selected will use cosine similarity to calculate the effect of joining different local servers. The cosine similarity calculation formula is:
[0088]
[0089] Where V′ represents the balanced global distribution, v j Represents client c j Data distribution on vl i ls for the local server i The larger the cosine similarity, the closer the local server data distribution is to a balanced distribution after the client joins. According to this principle, the optimal local server is selected until all clients are assigned to a local server.
[0090] Step 4: The server sends the global model to the local server. The local server sends the received global model to the clients it manages. The clients update the model asynchronously until the last client sends the updated model back to the local server. Each local server uploads the updated model to the central server for aggregate update, and the process is repeated.
[0091] In step 4, the specific steps of the model aggregation update are as follows:
[0092] Step 4.1: The central server initializes the global model parameter w0 and sends it to n local servers simultaneously.
[0093] Step 4.2: After the local server receives the global model parameter w0, it sends the global model parameter w0 to the first client c1. Client c1 uses local data to perform E rounds of training, updates the model parameters, obtains w1, and sends it to the local server.
[0094] Step 4.3: The local server sends the updated parameter w1 to the next client c2. Client c2 performs round E of local training, updates the model parameter to w2, and sends the updated w2 to the local server.
[0095] Step 4.4: Repeat the above process until the last client c managed by the local server is m Completed round E of local training.
[0096] Step 4.5: Continue to repeat the update process of steps 4.2-4.4 until E is executed. l All local servers upload the updated parameters to the central server for aggregate update to obtain a new global model w'.
[0097] Step 4.6: Continue to repeat steps 4.1 to 4.5 until the set global training round E is reached.
[0098] In step 4.2, the specific steps of model training are as follows:
[0099] Step 4.2.1. We use a convolutional neural network (CNN) as the model structure. The input layer receives a grayscale image of size 28x28, which needs to go through two convolutional layers, two pooling layers, and two fully connected layers. Finally, an output layer is connected, and the output layer has 10 neurons. The activation function uses Softmax to convert the output value into a probability distribution, that is, the prediction result. This model structure is suitable for the classification task of the MNIST dataset, and extracts image features and classifies them through a series of convolutional, pooling, and fully connected layers.
[0100] Step 4.2.2, calculate the cross entropy loss function, calculate the cross entropy loss between the predicted result of the network output and the true label, and measure the difference between the network output and the true label.
[0101] Step 4.2.3: Calculate the gradient of the loss function and use the stochastic gradient descent algorithm to update the network parameters according to the gradient of the loss function.
[0102] Step 4.2.4: Use the back-propagation algorithm to calculate the gradient of the loss function with respect to the network parameters. Update the network parameters according to the gradient and the stochastic gradient descent algorithm to minimize the loss function.
[0103] Step 4.2.5: Repeat steps 4.2.1 to 4.2.4 until the set training round ES is reached.
[0104] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A bottom-up hierarchical federated learning method based on privacy protection. It is characterized in that The steps include: Obtaining the global data distribution obtained by the central server after performing distribution evaluation on the data received in encrypted form from each client; Perform mixed sampling combining oversampling and undersampling on local data according to the global data distribution, so that the global data distribution after sampling reaches a balanced state; Select different servers from the bottom up to join the n local servers established according to their local data distribution, so that the data distribution in each server is close to a balanced data distribution; Obtain the global model sent by the central server to the local server, and update the global model asynchronously until the last client sends the updated global model back to the local server. Each local server uploads the updated model to the central server for aggregate update, and iterates repeatedly.
2. The bottom-up hierarchical federated learning method based on privacy protection according to claim 1, Features: The global data distribution is obtained by the following steps: During the system initialization phase, the central server generates a pair of public keys PK and private keys SK; the public key is used to encrypt data, and the private key is used to decrypt data, and sends them to each client; Each client uses the public key to authenticate its data locally. i Encrypt and get the ciphertext data E(D i ), and distribute the ciphertext data to E(D i ) upload to the central server; After receiving the ciphertext data uploaded by all clients, the central server uses the properties of homomorphic encryption to operate on the ciphertext data; all data distributions are summed up to obtain the global data distribution E(V)=E(D 1 )+E(D 2 )+…+E(D n ); then send the calculated global data distribution E(V) to each client; After the client receives the global data distribution E(V) in ciphertext form from the central server, it decrypts it using the private key SK provided by the central server to obtain the global data distribution E(V) in plaintext form.
3. The bottom-up hierarchical federated learning method based on privacy protection according to claim 1, Features: Hybrid sampling includes the following steps: Input the global data distribution E(V) and the original local data of each client, and identify the majority class and minority class in the global data distribution respectively; For each minority class p globally k , use the ADASYN algorithm to generate synthetic samples of the minority class, and calculate the number of samples required to be synthesized by the following formula: G pk =(number) majority -num pk )×β; Among them, G pk It is a minority class p k The number of samples to be synthesized, num majority Indicates the number of majority class samples, num pk represents the minority class p k The number of existing samples, β is a proportional factor used to control the number of synthetic samples generated for minority class samples. β determines the proportional relationship between the number of generated minority class samples and the number of majority class samples; For each minority class sample in client c First calculate p in client c k The number of samples in each category Where N c is the total number of samples in client c, and N is the total number of samples of all clients; For each minority class sample calculate The proportion of samples of other classes in the K nearest neighbors That is, the proportion of samples of other categories in the K nearest neighbors of this sample; normalization The normalization formula is as follows: Calculate the number of generated samples in is p in client c k The number of samples in the class; Synthesize new samples, when When, from Select a minority class sample s from the K nearest neighbors nn ,Then generate new synthetic samples using the formula: where s yn is a new synthetic sample, is the sample in each minority class, s nn is from Select a minority class sample from the K nearest neighbors, λ is a random number between 0 and 1; For the majority class, K-means clustering is used for undersampling. For each majority class p, k samples are randomly selected as the initial cluster centers. Each sample is assigned to the nearest cluster center according to the calculated distance. The cluster centers are updated until the centers no longer change. Then the number of samples that should be extracted for each majority class is calculated: G p =(number) p -num majority ) Among them G p is the number of samples selected for each majority class, num p represents the number of existing samples of the majority class p, num minority Represents the number of minority class samples; Finally, the same number of samples are randomly selected from each cluster as part of the training data set to achieve mixed sampling.
4. The bottom-up hierarchical federated learning method based on privacy protection according to claim 3, Features: The steps for the client to select a server from the bottom up are as follows: Create n local servers; If there is no client in the local server, the client is randomly assigned to the local server; when all local servers have at least one client, the remaining clients to be selected will use cosine similarity to calculate the effect of joining different local servers. The cosine similarity calculation formula is: Cosine similarity Where V′ represents the balanced global distribution, v j Represents client c j Data distribution on vl i ls for the local server i The larger the cosine similarity, the closer the local server data distribution is to the balanced distribution after the client joins. According to this principle, the optimal local server is selected until all clients are assigned to a local server.
5. The bottom-up hierarchical federated learning method based on privacy protection according to claim 1, Features: The specific steps for the aggregation update of the model are as follows: The central server initializes the global model initial parameters w 0 , and send it to n local servers at the same time; The local server receives the global model initial parameters w 0 After that, the local server will set the global model parameter w 0 Sent to the first client c 1 , client c 1 Use local data to perform E rounds of training, update model parameters, and get w 1 , sent to the local server; The local server will update the parameter w 1 Send to the next client c 2 , client c 2 For the global model parameter w 0 Perform E rounds of local training and update the global model parameters to w 2 , and the updated w 2 Send to local server; Repeat the above process until the last client c managed by the local server m Completed round E of local training; Repeat the above steps to update the process until the first round of E is executed l Round till; All local servers upload the updated parameters to the central server for aggregate update to obtain a new global model w'; Continue to repeat the above steps until the set global training round E is reached.
6. The bottom-up hierarchical federated learning method based on privacy protection according to claim 5, Features: The client trains the global model as follows: The convolutional neural network (CNN) is used as the model structure. The input layer receives a grayscale image of size 28x28, passes through two convolutional layers, two pooling layers, and two fully connected layers; finally, it is connected to an output layer with 10 neurons; the activation function uses Softmax to convert the output value into a probability distribution, i.e., the prediction result; this model structure is suitable for the classification task of the MNIST dataset, and extracts image features and classifies them through a series of convolutional, pooling, and fully connected layers; Calculate the cross entropy loss function, calculate the cross entropy loss between the prediction result output by the Softmax layer and the true label, and measure the difference between the network output and the true label; Calculate the gradient of the cross entropy loss function and use the stochastic gradient descent algorithm to update the network parameters according to the gradient of the loss function; The back propagation algorithm is used to calculate the gradient of the loss function with respect to the network parameters, and the network parameters are updated according to the gradient and the stochastic gradient descent algorithm to minimize the loss function; the above steps are repeated until the set training round ES is reached.
Citation Information
Patent Citations
Medical disease analysis method based on migration federation learning
CN112420187A
Federal learning privacy protection method and system based on homomorphic encryption
CN117640253A
Three-layer asynchronous federal contrast learning method based on edge auxiliary pairing
CN117669779A
Systems and methods for user-edge association based on vehicle heterogeneity for reducing the heterogeneity in hierarchical federated learning networks
US20240265296A1
