Client data label imbalance detection method and system in federal learning

CN119886282AActive Publication Date: 2025-04-25HUAIAN KUNBO INFORMATION TECHNOLOGY CO LTD

Patent Information

Application Number
CN202411799766.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-09
Publication Date
2025-04-25
Estimated Expiration
2044-12-09

AI Technical Summary

Technical Problem

The problem of label imbalance of client data in federated learning leads to the model's bias towards most classes during training, ignoring the less common categories, affecting the generalization ability and overall performance of the model.

Method used

A comprehensive solution is built by combining generative adversarial networks, deep neural networks and federated learning models. First, a data set with known data distribution offsets are generated using the generative adversarial network, and then independent federated learning training is carried out on the server side, model parameters and data distribution offset labels are collected, and finally deep neural networks are driven for training to identify data distribution offsets.

Benefits of technology

Effectively identify and handle label imbalances in client data, improve the overall accuracy and generalization capabilities of the model, and ensure that the federated learning system can handle different types of data fairly.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119886282A_ABST
    Figure CN119886282A_ABST
Patent Text Reader

Abstract

The invention discloses a client data label imbalance detection method and system in federated learning, and the method comprises the following steps: (1) generating a plurality of data sets with known label distribution offset by using a verification data set held by a server in federated learning and a generative adversarial network, and obtaining a virtual client data set; (2) driving a federal learning model to be learned to train by using a virtual client data set and a known data set distribution type thereof, wherein the same model is initialized by the model to be learned of each virtual client; (3) after training is finished, extracting model parameters as features and virtual client data set distribution types as labels to form a new data set for training the client data set distribution types; (4) using the obtained data set to drive a label offset identification deep neural network model, and carrying out deep neural network model learning; and (5) after completing the training of the label offset identification deep neural network model, deploying the label offset identification deep neural network model to a federated learning server.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of distributed machine learning, and in particular relates to a method and system for detecting client data label imbalance in federated learning. Background Art

[0002] Federated learning is a distributed machine learning framework that allows multiple clients to jointly train a model without directly exchanging data. Each client trains the model on its own local data and then sends the updated model parameters or gradients to a central server for aggregation. This learning model ensures data privacy while allowing the advantages of large-scale datasets distributed around the world to be exploited.

[0003] However, a major problem faced by federated learning is the non-independent and identically distributed data held by the client, especially the imbalanced distribution of sample labels. In practical applications, the datasets held by the client often show that the number of samples in some categories is much larger than that in other categories, or the samples in some categories are almost non-existent. This label imbalance phenomenon may cause the model to favor the majority class during training, thereby ignoring those less common categories, which ultimately affects the generalization ability and overall performance of the model.

[0004] Therefore, it is urgent to design a method that can effectively identify the distribution bias of client data to solve the above technical problems in this field. Specifically, by real-time monitoring of data distribution bias, it can help understand the distribution characteristics of client data, ensure that the federated learning system can handle different types of data fairly, and avoid the degradation of model performance due to undetected bias, thereby improving the overall accuracy and generalization ability of the model. Based on this, the present invention provides a method and system for detecting client data label imbalance in federated learning. Summary of the invention

[0005] In view of the above situation, the present invention provides a method and system for detecting imbalanced client data labels in federated learning, so as to effectively identify the data distribution deviation from different clients, that is, the problem of data label imbalance. To this end, the present invention combines generative adversarial networks, deep neural networks and federated learning models to be trained to construct a comprehensive solution.

[0006] To achieve the above objectives, the present invention first uses a generative adversarial network to establish a data set with known data distribution offset; secondly, the server uses these data sets and the federated learning model to be trained to perform independent federated learning training, and collects parameter information and data distribution offset labels of the federated learning model to be trained; finally, these model parameters and data distribution offset labels are used to drive the deep neural network to train, thereby obtaining a deep neural network model that can identify data distribution offset. The specific technical solutions of the present invention are as follows:

[0007] A method for detecting client data label imbalance in federated learning, the main steps of which include a data set preprocessing stage, a virtual federated learning model training stage, a data set construction stage, a label offset identification deep neural network model training stage, and a model deployment stage, as follows:

[0008] (1) Dataset preprocessing stage

[0009] Use the validation dataset held by the server in federated learning and a generative adversarial network to generate various datasets with known label distribution offsets.

[0010] (2) Virtual federated learning model training phase

[0011] The virtual client dataset obtained in the above step and its known dataset distribution type drive the federated learning model to be learned for training; at this time, each virtual client model to be learned initializes the same model M 0 .

[0012] (3) Feature vector dataset creation stage

[0013] After the training is completed, the model parameters are extracted as features and the virtual client dataset distribution type is used as a label to form a new dataset for training the client dataset distribution type.

[0014] (4) Deep neural network model training phase for label shift recognition

