Model updating method and device, equipment and computer storage medium
By identifying and adjusting the distribution characteristics of node model data in federated learning, usable and unusable data are filtered out. The global model is then trained and updated using a classifier, which solves the problems of node hardware limitations and the influence of noisy data, thereby improving the learning quality of the model and the accuracy of gradient calculation.
Patent Information
- Application Number
- CN202210335024.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-31
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2042-03-31
AI Technical Summary
In federated learning, the limited hardware and data resources of participating nodes lead to the collection of low-quality data and model updates, affecting the learning quality of the global model. Furthermore, existing gradient calculation methods are inaccurate when noisy data is present.
By identifying the distribution characteristics of node model data, usable and unusable data are filtered out. A classifier is used for training, and weights are adjusted to update the global model, thereby identifying and reducing the impact of abnormal data.
It improves the computational accuracy of the global model and the accuracy of gradient calculation, thereby enhancing the model's learning quality and convergence speed.
Smart Images

Figure CN116956099B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of big data technology, and in particular relates to a model update method, apparatus, device and computer storage medium. Background Technology
[0002] The proliferation of mobile edge devices has led to a rapid increase in data generated at the edge, simultaneously promoting the booming development of modern artificial intelligence and big data applications. Traditional mechanisms for centralized model training by collecting large amounts of data in the cloud suffer from low privacy and security, as well as high data transmission costs. Therefore, federated learning has emerged to fully utilize data resources without compromising privacy. Federated learning allows data owners to collaboratively train a global model without sharing their original data. In federated learning, distributed data owners use their own data to train the global model locally, obtain model update data, and then submit it to the server for model aggregation. The server uses the aggregated model update data to update the global model and returns it to each node for the next iteration. The training process of the global model can thus be completed iteratively in a distributed and privacy-preserving manner.
[0003] However, the nodes participating in federated learning (i.e., data owners) are typically limited in terms of hardware and data resources, and exhibit heterogeneity, which can significantly impact learning performance. For example, due to the hardware limitations of each data owner, some mislabeled, low-quality data is often collected, resulting in inconsistent local learning and modeling quality. This means that if low-quality model update data from various nodes is aggregated indiscriminately on the server, it can conversely worsen the overall model quality, leading to low model learning quality. Summary of the Invention
[0004] This application provides a model update method, apparatus, device, and computer storage medium, which can improve the learning quality in scenarios where models are trained using federated learning.
[0005] An embodiment of the first aspect of this application provides a model update method, the method comprising:
[0006] Obtain node model data from multiple nodes to obtain a dataset;
[0007] Based on the distribution data of the node model data in the dataset, determine the first data and the second data, where the first data is the node model data that meets the first condition and the second data is the node model data that meets the second condition.
[0008] Input the first and second data into a preset classifier to train the classifier;
[0009] When the trained classifier meets the third preset condition, the weights of the node model data are calculated based on the classifier, and the corresponding federated learning global model is updated using these weights.
[0010] In some embodiments, before determining the first and second data in the dataset based on the distribution data of the node model data, the method further includes:
[0011] Calculate the expected value of the node model data in the dataset;
[0012] Calculations are performed based on the expected value and node model data to determine the variance corresponding to each node data model.
[0013] Based on the variance, determine the normal distribution of the node model data in the dataset.
[0014] In some embodiments, determining the first and second data in the dataset based on the distribution data of the node model data includes:
[0015] Based on the normal distribution data of the node model data, determine the first interval and the second interval. The first interval is determined according to the first condition, and the second interval is determined according to the second condition.
[0016] The node model data corresponding to the first interval is determined as the first data;
[0017] The node model data corresponding to the second interval is determined as the second data;
[0018] The ratio of the first data to the second data is a preset value.
[0019] In some embodiments, the classifier includes a first classifier and a second classifier. The first data and the second data are input into a preset classifier to train the classifier, including:
[0020] According to the first condition and the second condition, the first data and the second data are respectively input into a preset classifier, wherein the first data and the second data have the same initial weight;
[0021] Based on the first data, the second data, and the initial weights, calculate the error rates of the first classifier and the second classifier respectively.
[0022] Based on the error rates of the first and second classifiers, calculate the first weight of each classifier accordingly.
[0023] If the target classifier does not meet the third preset condition, the initial weights corresponding to the node model data in the target classifier are adjusted according to the preset rules and the corresponding first weights. The step of calculating the error rate of the first classifier and the second classifier is then performed based on the adjusted weights until the first classifier and the second classifier meet the third preset condition, and the target classifier is the classifier with the smaller error rate among the first classifier and the second classifier.
[0024] In some embodiments, adjusting the initial values corresponding to the node model data in the target classifier according to preset rules and corresponding first weights includes:
[0025] The initial weights of the first data corresponding to the target classifier are increased according to a preset rule to obtain the second weights; and...
[0026] The initial weights of the second data corresponding to the target classifier are reduced according to a preset rule to obtain the third weights.
[0027] A second aspect of this application provides a model updating apparatus, the apparatus comprising:
[0028] The acquisition module is used to acquire node model data from multiple nodes to obtain a dataset.
[0029] The first determining module is used to determine the first data and the second data based on the distribution data of the node model data in the dataset, wherein the first data is the node model data that meets the first condition and the second data is the node model data that meets the second condition.
[0030] The training module is used to input the first data and the second data into a preset classifier and train the classifier.
[0031] The update module is used to calculate the weights of the node model data based on the classifier when the trained classifier reaches a third preset condition, so as to update the corresponding federated learning global model through the weights.
[0032] In some embodiments, the training module includes:
[0033] The input submodule is used to input the first data and the second data into a preset classifier according to the first condition and the second condition, respectively, wherein the first data and the second data have the same initial weights.
[0034] The first calculation submodule is used to calculate the error rates of the first classifier and the second classifier based on the first data, the second data, and the initial weights, respectively.
[0035] The second calculation submodule is used to calculate the first weight of the model data of each node according to the error rate of the first classifier and the second classifier.
[0036] The adjustment submodule is used to adjust the initial weights corresponding to the node model data in the target classifier according to preset rules and corresponding first weights when the target classifier does not meet the third preset condition. The adjustment submodule is used to return to the step of calculating the error rate of the first classifier and the second classifier based on the adjusted weights, until the first classifier and the second classifier meet the third preset condition and the target classifier is the classifier with the smaller error rate among the first classifier and the second classifier.
[0037] An embodiment of the third aspect of this application provides a computer device, the device comprising: a processor and a memory storing computer program instructions;
[0038] When the processor executes the computer program instructions, it implements the model update method as described in the first aspect.
[0039] An embodiment of the fourth aspect of this application provides a computer storage medium storing computer program instructions that, when executed by a processor, implement the model update method as described in the first aspect.
[0040] An embodiment of the fifth aspect of this application provides a computer program product in which instructions, when executed by a processor of an electronic device, cause the electronic device to perform the model update method as described in the first aspect.
[0041] The model update method, apparatus, device, and computer storage medium of this application embodiment can acquire node model data of multiple nodes to obtain a data set; based on the distribution data of the node model data in the data set, node model data that meets a first condition is identified as first data, and node model data that meets a second condition is identified as second data; then, the first data and the second data are input into a preset classifier to train the classifier; when the trained classifier meets a third preset condition, the weights of the node model data are calculated according to the classifier to update the corresponding federated learning global model through the weights. This allows for the identification of usable data (i.e., first data) and unusable data that does not conform to the norm (i.e., second data) based on the distribution characteristics of the node model data of multiple nodes, thereby inputting them respectively into a preset classifier for training, obtaining the classifier calculation results that meet the conditions, and using them for training the global model, thus improving the calculation accuracy of the global model. Attached Figure Description
[0042] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0043] Figure 1 This is a schematic flowchart of a model update method provided in one embodiment of this application;
[0044] Figure 2 This is a flowchart illustrating a specific embodiment of the model update method provided in this application;
[0045] Figure 3 This is a schematic diagram of the structure of a model update device provided in another embodiment of this application;
[0046] Figure 4 This is a schematic diagram of the structure of a computer device provided in another embodiment of this application. Detailed Implementation
[0047] The features and exemplary embodiments of various aspects of this application will be described in detail below. To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain this application and not to limit it. For those skilled in the art, this application can be implemented without some of these specific details. The following description of the embodiments is merely to provide a better understanding of this application by illustrating examples.
[0048] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes said element.
[0049] In federated learning, the feature vectors of each data owner (such as vectors for activity area center, place of residence, place of work, etc.) are basically the same, but the similarity between users is extremely low. For example, among users owned by different operators, the feature vectors corresponding to the place of residence are basically the same, but the overlap between users of different operators is very small. In this scenario, horizontal federated learning is often used for global model updates.
[0050] The model training method based on lateral federated learning is as follows: The aggregation node (i.e., the server) sends the model algorithm to each data owner (i.e., the computing node). For example, in a smart city project scenario, the corresponding model algorithm includes algorithms for the activity area center, residence, and workplace. Each data owner then uses the distributed model algorithm to train its local data. Each data owner then calculates the gradient of its corresponding model data and sends the gradient to the model aggregation node. Here, the gradient is an intermediate calculation result, not the original data, thus ensuring joint modeling without exposing the original data. The model aggregation node aggregates the gradients uploaded by all data owners, generates the final model, and sends the model back to each data owner. In this way, each data owner uses the aggregated model, thus ensuring the data privacy of each data owner while performing joint modeling.
[0051] However, in horizontal federated learning methods, when each data owner calculates the intermediate gradient and sends it to the model aggregation node, the main algorithm used by the aggregation node is to perform weighted calculations based on the amount of data owned by each data owner. That is, the gradient weight of data owners with larger amounts of data is larger, and the gradient weight of data owners with smaller amounts of data is smaller. For example, assuming that the number of data owners at a certain moment is n, where n is a positive integer, then the set of data amounts formed by all data owners is k = {k1, k2, ..., kk}. n The set of gradients calculated by all data owners is a = {a1, a2, ..., a}. n Therefore, the formula for calculating the gradient balance of the aggregation node with respect to all data owners can be expressed as:
[0052]
[0053] Among them, a new The gradient is the result of equalization, where i is the identifier of the data owner, i = 1, 2, ..., n. This represents the total amount of data owned by all data owners.
[0054] This weighted calculation method based on the amount of data held by each data owner is relatively simple. However, in real-world big data computing scenarios, massive amounts of data contain a large amount of noisy data. If a particular data owner holds a significant amount of noisy data, according to the formula above, that data owner's gradient weight will be very large, affecting the accuracy of gradient calculation. Therefore, weighting gradients solely based on the size of the data held by each data owner will negatively impact the accuracy of gradient calculation in scenarios with noisy data, thus affecting the accuracy of the final model. Therefore, improving gradient accuracy is a crucial aspect of federated learning.
[0055] To address the problems of existing technologies, embodiments of this application provide a model update method, apparatus, device, and computer storage medium. By leveraging the distribution characteristics of node model data, usable and unusable data are identified, and classification training is performed to adjust weights. The adjusted weights of the node model data are then used to update the global model, thereby improving the accuracy of the global model. The model update method provided in this application embodiment is described below.
[0056] Figure 1 A schematic flowchart of a model update method provided in one embodiment of this application is shown. Figure 1 As shown, the model update method includes S101 to S104:
[0057] S101 acquires node model data from multiple nodes to obtain a dataset;
[0058] S102 Based on the distribution data of the node model data in the dataset, determine the first data and the second data, wherein the first data is the node model data that meets the first condition and the second data is the node model data that meets the second condition.
[0059] S103 inputs the first data and the second data into a preset classifier to train the classifier;
[0060] S104 When the trained classifier reaches the third preset condition, calculate the weight of the node model data according to the classifier, and update the corresponding federated learning global model through the weight.
[0061] According to embodiments of this application, node model data from multiple nodes can be acquired to obtain a dataset. Based on the distribution data of the node model data in the dataset, node model data meeting a first condition is identified as first data, and node model data meeting a second condition is identified as second data. Then, the first and second data are input into a preset classifier for training. When the trained classifier meets a third preset condition, the weights of the node model data are calculated based on the classifier, and the corresponding federated learning global model is updated using these weights. This allows for the identification of usable data (i.e., first data) and unusable data (i.e., second data) that do not conform to the norm, based on the distribution characteristics of the node model data from multiple nodes. These usable data are then input into a preset classifier for training, yielding reliable weights for training the global model and improving the computational accuracy of the global model.
[0062] In this embodiment, the node model data obtained in step S101 includes the model training data of each node (i.e., the data owner). It is understood that the aggregation node (i.e., the server) sends the model algorithm to each data owner (i.e., the computing node). For example, in a smart city project scenario, the corresponding model algorithm includes algorithms related to the activity area center, residence, and workplace. Then, each data owner uses the distributed model algorithm to train its local data, calculates the gradient of its corresponding model data, and sends the gradient to the model aggregation node. Here, the gradient is an intermediate calculation result, not the original data, thus ensuring joint modeling without exposing the original data.
[0063] Because the noise levels in the node model data reported by each node vary, some noise has a significant impact, rendering the data unusable for global model updates; such data is considered anomalous. Conversely, some noise has a negligible impact and can be used for global model updates; such data is considered normal.
[0064] In this embodiment, to accurately reflect the noise impact of node model data such as gradients uploaded by the data owner, the distribution of these node model data is calculated for identification and judgment. Specifically, in this embodiment, before determining the first and second data in the data set based on the distribution data of the node model data in step S102, the method may further include S105 to S107:
[0065] S105 calculates the expected value of the node model data in the dataset.
[0066] For example, assuming the gradient calculated by the data owner is 'a', the dataset formed after the aggregation node obtains the gradients of the n data owners through step S101 can be represented as: a = {a1, a2, ..., a} n}
[0067] Based on this dataset, the expected value of the gradient of all data owners in the dataset can be calculated in step S105, specifically according to the following formula (1):
[0068]
[0069] In formula (1), E(a) is the expected value of the gradient of all data owners, and i is the identifier of the data owner, i = 1, 2, ..., n.
[0070] S106 calculates the variance corresponding to each node data model based on the expected value and the node model data.
[0071] For example, the variance corresponding to the node data model can be calculated using the following formula (2):
[0072]
[0073] In formula (2), S(a) is the variance of the data model corresponding to the n data owner nodes.
[0074] Variance is typically used to measure the dispersion of a random variable or a set of data, reflecting the degree of deviation between the random variable and its expected value. Therefore, in this embodiment, the distribution of node model data is analyzed by analyzing the expected value and variance, thereby identifying normal and abnormal data.
[0075] S107 determines the normal distribution data of the node model data in the dataset based on the variance.
[0076] For a set of random variables, if they follow a normal distribution with expected value μ and variance σ, then it can be denoted as N(μ,σ). 2 ), N∈(0,1). Here, the expected value μ determines the location of the random variable distribution, and the variance σ determines the amplitude of the distribution. The corresponding probability density function can be expressed as P(x,y), where x∈N, and y represents the nodal model data, such as the gradient. When it usually follows a normal distribution, the probability value y corresponding to each random variable can be directly calculated by looking up the standard normal distribution table.
[0077] In this embodiment, the normal distribution of the node model data in the dataset can be determined based on the variance, and data analysis can be performed based on the obtained normal distribution. Specifically, step S107 may include S1071 to S1073:
[0078] S1071 determines the first interval and the second interval based on the normal distribution data of the node model data. The first interval is determined according to the first condition, and the second interval is determined according to the second condition.
[0079] In this embodiment, based on the obtained expected value and variance, the normal distribution data of the node model data in the dataset can be determined as N(μ,σ). 2 ), N∈(0,1), where μ=E(a), σ=S(a). In this way, the corresponding data interval can be determined based on the normally distributed data, thereby filtering out normal and abnormal data.
[0080] For example, this embodiment uses the Pareto principle (80 / 20 rule) to determine the first and second conditions. The Pareto principle determines that 20% of the data is abnormal data and 80% is normal data. Therefore, in this embodiment, by setting two interval boundary values X1 and X2, the interval between these two boundary values is defined as the first interval, and the interval outside the first interval is defined as the second interval. Correspondingly, the first condition can be the node model data corresponding to the first interval, and the second condition can be the node model data corresponding to the second interval.
[0081] Specifically, in this step, based on the Pareto principle, the probability value P corresponding to the normally distributed data is set to satisfy P(x>X2)=0.1. Then, X2 can be directly calculated by looking up the standard normal distribution table. Based on the regularity of the normal distribution, X1=2E(a)-X2.
[0082] S1072 determines the node model data corresponding to the first interval as the first data;
[0083] S1073 determines the node model data corresponding to the second interval as the second data;
[0084] The ratio of the first data to the second data is a preset value.
[0085] In this embodiment, after determining the boundary values X1 and X2 of the first interval and the second interval, the gradients distributed in the range X1 < x < X2 (i.e., the first interval) are considered normal gradients, while the gradients distributed in the second interval, i.e., (x > X2) and (x < X1), are considered abnormal gradients. Therefore, the first data determined based on the first interval can be represented as Y = {y1, y2, ..., y p The second data determined based on the second interval can be represented as G = {g1, g2, ..., g}. q}, p≠q, p and q are less than or equal to n.
[0086] Therefore, the first data point accounts for 80% of the total data set, and the second data point accounts for 20% of the total data set. The ratio of the first data point to the second data point conforms to the Pareto principle, that is, it conforms to the preset ratio of 2:8.
[0087] After determining the first and second data points, i.e., identifying abnormal and normal data, a pre-defined classifier can be trained, adjusting the weights of the first and second data points until a reasonable weight is obtained, minimizing the impact of abnormal data on the global model. Specifically, in this embodiment, the classifier includes a first classifier and a second classifier, such as... Figure 2 As shown, step S103, which involves inputting the first and second data into a preset classifier to train the classifier, may include:
[0088] S1031 According to the first condition and the second condition, the first data and the second data are respectively input into a preset classifier, wherein the first data and the second data have the same initial weight.
[0089] For example, based on the first boundary value, the data input to the first classifier is determined, and the first classifier h1 can be represented as:
[0090]
[0091] Based on the second boundary value, the data input to the first classifier is determined, and the second classifier h2 can be represented as:
[0092]
[0093] Furthermore, each data owner is assigned the same initial weight w. i w i =1 / d, then the initial weight distribution of all data owners can be expressed as:
[0094]
[0095] S1032 Calculates the error rates of the first classifier and the second classifier based on the first data, the second data, and the initial weights.
[0096] In this embodiment, the gradient of the data owner is input into two classifiers for classification according to the distribution of the data. The error rate corresponding to the gradient in the first classifier and the second classifier can be calculated by the following formula (5):
[0097]
[0098] In formula (5), e tThe classifier's error rate is represented by h, where t represents the classifier's number, t = 1, 2; t This represents a classifier.
[0099] S1033 calculates the first weight of each classifier based on the error rates of the first and second classifiers.
[0100] If the error rate of either or both of the first and second classifiers fails to meet a preset condition (e.g., the error rate fails to reach a preset value, or the current iteration fails to reach a preset number of iterations), then the weights of the node model data in the classifier need to be adjusted. The iteration of the node model data weights is achieved through classifier training. This iteration of node model data weights is performed using the classifier weights.
[0101] In this embodiment, the data set a = {a1, a2, ..., a...} n All node model data are input into h1 and h2 respectively. Each node model data has its own initial weight. Based on the classification results and initial weights of the node model data, the error rate e1 of the first classifier and the error rate e2 of the second classifier are calculated. The weights (i.e., the first weights) in each classifier are calculated according to the error rates, so as to complete the subsequent iterations according to the first weights of the corresponding classifiers.
[0102] In this step, the first weight o of the corresponding classifier is calculated based on the classifier's error rate. t The calculation formula can be the following formula (6):
[0103]
[0104] S1034 If the target classifier does not meet the third preset condition, adjust the initial weights corresponding to the node model data in the target classifier according to the preset rules and the corresponding first weights, so as to return to the step of calculating the error rate of the first classifier and the second classifier based on the adjusted weights, until the first classifier and the second classifier meet the third preset condition, and the target classifier is the classifier with the smaller error rate among the first classifier and the second classifier.
[0105] In this embodiment, since the input data to each classifier may contain both abnormal and normal data probability values, if any classifier fails to meet the third preset condition, it indicates that the noise impact of abnormal data in the current node model data has not been eliminated. Therefore, in this embodiment, the classifier with the smaller error rate between the first and second classifiers is selected as the target classifier. By recalculating the weights corresponding to the node model data in the target classifier, the target classifier is iterated, thereby achieving the iteration of the node model data in the classifier and eliminating the noise impact of abnormal data in the classifier.
[0106] For example, in the first iteration of the node model data, the first weight obtained by formula (6) and the original weight of the node model data are used to perform the first iteration based on whether each node model data in the classifier belongs to normal data or abnormal data. Specifically, in step S1034, the initial weights corresponding to the node model data in the target classifier are adjusted according to preset rules and the corresponding first weights, which may include:
[0107] The original weights corresponding to the first data in the target classifier are increased according to a preset rule to obtain the second weights; and...
[0108] The original weights corresponding to the second data in the target classifier are reduced according to a preset rule to obtain the third weights.
[0109] In this embodiment, if there is abnormal data (i.e., second data) in the target classifier, the weight of the abnormal data is reduced accordingly; if there is normal data (i.e., first data) in the target classifier, the weight of the normal data is increased accordingly, thereby balancing the weights of different data. The specific adjustment method is as follows:
[0110] For abnormal data, the specific calculation method during the weight reduction process is as shown in formula (7):
[0111] in
[0112]
[0113]
[0114]
[0115] Among them, w m (i) represents the weight of the node model data of the i-th data owner in the m-th iteration. Therefore, when m=1, w m (i) represents the original weights, i.e., w m (i)=w i .
[0116] For normal data, the specific calculation method for increasing the weight is as shown in formula (8):
[0117] in
[0118]
[0119]
[0120]
[0121] The weight of node i after adjustment, i.e., the weight w obtained after increasing or decreasing it. m+1 (i) Substitute into formula (5) and recalculate the error rate of the two classifiers. If the error rate of the classifiers still does not reach the third preset condition (e.g., the error rate does not reach the preset value of 0, or the current iteration does not reach the preset number of iterations), then select the classifier with the smaller error rate as the target classifier again. Adjust the weights of the node model data in the target classifier according to formulas (7) and (8) until the error rate of the two classifiers reaches the third preset condition, terminate the iteration, execute step S104, record the weights of the node model data in the classifier at the time of termination of the iteration, and update the global model with the weights and the corresponding node model data. It should be understood that using node data for global updates is a mature technology in the field of federated learning, which will not be elaborated here.
[0122] In this embodiment, when updating the model using a horizontal federated learning approach, an iterative weight optimization method based on classifier error rate judgment improves model convergence speed and prediction accuracy. During the iterative weight optimization process based on classifier error rate judgment, abnormal data owner nodes can be identified, and classifiers can be set accordingly. The error rate of each classifier is iterated sequentially until the classifier with the lowest error rate is found. Following the principle that the weights of abnormal data identified by the classifier decrease while the weights of normal data increase, the weights of each data owner are recalculated. This iteration continues until a preset condition is met or the error rate reaches zero, at which point the iteration-resolved weights become the final weights of the data owners. This weight calculation method lowers the weights of data owners with low accuracy and increases the weights of data owners with high accuracy, thereby improving the model aggregation accuracy of the model aggregation node.
[0123] The above text combines Figure 1 and Figure 2 The present application describes in detail the model update method according to the embodiments of this application. The following will be combined with... Figure 3 The apparatus of the embodiments of this application is described in detail below.
[0124] Figure 3 A schematic diagram of the model update apparatus provided in an embodiment of this application is shown. Figure 3 As shown, the device 300 includes:
[0125] The acquisition module 301 is used to acquire node model data from multiple nodes to obtain a data set;
[0126] The first determining module 302 is used to determine the first data and the second data based on the distribution data of the node model data in the dataset, wherein the first data is the node model data that meets the first condition and the second data is the node model data that meets the second condition.
[0127] The training module 303 is used to input the first data and the second data into a preset classifier to train the classifier;
[0128] The update module 304 is used to update the corresponding federated learning global model based on the output data of the classifier, the first data, and the second data when the trained classifier reaches the third preset condition.
[0129] According to embodiments of this application, node model data from multiple nodes can be acquired to obtain a dataset. Based on the distribution data of the node model data in the dataset, node model data meeting a first condition is identified as first data, and node model data meeting a second condition is identified as second data. Then, the first and second data are input into a preset classifier for training. When the trained classifier meets a third preset condition, the weights of the node model data are calculated based on the classifier, and the corresponding federated learning global model is updated using these weights. This allows for the identification of usable data (i.e., first data) and unusable data (i.e., second data) that do not conform to the norm, based on the distribution characteristics of the node model data from multiple nodes. These usable data are then input into a preset classifier for training, yielding reliable weights for training the global model and improving the computational accuracy of the global model.
[0130] In some embodiments, the device 300 may further include:
[0131] The first calculation module is used to calculate the expected value of the node model data in the dataset.
[0132] The second determination module is used to calculate and determine the variance corresponding to each node data model based on the expected value and the node model data.
[0133] The third determination module is used to determine the normal distribution data of the node model data in the dataset based on the variance.
[0134] For example, assuming the gradient calculated by the data owner is 'a', the dataset formed after the aggregation node obtains the gradients of the n data owners through step S101 can be represented as: a = {a1, a2, ..., a} n}
[0135] Based on this dataset, the expected value of the gradient of all data owners in the dataset can be calculated in step S105, specifically according to the following formula (1):
[0136]
[0137] In formula (1), E(a) is the expected value of the gradient of all data owners, and i is the identifier of the data owner, i = 1, 2, ..., n.
[0138] For example, the variance corresponding to the node data model can be calculated using the following formula (2):
[0139]
[0140] In formula (2), S(a) is the variance of the data model corresponding to the n data owner nodes.
[0141] In this embodiment, the normal distribution of node model data in the dataset can be determined based on the variance. Based on the obtained normal distribution, the noise impact of node model data such as gradients uploaded by the data owner can be accurately reflected, and data with high noise can be identified and judged.
[0142] Specifically, the third determining module may include:
[0143] The second determination submodule is used to determine the first interval and the second interval based on the normal distribution data of the node model data. The first interval is determined according to the first condition, and the second interval is determined according to the second condition.
[0144] The third determining submodule is used to determine the node model data corresponding to the first interval as the first data;
[0145] The fourth determination submodule is used to determine the node model data corresponding to the second interval as the second data;
[0146] The ratio of the first data to the second data is a preset value.
[0147] For a set of random variables, if they follow a normal distribution with expected value μ and variance σ, then it can be denoted as N(μ,σ). 2 ), N∈(0,1). Here, the expected value μ determines the location of the random variable distribution, and the variance σ determines the amplitude of the distribution. The corresponding probability density function can be expressed as P(x,y), where x∈N, and y represents the nodal model data, such as the gradient. When it usually follows a normal distribution, the probability value y corresponding to each random variable can be directly calculated by looking up the standard normal distribution table.
[0148] In this embodiment, based on the obtained expected value and variance, the normal distribution data of the node model data in the dataset can be determined as N(μ,σ). 2 ), N∈(0,1), where μ=E(a), σ=S(a). In this way, the corresponding data interval can be determined based on the normally distributed data, thereby filtering out normal and abnormal data.
[0149] For example, this embodiment uses the Pareto principle (80 / 20 rule) to determine the first and second conditions. The Pareto principle determines that 20% of the data is abnormal data and 80% is normal data. Therefore, in this embodiment, by setting two interval boundary values X1 and X2, the interval between these two boundary values is defined as the first interval, and the interval outside the first interval is defined as the second interval. Correspondingly, the first condition can be the node model data corresponding to the first interval, and the second condition can be the node model data corresponding to the second interval.
[0150] Specifically, in this step, based on the Pareto principle, the probability value P corresponding to the normally distributed data is set to P(x>X2)=0.1. Then, X2 can be directly calculated by looking up the standard normal distribution table. Based on the regularity of the normal distribution, X1=2E(a)-X2.
[0151] In this embodiment, after determining the boundary values X1 and X2 of the first interval and the second interval, the gradients distributed in the range X1 < x < X2 (i.e., the first interval) are considered normal gradients, while the gradients distributed in the second interval, i.e., (x > X2) and (x < X1), are considered abnormal gradients. Therefore, the first data determined based on the first interval can be represented as Y = {y1, y2, ..., y p The second data determined based on the second interval can be represented as G = {g1, g2, ..., g}. q}, p≠q, p and q are less than or equal to n.
[0152] Therefore, the first data point accounts for 80% of the total data set, and the second data point accounts for 20% of the total data set. The ratio of the first data point to the second data point conforms to the Pareto principle, that is, it conforms to the preset ratio of 2:8.
[0153] After determining the first and second data points, that is, after identifying abnormal and normal data, the model can be trained using a preset classifier. The weights of the first and second data points can be adjusted until a reasonable weight is obtained, minimizing the impact of abnormal data on the global model.
[0154] In some embodiments, the training module includes:
[0155] The input submodule is used to input the first data and the second data into a preset classifier according to the first condition and the second condition, respectively, wherein the first data and the second data have the same initial weights.
[0156] The first calculation submodule is used to calculate the error rates of the first classifier and the second classifier based on the first data, the second data, and the initial weights, respectively.
[0157] The second calculation submodule is used to calculate the first weight of each classifier based on the error rates of the first classifier and the second classifier.
[0158] The adjustment submodule is used to adjust the initial weights corresponding to the node model data in the target classifier according to preset rules and corresponding first weights when the target classifier does not meet the third preset condition. The adjustment submodule is used to return to the step of calculating the error rate of the first classifier and the second classifier based on the adjusted weights, until the first classifier and the second classifier meet the third preset condition and the target classifier is the classifier with the smaller error rate among the first classifier and the second classifier.
[0159] For example, based on the first boundary value, the data input to the first classifier is determined, and the first classifier h1 can be represented as:
[0160]
[0161] Based on the second boundary value, the data input to the first classifier is determined, and the second classifier h2 can be represented as:
[0162]
[0163] Furthermore, each data owner is assigned the same initial weight w. i w i =1 / d, then the initial weight distribution of all data owners can be expressed as:
[0164]
[0165] In this embodiment, the gradient of the data owner is input into two classifiers for classification according to the distribution of the data. The error rate corresponding to the gradient in the first classifier and the second classifier can be calculated by the following formula (5):
[0166]
[0167] In formula (5), e t The classifier's error rate is represented by h, where t represents the classifier's number, t = 1, 2; t This represents a classifier.
[0168] Given a data set a = {a1, a2, ..., a...} n All node model data are input into h1 and h2 respectively. Each node model data has its own initial weight. Based on the classification results and weights of the node model data, the error rate e1 of the first classifier and the error rate e2 of the second classifier are calculated. The weights of the node model data in each classifier (i.e., the first weights) are calculated again according to the error rates to complete the first iteration.
[0169] Calculate the first weight of the model data for each node in the classifier based on the classifier's error rate. t The calculation formula can be:
[0170]
[0171] In this embodiment, since the input data to each classifier may contain both abnormal and normal data probability values, if any classifier fails to meet the third preset condition, it indicates that the noise impact of abnormal data in the current node model data has not been eliminated. Therefore, in this embodiment, the classifier with the smaller error rate between the first and second classifiers is selected as the target classifier. By recalculating the weights corresponding to the node model data in the target classifier, the target classifier is iterated, thereby achieving the iteration of the node model data in the classifier and eliminating the noise impact of abnormal data in the classifier.
[0172] For example, in the first iteration of the node model data, the first weight obtained by formula (6) and the original weight of the node model data are used to perform the first iteration based on whether each node model data in the classifier belongs to normal data or abnormal data.
[0173] Specifically, the adjustment submodule may include:
[0174] The first adjustment unit is used to increase the original weights corresponding to the first data in the target classifier according to a preset rule to obtain the second weights; and
[0175] The second adjustment unit is used to reduce the original weights corresponding to the second data in the target classifier according to a preset rule to obtain the third weights.
[0176] In this embodiment, if there is abnormal data (i.e., second data) in the target classifier, the weight of the abnormal data is reduced accordingly; if there is normal data (i.e., first data) in the target classifier, the weight of the normal data is increased accordingly, thereby balancing the weights of different data. The specific adjustment method is as follows:
[0177] For abnormal data, the weight is reduced (i.e., lowered) according to preset rules. The specific calculation method is as shown in formula (7):
[0178] in
[0179]
[0180]
[0181]
[0182] Among them, w m (i) represents the weight of the node model data of the i-th data owner in the m-th iteration. When m=1, w m (i)=w i .
[0183] For normal data, increase the weight, and the specific calculation method is as shown in formula (8):
[0184] in
[0185]
[0186]
[0187]
[0188] The weight w obtained after increasing or decreasing node i m+1 (i), substituting into formula (5), recalculate the error rate of the two classifiers. It should be understood that for scenarios where the weights are increased, w m+1 (i) is the second weight obtained through formula (8). For scenarios where the weight is reduced, w m+1 (i) is the third weight obtained through formula (7).
[0189] If, after recalculating the error rates of the two classifiers, either or all of their error rates still do not reach the third preset condition (such as reaching the preset value of 0, or the current iteration reaching the preset number of iterations), then the classifier with the smaller error rate is selected again as the classifier. The weights of the node model data in the classifier are adjusted according to formulas (7) and (8) until the error rates of the two classifiers reach the third preset condition, at which point the iteration terminates. The weights of the node model data in the classifier are recorded at the time of termination of the iteration, and the weights and the corresponding node model data are used to update the global model. It should be understood that using node data for global updates is a mature technique in the field of federated learning, and will not be elaborated here.
[0190] In this embodiment, when updating the model using a horizontal federated learning approach, an iterative weight optimization method based on classifier error rate judgment improves model convergence speed and prediction accuracy. During the iterative weight optimization process based on classifier error rate judgment, abnormal data owner nodes can be identified, and classifiers can be set accordingly. The error rate of each classifier is iterated sequentially until the classifier with the lowest error rate is found. Following the principle that the weights of abnormal data identified by the classifier decrease while the weights of normal data increase, the weights of each data owner are recalculated. This iteration continues until a preset condition is met or the error rate reaches zero, at which point the iteration-resolved weights become the final weights of the data owners. This weight calculation method lowers the weights of data owners with low accuracy and increases the weights of data owners with high accuracy, thereby improving the model aggregation accuracy of the model aggregation node.
[0191] It should be noted that all relevant content of each step involved in the above method embodiments can be referenced from the functional description of the corresponding functional module and can achieve its corresponding technical effect. For the sake of brevity, it will not be repeated here.
[0192] Figure 4 A schematic diagram of the hardware structure of a computer device provided in an embodiment of this application is shown.
[0193] The computer device may include a processor 401 and a memory 402 storing computer program instructions.
[0194] Specifically, the processor 401 may include a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.
[0195] Memory 402 may include mass storage for data or instructions. For example, and not limitingly, memory 402 may include a hard disk drive (HDD), floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 402 may include removable or non-removable (or fixed) media. Where appropriate, memory 402 may be internal or external to the integrated gateway disaster recovery device. In a particular embodiment, memory 402 is non-volatile solid-state memory.
[0196] Memory may include read-only memory (ROM), random access memory (RAM), disk storage media devices, optical storage media devices, flash memory devices, and electrical, optical, or other physical / tangible memory storage devices. Therefore, typically, memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to one aspect of this application.
[0197] The processor 401 implements any of the model update methods in the above embodiments by reading and executing computer program instructions stored in the memory 402.
[0198] In one example, the computer device may also include a communication interface 403 and a bus 410. Wherein, as... Figure 4 As shown, the processor 401, memory 402, and communication interface 403 are connected through bus 410 and complete communication with each other.
[0199] The communication interface 403 is mainly used to realize communication between various modules, devices, units and / or equipment in the embodiments of this application.
[0200] Bus 410 includes hardware, software, or both, that couples components of the computer device together. For example, and not limitingly, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a Microchannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses, or combinations of two or more of these. Where appropriate, bus 410 may include one or more buses. Although specific buses are described and illustrated in embodiments of this application, any suitable bus or interconnect is contemplated herein.
[0201] Furthermore, in conjunction with the model update methods in the above embodiments, this application embodiment can provide a computer storage medium for implementation. The computer storage medium stores computer program instructions; when these computer program instructions are executed by a processor, they implement any of the model update methods in the above embodiments.
[0202] Furthermore, in conjunction with the model update methods in the above embodiments, this application embodiment can provide a computer program product for implementation. When the instructions in this computer program product are executed by the processor of an electronic device, the electronic device implements any of the model update methods in the above embodiments.
[0203] It should be clarified that this application is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of this application is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of this application.
[0204] The functional modules shown in the above-described block diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this application are programs or code segments used to perform the required tasks. Programs or code segments can be stored on a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried on a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.
[0205] It should also be noted that the exemplary embodiments mentioned in this application describe methods or systems based on a series of steps or apparatus. However, this application is not limited to the order of the above steps; that is, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.
[0206] The aspects of this application have been described above with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It should be understood that each block in the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that these instructions, executable via the processor of the computer or other programmable data processing apparatus, enable the implementation of the functions / actions specified in one or more blocks of the flowchart illustrations and / or block diagrams. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field-programmable logic circuit. It is also understood that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can also be implemented by dedicated hardware performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.
[0207] The above description is merely a specific implementation of this application. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, modules, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. It should be understood that the protection scope of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the protection scope of this application.
Claims
1. A model update method, characterized in that, The method includes: Obtain node model data from multiple nodes to obtain a dataset; Based on the distribution data of the node model data in the dataset, determine the first data and the second data, wherein the first data is the node model data that meets the first condition and the second data is the node model data that meets the second condition. According to the first condition and the second condition, the first data and the second data are respectively input into a preset classifier, wherein the first data and the second data have the same initial weight, and the classifier includes a first classifier and a second classifier; Based on the first data, the second data, and the initial weights, calculate the error rates of the first classifier and the second classifier, respectively. Based on the error rates of the first and second classifiers, calculate the first weight of each classifier accordingly. The classifier is trained based on the first weight; When the trained classifier meets the third preset condition, the weights of the node model data are calculated based on the classifier, and the corresponding federated learning global model is updated through the weights.
2. The method according to claim 1, characterized in that, Before determining the first and second data in the dataset based on the distribution data of the node model data, the method further includes: Calculate the expected value of the node model data in the dataset; The variance corresponding to each node model data is determined by calculating based on the expected value and the node model data. Based on the variance, determine the normal distribution data of the node model data in the dataset.
3. The method according to claim 2, characterized in that, The step of determining the first and second data in the dataset based on the distribution data of the node model data includes: Based on the normal distribution data of the node model data, a first interval and a second interval are determined, wherein the first interval is determined according to the first condition and the second interval is determined according to the second condition; The node model data corresponding to the first interval is determined as the first data; The node model data corresponding to the second interval is determined as the second data; The ratio of the amount of the first data to the amount of the second data is a preset value.
4. The method according to claim 1, characterized in that, The step of inputting the first data and the second data into a preset classifier and training the classifier includes: If the target classifier does not meet the third preset condition, the initial weights corresponding to the node model data in the target classifier are adjusted according to the preset rules and the corresponding first weights, so as to return to the step of calculating the error rate of the first classifier and the second classifier based on the adjusted weights, until the first classifier or the second classifier meets the third preset condition, and the target classifier is the classifier with the smaller error rate among the first classifier and the second classifier.
5. The method according to claim 4, characterized in that, The step of adjusting the initial weights corresponding to the node model data in the target classifier according to preset rules and corresponding first weights includes: The initial weights of the first data corresponding to the target classifier are increased according to a preset rule to obtain the second weights; and... The initial weights of the second data corresponding to the target classifier are reduced according to a preset rule to obtain the third weights.
6. A model update device, characterized in that, The device includes: The acquisition module is used to acquire node model data from multiple nodes to obtain a dataset. The first determining module is used to determine first data and second data based on the distribution data of node model data in the dataset, wherein the first data is node model data that meets a first condition, the second data is node model data that meets a second condition, and the classifier includes a first classifier and a second classifier. The training module is used to input the first data and the second data into a preset classifier and train the classifier. The input submodule is used to input the first data and the second data into a preset classifier according to the first condition and the second condition, respectively, wherein the first data and the second data have the same initial weights. The first calculation submodule is used to calculate the error rates of the first classifier and the second classifier based on the first data, the second data, and the initial weights, respectively. The second calculation submodule is used to calculate the first weight of each classifier based on the error rates of the first classifier and the second classifier. The update module is used to calculate the weights of the node model data based on the classifier when the trained classifier reaches a third preset condition, so as to update the corresponding federated learning global model through the weights.
7. The apparatus according to claim 6, characterized in that, The training module includes: The adjustment submodule is used to adjust the initial weights corresponding to the node model data in the target classifier according to preset rules and corresponding first weights when the target classifier does not meet the third preset condition. The adjustment submodule is used to return to the step of calculating the error rate of the first classifier and the second classifier based on the adjusted weights, until the first classifier and the second classifier meet the third preset condition. The target classifier is the classifier with the smaller error rate among the first classifier and the second classifier.
8. A computer device, characterized in that, The device includes: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, it implements the model update method as described in any one of claims 1-5.
9. A computer storage medium, characterized in that, The computer storage medium stores computer program instructions, which, when executed by a processor, implement the model update method as described in any one of claims 1-5.
10. A computer program product, characterized in that, When the instructions in the computer program product are executed by the processor of the electronic device, the electronic device performs the model update method as described in any one of claims 1-5.
Citation Information
Patent Citations
Medical big data security sharing method and system based on transverse and longitudinal federated learning
CN113642034A
Federal learning model training method, device, system, storage medium and equipment
CN113837399A
Method for updating node model for resisting discrimination propagation in federated learning
CN113902131A