A method and system for detecting client data label imbalance in federated learning

By constructing a dataset using generative adversarial networks and deep neural networks, and combining it with a federated learning framework, the problem of imbalanced labels in client data is identified and addressed, thus solving the problem of model training being biased towards the majority class and improving the model's accuracy and generalization ability.

CN119886282BActive Publication Date: 2025-10-21HUAIAN KUNBO INFORMATION TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

The label imbalance of client data in federated learning causes model training to be biased towards the majority category, affecting the model's generalization ability and overall performance.

Method used

Generative adversarial networks are used to generate datasets with known data distribution offsets. A deep neural network model for label offset recognition is constructed by combining deep neural networks and federated learning models. The model is trained and deployed on the server side to identify and process the label offsets of the client dataset.

Benefits of technology

Effectively identify and handle data distribution shifts to improve model accuracy and generalization ability, guide data acquisition or training strategy adjustments, and enhance overall model performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119886282B_ABST
    Figure CN119886282B_ABST
Patent Text Reader

Abstract

The application discloses a kind of federal learning in client data label imbalance detection method and system, method as follows: (1) using the validation dataset held in federal learning in server and generating a variety of label distribution offset known data set with generative adversarial network, obtain virtual client dataset;(2) with virtual client dataset and its known data set distribution type driving the federal learning model to be learned to carry out training, and the model to be learned of each virtual client is initialized with same model;(3) after training, extract model parameters as features, virtual client dataset distribution type as label, constitute the new data set for training client dataset distribution type;(4) using the data set obtained, drive label offset identification deep neural network model, carry out deep neural network model learning;(5) after completing label offset identification deep neural network model training, label offset identification deep neural network model is deployed to federal 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 specifically 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 leveraging the advantages of large-scale, globally distributed datasets.

[0003] However, a major challenge facing federated learning is the non-independent and identically distributed nature of client-held data, particularly the imbalance in sample label distribution. In practical applications, client-held datasets often exhibit a significant excess of samples in some categories, or near-absence of samples in some categories. This label imbalance can cause the model to favor the majority class during training, neglecting less common classes, ultimately impacting the model's generalization and overall performance.

[0004] Therefore, there is an urgent need in this field to design a method that can effectively identify client data distribution bias to address the above technical issues. Specifically, by monitoring data distribution bias in real time, we can help understand the distribution characteristics of client data, ensure that the federated learning system can handle different types of data fairly, avoid model performance degradation due to undetected bias, and thus improve 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] To address this issue, the present invention provides a method and system for detecting client data label imbalance in federated learning. This method effectively identifies the distributional shift in data from different clients, often referred to as data label imbalance. To this end, the present invention combines generative adversarial networks, deep neural networks, and the federated learning model to be trained, creating a comprehensive solution.

[0006] To achieve the above objectives, the present invention first uses a generative adversarial network to establish a dataset with known data distribution offsets. Secondly, on the server side, independent federated learning training is performed using this dataset and the federated learning model to be trained, and parameter information and data distribution offset labels of the federated learning model to be trained are collected. Finally, these model parameters and data distribution offset labels are used to drive the training of a deep neural network, thereby obtaining a deep neural network model that can identify data distribution offsets. 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 include dataset preprocessing, virtual federated learning model training, dataset construction, label offset identification deep neural network model training, and model deployment. The details are as follows:

[0008] (1) Dataset preprocessing stage

[0009] The validation dataset held by the server in federated learning and the generative adversarial network are used 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 to be learned model initializes the same model M 0 .

[0012] (3) Feature vector dataset production 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] Use the dataset obtained in the previous step to drive the label offset recognition deep neural network model M 1 , carry out deep neural network model learning.

[0016] (5) Model deployment phase

[0017] After completing the training of the deep neural network model for label offset recognition, 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, the real client uses its private dataset 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 stage (1) are 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 dataset 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 generative adversarial network, these datasets are expanded 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 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 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 D into thinking 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 is from the real single-label dataset D i , 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 its judgment of real data while minimizing the misjudgment of generated data. In the process of generative adversarial networks, the generator and discriminator are optimized alternately to improve data quality. The discriminator performs the following steps:

[0031] 1. From the real single-label dataset D i Randomly sample a batch of real samples from i .

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

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

[0034]

[0035] Where 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. Generator generates sample x i ′, and calculate the authenticity scores of these samples through the discriminator.

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

[0042]

[0043] 3. Use gradient descent 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 set expected goals, such as the generator and discriminator loss functions converge to stable values, and then training is carried out on the next single-label dataset until all categories of datasets are trained.

[0046] Preferably, the model training phase (2) is 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 based on the n data distributions 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, we set the number of local iterations E and learning rate η for each dataset, and used the same training model structure, loss function, and optimization algorithm for each training task. These parameters remained consistent across datasets to ensure comparable and consistent model training. All setup and training were performed on the server.

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

[0052] 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 .

[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 Continuously update, and gradually optimize the model performance through multiple cycles of forward propagation and backward propagation. Finally, after reaching the predetermined training round T, record the final parameters θ of the model T .

[0060] This process is repeated, with each dataset trained 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 dataset 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 dataset.

[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 nThe final training dataset is integrated and stored 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 consists of model parameter data, with each feature representing the parameter value of the model on a specific dataset. The final dataset file will be stored on 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. Delete 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 repeated 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 offset 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 dataset 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 dataset.

[0075] Calculate and apply the mean squared 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 backpropagation 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 number of training rounds is reached or the model performance reaches a satisfactory level.

[0081] After 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 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 (5) is as follows:

[0085] After completing the training and verification of the label offset recognition deep neural network model, the model is deployed to the actual federated learning server. For newly joined clients, their local models are 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 stage (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 shift distribution type of the client's dataset. The deployed model analyzes the received gradient data and predicts the degree of dataset shift. The model's prediction results guide the client to adjust its data collection or training strategy, thereby reducing data shift and improving 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: Uses the validation dataset held by the server in federated learning and a generative adversarial network to generate various datasets with known label distribution offsets. This module preprocesses the validation dataset held by the server and organizes multiple datasets with only a single label.

[0090] Generative Adversarial Network Module: Based on the client's label distribution offset setting, the corresponding data samples are randomly sampled from the verification dataset held by the server. These data samples are input into a generative adversarial network consisting of a generator G composed of a deep neural network and a discriminator D to generate new data samples. Finally, a set number of virtual client datasets with known data sample labels are obtained. In this module, the generative adversarial network consists of 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 This module manages independent training tasks for each dataset on the server side, organizing and coordinating the entire training process. Its primary responsibilities include initializing the model, assigning training tasks, and collecting model parameters after each dataset is trained. It also handles all coordination related to training, ensuring that the resulting model parameters are suitable for subsequent analysis and application.

[0092] Label offset detection and feature vector generation module: After the model training module completes training, it extracts model parameters as features and virtual client dataset distribution types as labels to form a new dataset for training client dataset distribution types. Based on the model parameter information collected during the model training process, this module generates feature vectors and assigns corresponding labels to each vector based on the actual label offset of the dataset and the number of iterations.

[0093] The Deep Neural Network Training Module uses the dataset generated in the Label Shift Detection and Feature Vector Generation Module to drive the Label Shift Identification Deep Neural Network Model M1 and conduct deep neural network model learning. This module uses the feature vectors and labels generated in the previous stage to train a deep neural network to identify label shifts in the data. The deep neural network model uses a multi-layer perceptron structure and a mean squared error loss function for training, optimizing the model to accurately predict label shifts.

[0094] Model deployment module: After completing the training of the deep neural network model for label drift detection, the model is deployed to the actual federated learning production environment. The deployed model can monitor the label drift of the client dataset in real time.

[0095] This paper uses generative adversarial networks and sampling techniques to create datasets with data distribution shifts. These datasets are then independently trained on the server side, collecting model parameter information after training. These model parameters are then combined with deep neural networks for further training, thereby constructing a model that can accurately identify data distribution shifts.

[0096] The present invention combines generative adversarial networks, deep neural networks and a federated learning framework to provide a client data label imbalance detection method and system in a federated learning environment to effectively identify and process data distribution deviation problems from multiple data sources.

[0097] This invention aims to detect data label imbalance in federated learning environments and accurately display the actual data distribution. This design can be combined with other data preprocessing or model tuning techniques to form a more comprehensive strategy. Specifically, it can guide the implementation of adjustments such as data resampling or model weight adjustment to effectively combat issues caused by data bias. This targeted training strategy strengthens the model's ability to handle heterogeneous data from multiple sources, thereby improving the model's accuracy and fairness in practical applications. BRIEF DESCRIPTION OF THE DRAWINGS

[0098] Figure 1 This 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 a federated learning framework, multiple clients collaborate to train models on these datasets while collecting gradient information. This information is then processed using deep neural networks to 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] In federated learning, the server-held validation dataset and a generative adversarial network are used to generate various datasets with known label distribution offsets. Specifically, based on the required client label distribution offset, a corresponding data sample is randomly sampled from the server-held validation dataset. This sample is then fed into a generative adversarial network composed of a generator G and a discriminator D, which are composed of a deep neural network, to generate a new data sample. Ultimately, a sufficient number of virtual client datasets with known data sample labels are 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 dataset 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 generative adversarial network, these datasets are expanded 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, making 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 is from the real single-label dataset D i , 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 its judgment of real data while minimizing the misjudgment of generated data. In the process of generative adversarial network operation, the generator and discriminator are alternately optimized to improve data quality. The discriminator performs the following steps:

[0118] 1. From the real single-label dataset D i Randomly sample a batch of real samples from i .

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

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

[0121]

[0122] Where 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. Generator generates sample x i ′, and calculate the authenticity scores of these samples through the discriminator.

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

[0129]

[0130] 3. Use gradient descent 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 set expected goals, such as the generator and discriminator loss functions converge to stable values, and then training is carried out on the next single-label dataset 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 equal samples from the data sets of other categories, and merge them to form a data set with a ratio of β (α+β=1). Mix the main category data with the other category data in the set ratio to form a new data set. Repeat this process to create multiple data distribution offset datasets as needed, such as Each of these datasets has 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 based on the n data distributions 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 Training is performed by setting the number of local iterations E and learning rate η for each dataset. The same training model structure, loss function, and optimization algorithm are used for each training task. These parameters are kept consistent across datasets to ensure comparability and consistency in the model training process. It is important to note that all setup 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 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 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 Continuously update, and gradually optimize the model performance through multiple cycles of forward propagation and backward propagation. Finally, after reaching the predetermined training round T, record the final parameters θ of the model T .

[0150] This process is repeated, with each dataset trained 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 dataset 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 dataset. For example, if the proportion of label b in the dataset is 90% and the proportion of label a is 10%, then the label can be represented as "1a9b". Specifically, assuming that the dataset D shift There are two labels a and b, where 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 The final training dataset is integrated and stored 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 consists of model parameter data, with each feature representing the parameter value of the model on a specific dataset. The final dataset file will be stored on 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. Delete 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 repeated 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 offset 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 dataset 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 dataset.

[0166] Calculate and apply the mean squared 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 backpropagation 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 number of training rounds is reached or the model performance reaches a satisfactory level.

[0172] After 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 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 offset recognition deep neural network model, the model is deployed to the actual federated learning server. For newly joined clients, their local models are 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 stage (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 shift distribution type of the client's dataset. The deployed model analyzes the received gradient data and predicts the degree of dataset shift. The model's prediction results guide the client to adjust its data collection or training strategy, thereby reducing data shift and improving 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 organize multiple datasets with only single labels.

[0184] Generative Adversarial Network Module: Based on the client's label distribution offset setting, the corresponding data sample is randomly sampled from the verification dataset held by the server; this data sample is input into the generative adversarial network composed of a generator G composed of a deep neural network and a discriminator D to generate new data samples; ultimately, a set number of virtual client datasets with known data sample labels are obtained; in this module, the generative adversarial network consists of 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 On the server side, it manages independent training tasks for each dataset and is responsible for organizing and coordinating the entire training process. This module's primary responsibilities include initializing the model, assigning training tasks, and collecting model parameters after each dataset is trained. It also handles all coordination related to training, ensuring that the resulting model parameters are suitable for subsequent analysis and application.

[0186] Label offset detection and feature vector generation module: After the model training module completes training, it extracts model parameters as features and virtual client dataset distribution types as labels to form a new dataset for training client dataset distribution types. Based on the model parameter information collected during the model training process, this module generates feature vectors and assigns corresponding labels to each vector based on the actual label offset of the dataset and the number of iterations.

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

[0188] Model Deployment Module: After completing the training and validation of the label drift identification deep neural network model, the model is deployed to the actual federated learning production environment. The deployed model can monitor the label drift of the client dataset in real time.

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

[0190] The above description is merely a preferred embodiment of the method of the present invention and the technical principles employed. 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 detail through the above embodiments, the present invention is not limited to the above embodiments and may include many other equivalent embodiments without departing from the concept of the present invention. The scope of the present invention is determined by the scope of the appended claims.

Claims

1. A method for detecting client data label imbalance in federated learning, characterized by: 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 dataset distribution type is used as a label to form a new dataset for training the client dataset distribution type; (4) Using the dataset 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; Step (2) is as follows: Take the same number of samples from each virtual client dataset to form a new dataset ; From the basic dataset Determine the proportion of main class data in order to generate new datasets 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 shift dataset , for each dataset Configure independent training tasks; Each data distribution offset dataset uses a separate initialization model M 0 Perform training and set the number of local iteration updates for each data distribution offset dataset E and the learning rate η , 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: Using learning rate η For 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; in each iteration, the model parameters θ t Update; finally, after reaching the predetermined training round T, record the final parameter θ of the model T .

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 a deep neural network and the discriminator D to generate a new data sample; finally, a set number of virtual client data sets with known data sample labels are 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, 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: Among them, x j represents the jth data sample, y j Indicates its 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 is 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 ) are added to the original dataset.

5. A method for detecting client data label imbalance in federated learning as claimed in claim 4, characterized by: 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. The method for detecting client data label imbalance in federated learning according to claim 1, wherein: Step (3) is as follows: The server collects each dataset Model parameter information θ after training n , including weights W and bias, 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 by ; the label format is "data distribution offset", where the data distribution offset part represents the proportion of each label in the dataset; 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 dataset 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.

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

8. The method for detecting client data label imbalance in federated learning according to claim 6 or 7, wherein: 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 on a data distribution shift detection model. A deep neural network model is selected as the training model. A multi-layer perceptron structure is used, 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 backpropagation 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: in, η represents the learning rate, is the gradient of the loss function with respect to the weights; The training process is repeated until the predetermined number of training rounds is reached or the model performance reaches a set satisfaction level.

9. A client data label imbalance detection system in a federated learning environment, configured to execute the method according to any one of claims 2 to 8, comprising the following modules: Dataset preprocessing module: Use the verification dataset held by the federated learning server and the generative adversarial network to generate various datasets with known label distribution offsets; Generative Adversarial Network (GAN) module: Based on the client's label distribution offset setting, it randomly samples corresponding data samples from the server's validation dataset. This data sample is then fed into a GAN consisting of a generator (G) and a discriminator (D) composed of a deep neural network to generate new data samples. This ultimately yields a set number of virtual client datasets with known data sample labels. 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 model parameters as features and virtual client dataset distribution types as labels to form a new dataset for training client dataset distribution types; Deep neural network training module: Use the dataset 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