[0015] Using the dataset obtained in the previous step, drive the label shift recognition deep neural network model M 1 , and conduct deep neural network model learning.

[0016] (5) Model deployment phase

[0017] After completing the training of the deep neural network model for label offset identification, the model is deployed to the actual federated learning server.

[0018] In the actual federated learning training process, for the newly joined client, its model is initialized to M 0 ; Then, according to the same configuration as in the virtual federated learning model training phase, let the real client use its private data set for model training, and the server accepts the model parameters uploaded by it; finally, the server extracts the uploaded model parameters and inputs the model M trained in the previous step 1 , get the client's dataset label offset distribution type.

[0019] Preferably, step (1) is specifically as follows: according to the label distribution offset setting of the required client, a corresponding data sample is randomly sampled from the verification data set held by the server; this sample is input into a generative adversarial network composed of a generator G and a discriminator D composed of a deep neural network to generate a new data sample; and finally a virtual client data set with a sufficient number and known data sample labels is obtained.

[0020] Preferably, the data set preprocessing and generative adversarial network generation phase in phase (1) is specifically as follows:

[0021] For a given server verification dataset, extract a single-label dataset D from the dataset according to each label i i . Each data set contains only samples with label i, that is:

[0022]

[0023] Among them, x j represents the jth data sample, y j Indicates its corresponding label, i is the label. With these single-label data D1, D2, ..., D n Based on the above, these datasets are expanded by generating adversarial networks so that the sample size of each single-label dataset is large enough to accommodate model training.

[0024] Specifically, the present invention constructs a deep neural network as a generator G for learning data features from each single-label dataset. The input of the generator G is from the single-label dataset D i The generator generates samples with similar features (which can be judged by the set threshold) based on the characteristics of the target dataset.

[0025] The loss function of the generator is defined as:

[0026] Where E represents the expected difference between the generated image distribution and the real image distribution, x i ′ is the sample set generated by the generator G, D(x i ′) is the probability that the discriminator determines whether the sample set is real. The generator improves the quality of the generated samples by minimizing this loss function.

[0027] The generated new sample set G(D i ) will be added to the original dataset to expand the sample size. This means that the generator tries to deceive the discriminator, making the discriminator D think that the generated samples come from real data, thereby gradually improving the authenticity of the generated samples.

[0028] The discriminator D receives data from two sources: one part comes from the real single-label dataset D i , and the other part comes from the new sample set G(D i ). The goal of the discriminator is to distinguish real data from generated data. The loss function of the discriminator is defined as:

[0029]

[0030] The discriminator attempts to maximize the accuracy of the judgment of real data while minimizing the misjudgment of the generated data. In the process of generating adversarial networks, the generator and the discriminator are optimized alternately to improve the data quality. The discriminator performs the following steps:

[0031] 1. From the real single-label dataset D i A batch of real samples are randomly sampled from the i .

[0032] 2. Use the generator to extract the corresponding single-label dataset x i Generate samples in , denoted as x i ′.

[0033] 3. Calculate the loss function of the discriminator:

[0034]

[0035] Among them, m is the amount of data.

[0036] 4. Use the gradient descent method to minimize the discriminator's loss function and update the discriminator parameters:

[0037]

[0038] Among them, η is the set learning rate.

[0039] The generator executes the following steps:

[0040] 1. The generator generates samples x i ′, and the authenticity scores of these samples are calculated by the discriminator.

[0041] 2. Calculate the loss function of the generator:

[0042]

[0043] 3. Use the gradient descent method to minimize the generator's loss function and update the generator parameters:

[0044]

[0045] The discriminator and generator are updated alternately until the generated samples meet the expected goals, such as the generator and discriminator loss functions converge to stable values, and the next single-label dataset is trained until all categories of datasets are trained.

[0046] Preferably, the model training phase in phase (2) is specifically as follows:

[0047] Take the same number of samples from each dataset to form a new dataset

[0048] First, from the basic data set The proportion of main class data is determined in , so as to generate new datasets with different data distribution shift characteristics.

[0049] Set up the initial global model M on the server side 0 . Shift the dataset according to the n data distribution generated in the previous step For each data set Configure independent training tasks.

[0050] Each dataset will be initialized using a separate model M 0 For training, set the number of local iteration updates E and the learning rate η for each dataset, and use the same training model structure, loss function, and optimization algorithm for each training task. These parameters are kept consistent across datasets to ensure that the model training process is comparable and consistent. All settings and training in this process are performed on the server.

[0051] After the configuration is complete, the server starts all independent training tasks.

[0052] Each dataset For each data set, in each round of training, firstly, the model f(x i θ t ) for the input sample x i Perform forward propagation to calculate the predicted value θ t are the model parameters at the tth iteration, including the weight W t and bias b t .

[0053] Next, according to the true label y i and predicted values Calculate the loss function L t , the formula is as follows:

[0054]

[0055] Where m is the number of samples, The cross entropy loss function is used. The gradient of the loss function is L t Calculated by back propagation algorithm:

[0056]

[0057] Then, the model parameters θ are adjusted using the learning rate η t To update:

[0058]

[0059] Among them, W t+1 and b ti1 are the model weights and biases after the t+1th iteration. In each iteration, the model parameters θ t The model performance is gradually optimized through multiple forward and backward propagation cycles. Finally, after reaching the predetermined training round T, the final parameter θ of the model is recorded. T .

[0060] This process is repeated, with each dataset completing training independently, until the model parameters for all datasets meet the expected performance requirements.

[0061] Preferably, the stage (3) of preparing the feature vector data set is as follows:

[0062] After training is completed, the server collects each data set Model parameter information after training θ n , which includes weights W and biases. The collected model parameters are flattened to construct feature vectors. Each feature vector v i Contains data from a specific dataset The model parameters θ n , forming the input features of subsequent learning tasks.

[0063] Each feature vector v n Equipped with a label n , the label is combined with the dataset The label format is "data distribution offset", where the data distribution offset part represents the proportion of each label in the data set.

[0064] Model parameter vector v n and label l n Forming sample pairs <v n ,l n >. All generated feature vectors v n and the corresponding label l nIntegrate into the final training data set and store it in CSV format. Each row represents a sample, containing a series of feature values ​​and a label. The formula is as follows:

[0065] CSV_row = {v n ,l n}

[0066] The feature vector is composed of model parameter data, and each feature represents the parameter value of the model on a specific data set. The final data set file will be stored in a server or cloud storage system for subsequent model training or analysis.

[0067] Validate the collected model parameter data to check data integrity and accuracy. Remove any outliers or corrupted data points to ensure that each feature vector v n are complete and correct, and the label l n Correctly reflects data distribution offset configuration.

[0068] By using multiple datasets with different distribution shifts The training process shown above is performed multiple times to generate a sufficient number of sample data sets to provide sufficient training data for subsequent classification or regression tasks.

[0069] Preferably, in step (4), M 1 A multi-layer perceptron structure is adopted and the cross entropy loss function is used for training to optimize the model to accurately predict the label distribution classification.

[0070] Preferably, the label shift recognition model training phase (4) is specifically as follows:

[0071] Use the prepared samples to train the data distribution shift detection model, and select a deep neural network as the training model. Specifically, a multi-layer perceptron structure is adopted, including an input layer, several hidden layers, and an output layer.

[0072] The dimension of the input layer matches the dimension of the feature vector, the hidden layer uses the ReLU activation function to increase the nonlinear processing capability, and the activation function of the output layer selects the softmax function.

[0073] The specific training process is as follows:

[0074] The feature vectors in each data set are input into the deep neural network for training. The model calculates the linear combination result z of each feature vector in each iteration. This value is used to predict the degree of data distribution deviation of the data set.

[0075] Calculate and apply the mean square error loss function to evaluate the prediction accuracy of the model. The loss function formula is:

[0076]

[0077] Among them, y is the actual label value, is the predicted value of the model and n is the number of samples.

[0078] The back propagation algorithm is used to automatically calculate the gradient of the loss function with respect to each weight, and then the gradient descent method is applied to update the weights and biases of the network. The update formula for each weight is:

[0079]

[0080] Among them, η represents the learning rate, is the gradient of the loss function with respect to the weights. This training process is repeated until the predetermined training round is reached or the model performance reaches a satisfactory level.

[0081] After the training is completed, important information about the training process is collected and fed back from the central server, including the performance of the global model on the training set and the validation set.

[0082] Model performance evaluation includes calculating precision, recall, and F1 score to ensure a comprehensive assessment of the overall performance of the model.

[0083] Based on the evaluation results, adjust the network structure and hyperparameters, or re-obtain more gradient descent samples and retrain the model to optimize performance.

[0084] Preferably, the model deployment phase of phase (5) is specifically as follows:

[0085] After completing the training and verification of the label shift recognition deep neural network model, the model is deployed to the actual federated learning server. For the newly joined client, its local model is first initialized to the initial model M 0 .

[0086] The client uses its private dataset to train the model, and the training process follows the same parameter settings as in phase (2). After the training is completed, the client uploads the model parameters obtained from its local training to the federated learning server.

[0087] The server receives the model parameters uploaded by the client and combines them with the model M trained in the previous step 1 By extracting the relevant model parameters uploaded by the client, the server can identify and infer the label offset distribution type of the client data set. The deployed model analyzes the received gradient data and predicts the degree of offset of the data set. The model's prediction results guide the client to adjust its data collection or training strategy, which can reduce data offset and improve the overall training effect and accuracy of the model.

[0088] The present invention also discloses a client data label imbalance detection system in a federated learning environment, which is used to execute the above method and includes the following modules:

[0089] Dataset preprocessing module: Use the verification dataset held by the server in federated learning and the generative adversarial network to generate various datasets with known label distribution offsets; this module preprocesses the verification dataset held by the server and sorts out multiple datasets with only a single label.

[0090] Generative adversarial network module: According to the label distribution offset setting of the client, the corresponding data sample is randomly sampled from the verification data set held by the server; this data sample is input into the generative adversarial network composed of the generator G composed of a deep neural network and the discriminator D to generate new data samples; finally, a set number of virtual client data sets with known data sample labels are obtained; in this module, the generative adversarial network contains a generator and a discriminator, which are used to generate data samples with specified characteristics.

[0091] Model training module: Use the obtained virtual client dataset and its known dataset distribution type to drive the federated learning model to be learned for training; each virtual client model to be learned initializes the same model M 0 ; In this module, the server manages the independent training tasks of each data set and is responsible for organizing and coordinating the entire training process. The main responsibilities of this module include model initialization, training task allocation, and model parameter collection after each data set is trained. It also handles all coordination work related to training to ensure that the final generated model parameters can be used for subsequent analysis and application.

[0092] Label offset detection and feature vector generation module: After the model training module is completed, the model parameters are extracted as features and the virtual client data set distribution type is used as a label to form a new data set for training the client data set distribution type; based on the model parameter information collected during the model training process, this module generates feature vectors, and combines the actual label offset of the data set and the number of iterations to assign corresponding labels to each vector.

[0093] Deep neural network training module: Use the data set obtained by the label shift detection and feature vector generation module to drive the label shift identification deep neural network model M1 and carry out deep neural network model learning; this module uses the feature vectors and labels generated in the previous stage to train the deep neural network to identify label shifts in the data. The deep neural network model adopts a multi-layer perceptron structure and uses the mean square error loss function for training to optimize the model to accurately predict label shifts.

[0094] Model deployment module: After completing the training of the label shift identification deep neural network model, the model is deployed to the actual federated learning production environment. The deployed model can monitor the label shift of the client's data set in real time.

[0095] The present invention uses generative adversarial networks and sampling techniques to establish data sets with data distribution offsets, and independently trains these data sets on the server side to collect model parameter information after training. Through these model parameters, further training is carried out in combination with deep neural networks to build a model that can accurately identify data distribution offsets.

[0096] The present invention combines a generative adversarial network, a deep neural network and a federated learning framework, and provides a method and system for detecting client data label imbalance in a federated learning environment, so as to effectively identify and process the problem of data distribution deviation from multiple data sources.

[0097] The present invention is dedicated to detecting the problem of data label imbalance in a federated learning environment and accurately displaying the actual distribution of data. The design of the present invention can be combined with other data preprocessing or model adjustment techniques to form a more comprehensive strategy. Specifically, the present invention can guide the implementation of adjustment measures such as data resampling or model weight adjustment to effectively combat problems caused by data offset. This targeted training strategy enhances the model's ability to handle non-uniform data from multiple sources, thereby improving the accuracy and fairness of the model in practical applications. BRIEF DESCRIPTION OF THE DRAWINGS

[0098] Figure 1 The present invention is a flowchart of a method for detecting client data label imbalance in a federated learning environment according to a preferred embodiment of the present invention.

[0099] Figure 2 This is an architecture diagram of a client data label imbalance detection system in a federated learning environment according to a preferred embodiment of the present invention.

[0100] Figure 3 This is a block diagram of a client data label imbalance detection system in a federated learning environment according to a preferred embodiment of the present invention. DETAILED DESCRIPTION

[0101] The preferred embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0102] This paper uses generative adversarial networks and sampling techniques to construct datasets with data distribution offsets. Through the federated learning framework, multiple clients collaborate to train models on these datasets while collecting gradient information. Then, deep neural networks are used to process this information and develop models that can accurately identify data distribution offsets, such as Figure 2 shown.

[0103] like Figure 1 As shown, this embodiment provides a method for detecting client data label imbalance in a federated learning environment, which is performed in the following steps:

[0104] (1) Dataset preprocessing and generative adversarial network generation

[0105] Use the validation dataset held by the server in federated learning and the generative adversarial network to generate various datasets with known label distribution offsets. Specifically, according to the label distribution offset setting of the required client, randomly sample the corresponding data sample from the validation dataset held by the server; input this sample to the generative adversarial network composed of the generator G and the discriminator D composed of a deep neural network to generate a new data sample; finally, a virtual client dataset with a sufficient number and known data sample labels is obtained.

[0106] Specifically, for a given server verification dataset, a single-label dataset D is extracted from the dataset according to each label i i . Each data set contains only samples with label i, that is:

[0107]

[0108] Among them, x j represents the data sample, y j Indicates its corresponding label, i is the label. With these single-label data D1, D2, ..., D n Based on the above, these datasets are expanded by generating adversarial networks so that the sample size of each single-label dataset is large enough to accommodate model training.

[0109] Construct a deep neural network as a generator G to learn data features from each single-label dataset. The input of the generator G is from the single-label dataset D i The generator generates samples with similar characteristics based on the characteristics of the target dataset, which is specifically expressed as:

[0110] G(D i )={x i1 ′,x i2 ′,…,x im ′}

[0111] The loss function of the generator is defined as:

[0112]

[0113] Where E represents the expected difference between the generated image distribution and the real image distribution, x i ′ is the sample set generated by the generator G, D(x i′) is the probability that the discriminator determines whether the sample set is real. The generator improves the quality of the generated samples by minimizing this loss function.

[0114] The generated new sample set G(D i ) will be added to the original dataset to expand the sample size. This means that the generator tries to deceive the discriminator and make D think that the generated samples come from real data, thereby gradually improving the authenticity of the generated samples.

[0115] The discriminator D receives data from two sources: one part comes from the real single-label dataset D i , and the other part comes from the new sample set G(D i ). The goal of the discriminator is to distinguish real data from generated data. The loss function of the discriminator is defined as:

[0116]

[0117] The discriminator attempts to maximize the accuracy of the judgment of real data while minimizing the misjudgment of the generated data. In the process of generating adversarial networks, the generator and the discriminator are optimized alternately to improve the data quality. The discriminator performs the following steps:

[0118] 1. From the real single-label dataset D i A batch of real samples are randomly sampled from the i .

[0119] 2. Use the generator to extract the corresponding single-label dataset x i Generate samples in , denoted as x i ′.

[0120] 3. Calculate the loss function of the discriminator:

[0121]

[0122] Among them, m is the amount of data.

[0123] 4. Use the gradient descent method to minimize the discriminator's loss function and update the discriminator parameters:

[0124]

[0125] Among them, η is the set learning rate.

[0126] The generator executes the following steps:

[0127] 1. The generator generates samples x i ′, and the authenticity scores of these samples are calculated by the discriminator.

[0128] 2. Calculate the loss function of the generator:

[0129]

[0130] 3. Use the gradient descent method to minimize the generator's loss function and update the generator parameters:

[0131]

[0132] The discriminator and generator are updated alternately until the generated samples meet the expected goals, such as the generator and discriminator loss functions converge to stable values, and the next single-label dataset is trained until all categories of datasets are trained.

[0133] (2) Virtual Federated Learning Model Training

[0134] Take the same number of samples from each dataset to form a new dataset

[0135] First, from the basic data set Determine the proportion of main class data in , so as to generate new datasets with different data distribution shift characteristics. Take the main category data with a ratio of α (60%, 75%, 90%, etc.), and extract samples from other categories of data sets in equal amounts, and merge them into a data set with a ratio of β (α+β=1). Mix the main category data with other category data in a set ratio to form a new data set. Repeat this process to create multiple data distribution offset datasets as needed, such as Etc., each with a different ratio of label combinations. These new datasets simulate different data distribution shifts by changing the ratio of the original labels in the dataset.

[0136] Set up the initial global model M on the server side 0 . Shift the dataset according to the n data distribution generated in the previous step For each data set Configure independent training tasks.

[0137] Each dataset will be initialized using a separate model M 0 Perform training, set the number of local iteration updates E and the learning rate η for each dataset, and use the same training model structure, loss function, and optimization algorithm for each training task. These parameters are kept consistent across datasets to ensure that the model training process is comparable and consistent. It should be noted that all settings and training in this process are performed on the server.

[0138] After the configuration is complete, the server starts all independent training tasks.

[0139] Each dataset For each data set, in each round of training, firstly, the model f(x i θ t ) for the input sample x i Perform forward propagation to calculate the predicted value The formula is:

[0140]

[0141] Here θ t is the model parameter at the tth iteration. Model parameter θ t Including weight W t and bias b t , the formula is:

[0142] θ t = {W t ,b t}

[0143] Next, according to the true label y i and predicted values Calculate the loss function L t , the formula is as follows:

[0144]

[0145] Where m is the number of samples, Use common loss functions such as cross entropy. The gradient of the loss function L t Calculated by back propagation algorithm:

[0146]

[0147] Then, the model parameters θ are adjusted using the learning rate η t To update:

[0148]

[0149] Among them, W t+1 and b t+1 are the model weights and biases after the t+1th iteration. In each iteration, the model parameters θ t The model performance is gradually optimized through multiple forward and backward propagation cycles. Finally, after reaching the predetermined training round T, the final parameter θ of the model is recorded. T .

[0150] This process is repeated, with each dataset completing training independently, until the model parameters for all datasets meet the expected performance requirements.

[0151] (3) Feature vector dataset creation

[0152] After training is completed, the server collects each data set Model parameter information after training θ n , which includes weight W and bias b, namely:

[0153]

[0154] The collected model parameters are flattened to construct feature vectors. Each feature vector v i Contains data from a specific dataset The model parameters θ n , forming the input features of subsequent learning tasks.

[0155] Each feature vector v n Equipped with a label n , the label is combined with the dataset The label format is "data distribution offset", where the data distribution offset part represents the proportion of each label in the data set. For example, if the proportion of label b in the data set is 90% and the proportion of label a is 10%, then the label can be represented as "1a9b". Specifically, assuming that the data set D shift There are two labels a and b in the system, label a accounts for 10% and label b accounts for 90%. The corresponding label l n is "1a9b".

[0156] Model parameter vector v n and label l n Forming sample pairs <v n ,l n >. All generated feature vectors v n and the corresponding label l n Integrate into the final training data set and store it in CSV format. Each row represents a sample, containing a series of feature values ​​and a label. The formula is as follows:

[0157] CSV_row = {v n ,l n}

[0158] The feature vector is composed of model parameter data, and each feature represents the parameter value of the model on a specific data set. The final data set file will be stored in a server or cloud storage system for subsequent model training or analysis.

[0159] Validate the collected model parameter data to check data integrity and accuracy. Remove any outliers or corrupted data points to ensure that each feature vector v n are complete and correct, and the label ln Correctly reflects data distribution offset configuration.

[0160] By using multiple datasets with different distribution shifts The training process shown above is performed multiple times to generate a sufficient number of sample data sets to provide sufficient training data for subsequent classification or regression tasks.

[0161] (4) Deep neural network model training for label shift recognition

[0162] Use the prepared samples to train the data distribution shift detection model, and select a deep neural network as the training model. Specifically, a multi-layer perceptron structure is adopted, including an input layer, several hidden layers, and an output layer.

[0163] The dimension of the input layer matches the dimension of the feature vector, the hidden layer uses the ReLU activation function to increase the nonlinear processing capability, and the activation function of the output layer selects the softmax function.

[0164] The specific training process is as follows:

[0165] The feature vectors in each data set are input into the deep neural network for training. The model calculates the linear combination result z of each feature vector in each iteration. This value is used to predict the degree of data distribution deviation of the data set.

[0166] Calculate and apply the mean square error loss function to evaluate the prediction accuracy of the model. The loss function formula is:

[0167]

[0168] Among them, y is the actual label value, is the predicted value of the model and n is the number of samples.

[0169] The back propagation algorithm is used to automatically calculate the gradient of the loss function with respect to each weight, and then the gradient descent method is applied to update the weights and biases of the network. The update formula for each weight is:

[0170]

[0171] Among them, η represents the learning rate, is the gradient of the loss function with respect to the weights. This training process is repeated until the predetermined training round is reached or the model performance reaches a satisfactory level.

[0172] After the training is completed, important information about the training process is collected and fed back from the central server, including the performance of the global model on the training set and the validation set.

[0173] Model performance evaluation includes calculating accuracy, recall, and F1 score to ensure a comprehensive evaluation of the overall performance of the model. The calculation formulas for accuracy, recall, and F1 score are as follows:

[0174]

[0175]

[0176] Among them, TP, TN, FP, and FN represent true positives, true negatives, false positives, and false negatives, respectively.

[0177] Based on the evaluation results, adjust the network structure and hyperparameters, or re-obtain more gradient descent samples and retrain the model to optimize performance.

[0178] (5) Model deployment

[0179] After completing the training and verification of the label shift recognition deep neural network model, the model is deployed to the actual federated learning server. For the newly joined client, its local model is first initialized to the initial model M 0 .

[0180] The client uses its private dataset to train the model, and the training process follows the same parameter settings as in phase (2). After the training is completed, the client uploads the model parameters obtained from its local training to the federated learning server.

[0181] The server receives the model parameters uploaded by the client and combines them with the model M trained in the previous step 1 By extracting the relevant model parameters uploaded by the client, the server can identify and infer the label offset distribution type of the client data set. The deployed model analyzes the received gradient data and predicts the degree of offset of the data set. The model's prediction results guide the client to adjust its data collection or training strategy, which can reduce data offset and improve the overall training effect and accuracy of the model.

[0182] like Figure 3 As shown, this embodiment discloses a client data label imbalance detection system in a federated learning environment, which is used to execute the above method embodiment, and includes the following modules:

[0183] Dataset preprocessing module: Use the verification dataset held by the server in federated learning and the generative adversarial network to generate various datasets with known label distribution offsets; in this module, the verification dataset held by the server is preprocessed to sort out multiple datasets with only a single label.

[0184] Generative adversarial network module: According to the label distribution offset setting of the client, the corresponding data sample is randomly sampled from the verification data set held by the server; this data sample is input into the generative adversarial network composed of the generator G composed of a deep neural network and the discriminator D to generate new data samples; finally, a set number of virtual client data sets with known data sample labels are obtained; in this module, the generative adversarial network contains a generator and a discriminator, which are used to generate data samples with specified characteristics.

[0185] Model training module: Use the obtained virtual client dataset and its known dataset distribution type to drive the federated learning model to be learned for training; each virtual client model to be learned initializes the same model M 0 ; Manage independent training tasks for each data set on the server side, and be responsible for organizing and coordinating the entire training process. The main responsibilities of this module include model initialization, training task allocation, and model parameter collection after each data set is trained. It also handles all coordination work related to training to ensure that the final generated model parameters can be used for subsequent analysis and application.

[0186] Label offset detection and feature vector generation module: After the model training module is completed, the model parameters are extracted as features and the virtual client data set distribution type is used as a label to form a new data set for training the client data set distribution type; based on the model parameter information collected during the model training process, this module generates feature vectors, and combines the actual label offset of the data set and the number of iterations to assign corresponding labels to each vector.

[0187] Deep neural network training module: Use the data set obtained by the label shift detection and feature vector generation module to drive the label shift recognition deep neural network model M 1 , conduct deep neural network model learning; use the feature vectors and labels generated in the previous stage to train the deep neural network to identify label shifts in the data. The deep neural network model uses a multi-layer perceptron structure and is trained using the mean square error loss function to optimize the model to accurately predict label shifts.

[0188] Model deployment module: After completing the training and verification of the label shift identification deep neural network model, the model is deployed to the actual federated learning production environment. The deployed model can monitor the label shift of the client's data set in real time.

[0189] For other contents of this embodiment, please refer to the above method embodiment.

[0190] The above description is only a preferred embodiment of the method of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may also include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. A method for detecting imbalanced client data labels in federated learning, characterized in that: The specific steps are as follows: (1) Use the verification dataset held by the server in federated learning and the generative adversarial network to generate multiple datasets with known label distribution offsets to obtain a virtual client dataset; (2) The federated learning model to be learned is trained using the virtual client dataset and its known dataset distribution type. Each virtual client’s model to be learned initializes the same model M 0 ; (3) After the training of step (2) is completed, the model parameters are extracted as features, and the virtual client data set distribution type is used as a label to form a new data set for training the client data set distribution type; (4) Using the data set obtained in step (3), drive the label shift recognition deep neural network model M 1 , carry out deep neural network model learning; (5) After completing the training of the label shift recognition deep neural network model, the label shift recognition deep neural network model is deployed to the federated learning server.

2. The method for detecting client data label imbalance in federated learning according to claim 1, wherein: In step (1), according to the label distribution offset setting of the client, the corresponding data sample is randomly sampled from the verification data set held by the server; this data sample is input into the generative adversarial network composed of the generator G composed of the deep neural network and the discriminator D to generate a new data sample; finally, a virtual client data set with a set number and known data sample labels is obtained.

3. The method for detecting client data label imbalance in federated learning according to claim 2, wherein: step( 1), for a given server verification dataset, a single-label dataset D is extracted from the dataset according to each label i i , each data set contains only samples with label i, that is: Among them, x j represents the jth data sample, y j Indicates the corresponding label, i is the label.

4. The method for detecting client data label imbalance in federated learning according to claim 3, wherein: In step (1), a deep neural network is constructed as a generator G to learn data features from each single-label dataset; The input of the generator G comes from the single-label dataset D i The generator generates samples with similar characteristics based on the characteristics of the target dataset. The loss function of the generator is defined as: Where E represents the expected difference between the generated image distribution and the real image distribution, x i ′ is the sample set generated by the generator G, D(x i ′) is the probability that the discriminator determines whether the sample set is real; The generated new sample set G(D i ) is added to the original dataset.

5. A method for detecting imbalanced client data labels in federated learning as claimed in claim 4, characterized in that: The device D receives data from two sources: one part comes from the real single-label dataset D i , and the other part comes from the new sample set G(D i ); the loss function of the discriminator is defined as:

6. A method for detecting client data label imbalance in federated learning as claimed in claim 5, characterized in that: Step (2) is as follows: Take the same number of samples from each virtual client dataset to form a new dataset From the basic data set Determine the proportion of main class data in order to generate new data sets with different data distribution shift characteristics; Set up the initial global model M on the server side 0 , according to the obtained n data distribution offset data set For each data set Configure independent training tasks; Each data distribution offset dataset is initialized using a separate model M 0 Perform training, set the number of local iteration updates E and the learning rate η for each data distribution offset dataset, and use the same training configuration for each training task; After the configuration is complete, the server starts all independent training tasks; Each dataset Perform independent iterative updates; for each data set, in each round of training, first pass the model f(x i θ t ) for the input sample x i Perform forward propagation to calculate the predicted value θ t are the model parameters at the tth iteration, including the weight W t and bias b t ; According to the true label y i and predicted values Calculate the loss function L t , the formula is as follows: Where m is the number of samples, Using the cross entropy loss function, the gradient of the loss function Calculated by back propagation algorithm: Use the learning rate η to adjust the model parameters θ t To update: Among them, W t+1 and b t+1 are the model weights and biases after the t+1th iteration respectively; in each iteration, the model parameter θ t Update; finally, after reaching the predetermined training round T, record the final parameter θ of the model T .

7. The method for detecting client data label imbalance in federated learning according to claim 6, characterized in that: Step (3) is as follows: The server collects each dataset Model parameter information after training θ n , including weights W and biases, use the collected model parameters to flatten and construct feature vectors, each feature vector v i Contains data from a specific dataset The model parameters θ n , forming the input features of subsequent learning tasks; Each Eigenvector v n Equipped with a label n , the label is combined with the dataset The data distribution offset configuration is defined; the label format is "data distribution offset", where the data distribution offset part represents the proportion of each label in the data set; Model parameter vector v n and label l n Forming sample pairs <v n ,l n >; All generated feature vectors v n and the corresponding label l n Integrate into the final training data set and store it in CSV format; each line represents a sample, containing a series of feature values ​​and a label; the formula is as follows: CSV_row={v n ,l n } The feature vector consists of model parameter data, and each feature represents the parameter value of the model on a specific data set.

8. The method for detecting client data label imbalance in federated learning according to claim 7, characterized in that: In step (3), the collected model parameter data is verified, outliers or damaged data points are deleted, and each feature vector v n are complete, accurate, and labeled n Correctly reflects data distribution offset configuration.

9. A method for detecting client data label imbalance in federated learning according to any one of claims 6 to 8, characterized in that: In step (4), M 1 A multi-layer perceptron structure is used and the cross entropy loss function is used for training; step (4) is as follows: The samples are trained with a data distribution deviation detection model, and a deep neural network model is selected as the training model. A multi-layer perceptron structure is adopted, including an input layer, several hidden layers, and an output layer. The dimension of the input layer matches the dimension of the feature vector, the hidden layer uses the ReLU activation function, and the output layer uses the softmax function as the activation function; The specific training process is as follows: (1) The feature vectors in each data set are input into the deep neural network model for training. The model calculates the linear combination result z of each feature vector in each iteration. This value is used to predict the degree of data distribution deviation of the data set. (2) Calculate and apply the mean square error loss function to evaluate the prediction accuracy of the model. The loss function formula is: Among them, y is the actual label value, is the predicted value of the model, and n is the number of samples; (3) Use the back-propagation algorithm to calculate the gradient of the loss function with respect to each weight, and then apply the gradient descent method to update the weights and biases of the network; the update formula for each weight and bias is: Among them, η represents the learning rate, is the gradient of the loss function with respect to the weight; The training process is repeated until the predetermined number of training rounds is reached or the model performance reaches a set satisfaction level.

10. A client data label imbalance detection system in a federated learning environment, used to execute the method according to any one of claims 2 to 9, comprising the following modules: Dataset preprocessing module: Use the validation dataset held by the server in federated learning and the generative adversarial network to generate various datasets with known label distribution offsets; Generative adversarial network module: According to the label distribution offset setting of the client, the corresponding data sample is randomly sampled from the verification data set held by the server; this data sample is input into the generative adversarial network composed of the generator G and the discriminator D composed of the deep neural network to generate new data samples; finally, a set number of virtual client data sets with known data sample labels are obtained; Model training module: uses the obtained virtual client dataset and its known dataset distribution type to drive the federated learning model to be learned for training; Each virtual client's model to be learned initializes the same model M 0 ; Label offset detection and feature vector generation module: After the model training module completes the training, it extracts the model parameters as features and the virtual client dataset distribution type as a label to form a new dataset for training the client dataset distribution type; Deep neural network training module: Use the data set obtained by the label shift detection and feature vector generation module to drive the label shift recognition deep neural network model M 1 , carry out deep neural network model learning; Model deployment module: After completing the training of the label shift recognition deep neural network model, the model is deployed to the federated learning production environment.

Citation Information

Patent Citations

  • Federal contrast clustering learning method and system for non-independent identically distributed data

    CN115563519A

  • Federal learning method for class imbalance data distribution

    CN116561622A

  • Federal learning method for non-independent identically distributed and unbalanced data set

    CN117829270A

  • Safe and efficient federated learning system and method based on generative adversarial network

    CN118133931A

Cited By

  • Feature-based label recovery method and system in federated learning without classifier transmission

    CN121031772A