Personalized federal learning scrap steel detection method based on layer-by-layer direction guidance
Through the introduction of layer -by -layer guidance mechanisms in the federal learning, personalized aggregation of the models of scrap steel recycling sites solves data heterogeneous problems and improves the generalization capacity and accuracy of the model.
Patent Information
- Application Number
- CN202411517995.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-29
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2044-10-29
AI Technical Summary
The existing federal learning technology cannot effectively solve the data heterogeneity problem caused by the differences in scrap steel data types and quantity between scrap steel recycling stations, resulting in a decrease in the overall performance of the global model.
Adopt personalized federal learning methods based on layer -by -layer guidance, through high -resolution industrial camera collection and pre -processing waste steel picture data, each client conducts local training and upload model parameters and loss values, server computing model hierarchical aggregation weights and direction vector vectors , Guide personalized model aggregation.
The personalized model of the waste steel recycling sites can effectively absorb the useful information of other sites, improve the generalization ability and accuracy of the model, and solve the decline in performance caused by data heterogeneous problems.
Smart Images

Figure CN119380101A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of metallurgical technology, and in particular to a personalized federated learning scrap steel detection method based on layer-by-layer direction guidance. Background Art
[0002] Scrap steel, as a recycled ferrous resource that can replace iron ore for steelmaking, plays an extremely important role and position in steelmaking. Scrap steel detection refers to the process of classifying and quality testing scrap steel materials, which is divided into manual detection and automated detection. Traditional manual detection relies on manual visual inspection, caliper measurement and other means. Compared with automated detection, traditional manual detection can no longer meet the growing demand for scrap steel detection.
[0003] Existing federated learning is a distributed machine learning paradigm that allows clients to collaboratively train global models with good generalization and high precision without exchanging original data. This approach can solve the problem of data silos, and because federated learning allows clients to upload model parameters rather than original data, it can reduce data transmission costs during scrap steel detection and protect data privacy and security. However, traditional federated learning cannot solve the data heterogeneity problem caused by differences in the type and quantity of scrap steel data among scrap steel recycling sites, because the global model will be biased towards a certain client during training, resulting in a decrease in the overall performance accuracy of the global model.
[0004] The existing technology uses the federated learning technology of hierarchical fine-grained fusion to measure the similarity between each client model and the global model, and calculates the weight of each client model to aggregate and update the global model. However, it cannot solve the problem of data heterogeneity in the actual application scenarios of scrap steel detection. On the one hand, there are different scrap steel recycling plants in the real scenario, and the scrap steel materials recycled by each recycling plant are different. For example, the scrap steel recycled by industrial scrap steel recycling plants tends to be single or specific scrap steel materials, and the types of scrap steel recycled by social scrap steel recycling plants are more diverse than those of industrial scrap steel recycling plants. On the other hand, there are differences in the amount of scrap steel recycled by different scrap steel recycling sites, so that during the training process, the global model will tend to recycle scrap steel recycling sites with a large amount of scrap steel, resulting in differences in the performance of the global model between various scrap steel recycling sites.
[0005] Therefore, those skilled in the art provide a personalized federated learning scrap steel detection method based on layer-by-layer direction guidance to solve the problems raised in the above background technology. Summary of the invention
[0006] In view of the shortcomings of the prior art, the present invention provides a personalized federated learning scrap steel detection method based on layer-by-layer direction guidance to solve the problems raised in the above background technology.
[0007] To achieve the above objectives, the present invention is implemented through the following technical solutions: a personalized federated learning scrap steel detection method based on layer-by-layer direction guidance, comprising the following steps:
[0008] S1. Scrap image collection and preprocessing:
[0009] High-resolution industrial cameras are used to collect high-definition images of different types of scrap steel at different unloading points of each scrap steel recycling station as training data sets;
[0010] Annotate the collected image data;
[0011] Perform data preprocessing, including data cleaning, noise and duplicate image removal, and data cropping;
[0012] The scrap steel image dataset is divided into a training set and a test set in a ratio of 8:2;
[0013] S2. Initialize the model:
[0014] Each scrap steel recycling station deploys an initial model with the same parameters and structure;
[0015] S3. Local training:
[0016] Each client uses the scrap steel image dataset for local training;
[0017] Use stochastic gradient descent combined with cross entropy loss function to optimize the model;
[0018] For stochastic gradient descent, each round of local training uses a small batch of data sets to calculate gradients and update model parameters;
[0019] S4. Aggregation weight method based on client model differences:
[0020] Each scrap steel recycling site uploads local model parameters and loss values to the server;
[0021] The server calculates the similarity of each client model layer by layer through cosine similarity to calculate the hierarchical aggregation weight of each model;
[0022] Normalize the loss values and calculate the aggregation weights of the layers between the models;
[0023] S5. Personalized model aggregation based on layer-by-layer direction guidance mechanism:
[0024] The personalized aggregation of the i-th client is performed using a layer-by-layer direction guidance mechanism;
[0025] Using the model-level weight coefficients obtained in step S4, select the top k client models with larger aggregate weight coefficients;
[0026] Calculate the direction vector of each client model using the guidance of each client to the i-th client;
[0027] The server calculates the direction vector of each client model at the model level and broadcasts all direction vectors to the corresponding clients;
[0028] After receiving the direction vector, each client updates its personalized model layer by layer;
[0029] The above local training, aggregation weight calculation and personalized model aggregation process are repeated until the preset training rounds are reached.
[0030] S1 Benefits of scrap steel image collection and preprocessing: ensuring high quality of input data, reducing noise interference during model training, and improving model learning efficiency and accuracy; S2 Benefits of model initialization: unifying initial conditions to avoid deviations in training results caused by differences in initial models; S3 Benefits of local training: each client model can better adapt to and learn local scrap steel data, improve local detection accuracy, and stochastic gradient descent combined with the cross-entropy loss function can ensure the efficiency and stability of the model training process; S4 Benefits of the aggregation weight method based on client model differences: accurately measure the similarity of each client model, avoid the model biased towards specific client data during training, improve the overall generalization ability of the aggregated model, and enhance the performance of the model on different client data; S5 Benefits of personalized model aggregation based on layer-by-layer direction guidance mechanism: ensure that each client model can effectively absorb useful information from other clients, improve the generalization ability and accuracy of the model, and the layer-by-layer update mechanism ensures that the model is gradually optimized to achieve the preset training effect.
[0031] Preferably, in the step S3, for stochastic gradient descent, each round of local training uses a small batch data set to perform gradient calculation and update model parameters, which is defined as:
[0032] Among them, θ is the model parameter, η is the learning rate, and loss i (θ) represents the loss value of the i-th sample.
[0033] Compared with batch gradient descent, stochastic gradient descent only needs to calculate the gradient of a single or a small number of samples during iteration, which greatly reduces the amount of calculation and improves the training speed. Stochastic gradient descent can quickly approach the minimum value of the loss function and avoid falling into the local minimum. Since the iteration only processes a single or a small number of samples, the memory required for stochastic gradient descent is reduced. At the same time, due to the heterogeneity of data from scrap steel recycling sites, stochastic gradient descent can improve the performance of the model on each data set through small batch data sets, so as to improve the accuracy and generalization ability of the scrap steel detection model.
[0034] Preferably, in step S3, the cross entropy loss function is defined as:
[0035] Among them, N is the number of samples in the data set, K is the number of labels in the data set, and y i,k Indicates the probability that the i-th sample actually belongs to the k-th class label, It represents the probability that the model predicts that the i-th sample belongs to the k-th class label.
[0036] The cross entropy loss function is very sensitive to differences in probability distributions, and can accurately reflect the subtle differences between model predictions and actual labels, and effectively guide the model optimization process. The cross entropy loss function is widely used in classification problems, especially in multi-category classification tasks, and can effectively handle complex classification tasks. The logarithmic function has good stability in numerical calculations, and logarithmic operations can avoid numerical overflow problems caused by extremely small or extremely large probabilities. At the same time, the cross entropy loss function is based on probability and provides an intuitive probability explanation, making the model output more interpretable and credible, and easy to understand and apply.
[0037] Preferably, in step S4, each client model parameter is defined as w i (1≤i≤M), the server accepts each client model parameter set {w1,w2,…,w M}, the client model can be divided into s layers, then the i-th client model parameters can be divided into According to the cosine similarity, the model similarity of any client at the level can be calculated. The function expression is:
[0038] Among them, sims;i,j represents the hierarchical similarity between the i-th client model and the j-th client model at the s-th layer of the model.
[0039] Cosine similarity is a dimensionless quantification method with a result between -1 and 1. It can effectively measure the directional similarity of vectors. For the data heterogeneity of different scrap steel recycling sites, cosine similarity can effectively compare the similarity of different client models, ignoring the differences in data volume and feature distribution. By calculating the similarity of each level, it can accurately identify model parameters with higher similarity and give them higher weights during aggregation, thereby improving the accuracy and generalization ability of the global model.
[0040] Preferably, in step S4, the loss value of each model is defined as l i (1≤i≤M), the server receives the loss value set {l1,l2,…,l M}, normalize the loss value, function expression:
[0041] Depend on The two get the aggregation weights of the layers between each model It represents the weight coefficient of client j to client i on the sth layer of the model when performing the personalized model aggregation method based on the layer-by-layer direction guidance mechanism.
[0042] Normalization adjusts the loss values of different clients to the same scale to avoid aggregation bias caused by the size of the data set or the range of loss values. Through normalization, the contribution of each client model can be fairly measured to ensure that the aggregation process avoids unfairness caused by excessively large or small loss values of a single client. At the same time, by combining cosine similarity and normalized loss value, the aggregation weight considers the similarity of model parameters and the accuracy of each model to comprehensively measure the contribution of each client model.
[0043] Preferably, the weight coefficient An increase indicates that client j’s contribution to client i’s model increases, and the weight coefficient The model added to represent client j has a higher similarity with the model of client i, and at the same time, the model itself has a higher accuracy.
[0044] Preferably, in step S5, the direction vector of each client model to client i is calculated by using the guidance of each client to client i through the layer-by-layer direction guidance mechanism, and the function expression is: in, is the direction vector of the client i selected to participate in the personalized aggregation update at layer l, which is used to guide the client model w i Update direction at layer l.
[0045] The layer-by-layer directional guidance mechanism makes the model update more refined, and can adjust the model parameters layer by layer to improve the model's adaptability to local data. By considering the guidance of other clients, client i can absorb useful information from other client models and perform more accurate optimization on local data, thereby improving the performance of personalized models. At the same time, the directional vector combines the guidance information of multiple groups of clients, so that the personalized model can be optimized for local data and draw on the data characteristics of other clients to improve the overall generalization ability.
[0046] Preferably, in the step S5, after receiving the direction vector, each client updates its personalized model layer by layer, and the function expression is:
[0047] The present invention provides a personalized federated learning scrap steel detection method based on layer-by-layer direction guidance. It has the following beneficial effects:
[0048] 1. This solution adopts personalized federated learning based on a layer-by-layer directional guidance mechanism. By utilizing the differences between client models and using the layer-by-layer directional guidance mechanism, the directional vector of each client at the level is calculated to guide the update direction of each client's personalized model. In this way, a personalized model is customized for each scrap steel recycling site, so that the personalized model can further perform detailed learning on its own local data while ensuring that the data of other scrap steel recycling sites are learned, thereby improving the performance of the model on its own client.
[0049] 2. The personalized federated learning method with layer-by-layer direction guidance proposed in the present invention enables the personalized model of each scrap steel recycling station to learn the knowledge of other models that are highly correlated with its own model layer by layer, and maximize the use of data from other scrap steel recycling stations to further improve the performance of its own personalized model, thereby solving the problem of performance degradation caused by data heterogeneity in the actual application scenarios of scrap steel detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 is a flow chart of the method of the present invention;
[0051] Figure 2 This is a framework diagram of the method of the present invention. DETAILED DESCRIPTION
[0052] In order to make the technical personnel in the technical field understand the scheme of the present invention, the technical scheme in the embodiment of the present invention will be clearly and completely described below in combination with the drawings in the embodiment of the present invention. Obviously, the described embodiment is a partial embodiment of the present invention, not a complete embodiment. Based on the embodiment of the present invention, other embodiments obtained by ordinary technicians in the field without creative work should fall within the scope of protection of the present invention.
[0053] The present invention is described in detail below in conjunction with the accompanying drawings:
[0054] Embodiment 1:
[0055] Please refer to the attached Figure 1 , Attachment Figure 2 The embodiment of the present invention provides a personalized federated learning scrap steel detection method based on layer-by-layer direction guidance, comprising the following steps:
[0056] S1. Scrap image collection and preprocessing:
[0057] Use high-resolution industrial cameras to collect scrap steel images at different unloading points in different scrap steel recycling stations to form a high-definition image dataset;
[0058] Annotate the collected images, including scrap type and quality information;
[0059] Perform data preprocessing, including data cleaning, denoising, removal of duplicate images, and data cropping;
[0060] The scrap steel image dataset is divided into a training set and a test set in a ratio of 8:2;
[0061] S2. Initialize the model:
[0062] Each scrap steel recycling site deploys an initial model with the same structure and parameters;
[0063] S3. Local training:
[0064] Each client uses the scrap steel image dataset for local training;
[0065] The stochastic gradient descent method combined with the cross entropy loss function is used for model optimization;
[0066] Each round of local training uses a small batch of data sets to calculate gradients and update model parameters;
[0067] S4. Aggregation weight method based on client model differences:
[0068] Each scrap steel recycling site uploads local model parameters and loss values to the server;
[0069] The server calculates the similarity of each client model layer by layer through cosine similarity and calculates the model level aggregation weight;
[0070] Define the model parameters of each client and calculate the model similarity of the clients at the level;
[0071] Normalize the loss values and calculate the aggregation weights between model layers;
[0072] S5. Personalized model aggregation based on layer-by-layer direction guidance mechanism:
[0073] A layer-by-layer direction guidance mechanism is used for personalized aggregation of the i-th client;
[0074] Select the top k client models with larger aggregation weights through the model-level weight coefficients;
[0075] Calculate the guidance direction vector of each client to the i-th client;
[0076] The server calculates the direction vector and broadcasts it to the corresponding client;
[0077] After receiving the direction vector, each client updates the personalized model layer by layer;
[0078] Repeat local training, aggregation weight calculation, and personalized model aggregation until the preset training rounds are reached.
[0079] Summary: In Example 1, the layer-by-layer directional guidance mechanism calculates the client model similarity through cosine similarity, and uses this to guide each client model to update layer by layer, thereby optimizing the personalized model performance of each scrap steel recycling site and solving the data heterogeneity problem.
[0080] Embodiment 2:
[0081] Please refer to the attached Figure 1 , Attachment Figure 2 The embodiment of the present invention provides a personalized federated learning scrap steel detection method based on layer-by-layer direction guidance, comprising the following steps:
[0082] S1. Scrap image collection and preprocessing:
[0083] Use high-resolution industrial cameras to collect scrap steel images at different unloading points in different scrap steel recycling stations to form a high-definition image dataset;
[0084] Annotate the captured images, including scrap type and quality information;
[0085] Perform data preprocessing, including data cleaning, denoising, removal of duplicate images, and data cropping;
[0086] The scrap steel image dataset is divided into training set and test set in a ratio of 7:3;
[0087] S2. Initialize the model:
[0088] Each scrap steel recycling site deploys an initial model with the same structure and parameters;
[0089] S3. Local training:
[0090] Each client uses the scrap steel image dataset for local training;
[0091] The Adam optimizer is used in combination with the cross entropy loss function to optimize the model;
[0092] Each round of local training uses a small batch of data sets to calculate gradients and update model parameters;
[0093] S4. Aggregation weight method based on client model differences:
[0094] Each scrap steel recycling site uploads local model parameters and loss values to the server;
[0095] The server calculates the similarity of each client model layer by layer through the Euclidean distance and calculates the model level aggregation weight;
[0096] Define the model parameters of each client and calculate the model similarity of the clients at the level;
[0097] Normalize the loss values and calculate the aggregation weights between model levels;
[0098] S5. Personalized model aggregation based on layer-by-layer direction guidance mechanism:
[0099] A layer-by-layer direction guidance mechanism is used for personalized aggregation of the i-th client;
[0100] Select the top k client models with larger aggregation weights through the model-level weight coefficients;
[0101] Calculate the guidance direction vector of each client to the i-th client;
[0102] The server calculates the direction vector and broadcasts it to the corresponding client;
[0103] After receiving the direction vector, each client updates the personalized model layer by layer;
[0104] Repeat local training, aggregation weight calculation, and personalized model aggregation until the preset training rounds are reached.
[0105] Summary: Example 2 improves the aggregation mechanism by using Euclidean distance instead of cosine similarity to calculate model similarity and using Adam optimizer to optimize the model. This method further enhances the adaptability of the model in a data heterogeneous environment and improves the performance of the personalized model.
[0106] Embodiment three:
[0107] Please refer to the attached Figure 1 , Attachment Figure 2 The embodiment of the present invention provides a personalized federated learning scrap steel detection method based on layer-by-layer direction guidance, comprising the following steps:
[0108] S1. Scrap image collection and preprocessing:
[0109] Use high-resolution industrial cameras to collect scrap steel images at different unloading points in different scrap steel recycling stations to form a high-definition image dataset;
[0110] Annotate the captured images, including scrap type and quality information;
[0111] Perform data preprocessing, including data cleaning, denoising, removal of duplicate images, and data cropping;
[0112] The scrap steel image dataset is divided into training set and test set in a ratio of 7:3;
[0113] S2. Initialize the model:
[0114] Each scrap steel recycling station deploys a convolutional neural network (CNN) initial model with the same structure and parameters;
[0115] S3. Local training:
[0116] Each client uses the scrap steel image dataset for local training;
[0117] The Adam optimizer is used in combination with the cross entropy loss function to optimize the model;
[0118] Each round of local training uses a small batch of data sets to calculate gradients and update model parameters;
[0119] S4. Aggregation weight method based on client model differences:
[0120] Each scrap steel recycling site uploads local model parameters and loss values to the server;
[0121] The server calculates the similarity of each client model layer by layer through cosine similarity and calculates the model level aggregation weight;
[0122] Define the model parameters of each client and calculate the model similarity of the clients at the level;
[0123] Normalize the loss values and calculate the aggregation weights between model levels;
[0124] S5. Personalized model aggregation based on layer-by-layer direction guidance mechanism:
[0125] A layer-by-layer direction guidance mechanism is used for personalized aggregation of the i-th client;
[0126] Select the top k client models with larger aggregation weights through the model-level weight coefficients;
[0127] Calculate the guidance direction vector of each client to the i-th client;
[0128] The server calculates the direction vector and broadcasts it to the corresponding client;
[0129] After receiving the direction vector, each client updates the personalized model layer by layer;
[0130] Repeat local training, aggregation weight calculation, and personalized model aggregation until the preset training rounds are reached.
[0131] Summary: Example 3 uses a convolutional neural network (CNN) as the basic model, combined with a layer-by-layer directional guidance mechanism, to enhance image data processing capabilities and improve the accuracy and efficiency of scrap steel detection.
[0132] Embodiment 4:
[0133] Please refer to the attached Figure 1 , Attachment Figure 2The embodiment of the present invention provides a personalized federated learning scrap steel detection method based on layer-by-layer direction guidance, comprising the following steps:
[0134] S1. Scrap image collection and preprocessing:
[0135] Use high-resolution industrial cameras to collect scrap steel images at different unloading points in different scrap steel recycling stations to form a high-definition image dataset;
[0136] Annotate the captured images, including scrap type and quality information;
[0137] Perform data preprocessing, including data cleaning, denoising, removal of duplicate images, and data cropping;
[0138] The scrap steel image dataset is divided into a training set and a test set in a ratio of 6:4;
[0139] S2. Initialize the model:
[0140] Each scrap steel recycling site deploys an initial model with the same structure and parameters;
[0141] S3. Local training:
[0142] Each client uses the scrap steel image dataset for local training;
[0143] The SGD optimizer is used in combination with the mean square error loss function for model optimization;
[0144] Each round of local training uses a small batch of data sets to calculate gradients and update model parameters;
[0145] S4. Aggregation weight method based on client model differences:
[0146] Each scrap steel recycling site uploads local model parameters and loss values to the server;
[0147] The server calculates the similarity of each client model layer by layer through cosine similarity and calculates the model level aggregation weight;
[0148] Define the model parameters of each client and calculate the model similarity of the clients at the level;
[0149] Normalize the loss values and calculate the aggregation weights between model levels;
[0150] S5. Personalized model aggregation based on layer-by-layer direction guidance mechanism:
[0151] A layer-by-layer direction guidance mechanism is used for personalized aggregation of the i-th client;
[0152] Select the top k client models with larger aggregation weights through the model-level weight coefficients;
[0153] Calculate the guidance direction vector of each client to the i-th client;
[0154] The server calculates the direction vector and broadcasts it to the corresponding client;
[0155] After receiving the direction vector, each client updates the personalized model layer by layer;
[0156] Repeat local training, aggregation weight calculation, and personalized model aggregation until the preset training rounds are reached.
[0157] Summary: Example 4 uses a 6:4 training set and test set split ratio and adopts a mean square error loss function. This method can verify the generalization ability of the model under different data split ratios.
[0158] Embodiment five:
[0159] Please refer to the attached Figure 1 , Attachment Figure 2 The embodiment of the present invention provides a personalized federated learning scrap steel detection method based on layer-by-layer direction guidance, comprising the following steps:
[0160] S1. Scrap image collection and preprocessing:
[0161] Use high-resolution industrial cameras to collect scrap steel images at different unloading points in different scrap steel recycling stations to form a high-definition image dataset;
[0162] Annotate the captured images, including scrap type and quality information;
[0163] Perform data preprocessing, including data cleaning, denoising, removal of duplicate images, and data cropping;
[0164] The scrap steel image dataset is divided into a training set and a test set in a ratio of 8:2;
[0165] S2. Initialize the model:
[0166] Each scrap steel recycling site deploys an initial model with the same structure and parameters;
[0167] S3. Local training:
[0168] Each client uses the scrap steel image dataset for local training;
[0169] The Adam optimizer is used in combination with the cross entropy loss function to optimize the model;
[0170] Each round of local training uses a small batch of data sets to calculate gradients and update model parameters;
[0171] S4. Aggregation weight method based on client model differences:
[0172] Each scrap steel recycling site uploads local model parameters and loss values to the server;
[0173] The server calculates the similarity of each client model layer by layer through Euclidean distance and calculates the model level aggregation weight;
[0174] Define the model parameters of each client and calculate the model similarity of the clients at the level;
[0175] Normalize the loss values and calculate the aggregation weights between model layers;
[0176] S5. Personalized model aggregation based on layer-by-layer direction guidance mechanism:
[0177] A layer-by-layer direction guidance mechanism is used for personalized aggregation of the i-th client;
[0178] Select the top k client models with larger aggregation weights through the model-level weight coefficients;
[0179] Calculate the guidance direction vector of each client to the i-th client;
[0180] The server calculates the direction vector and broadcasts it to the corresponding client;
[0181] After receiving the direction vector, each client updates the personalized model layer by layer;
[0182] Repeat local training, aggregation weight calculation, and personalized model aggregation until the preset training rounds are reached.
[0183] Summary: Example 5 improves the similarity calculation method and uses Euclidean distance instead of cosine similarity. In this way, the influence of different similarity calculation methods on the model aggregation effect can be explored to optimize the model performance.
[0184] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A personalized federated learning scrap steel detection method based on layer-by-layer direction guidance, characterized in that: The steps include: S1. Scrap image collection and preprocessing: High-resolution industrial cameras are used to collect high-definition images of different types of scrap steel at different unloading points of each scrap steel recycling station as training data sets; Annotate the collected image data; Perform data preprocessing, including data cleaning, removing noise and duplicate images, and data cropping; The scrap steel image dataset is divided into a training set and a test set in a ratio of 8:2; S2. Initialize the model: Each scrap steel recycling station deploys an initial model with the same parameters and structure; S3. Local training: Each client uses the scrap steel image dataset for local training; Use stochastic gradient descent combined with cross entropy loss function to optimize the model; For stochastic gradient descent, each round of local training uses a small batch of data sets to calculate gradients and update model parameters; S4. Aggregation weight method based on client model differences: Each scrap steel recycling site uploads local model parameters and loss values to the server; The server calculates the similarity of each client model layer by layer through cosine similarity to calculate the hierarchical aggregation weight of each model; Normalize the loss values and calculate the aggregation weights of the layers between the models; S5. Personalized model aggregation based on layer-by-layer direction guidance mechanism: The personalized aggregation of the i-th client is performed using a layer-by-layer direction guidance mechanism; Using the model-level weight coefficients obtained in step S4, select the top k client models with larger aggregate weight coefficients; Calculate the direction vector of each client model using the guidance of each client to the i-th client; The server calculates the direction vector of each client model at the model level and broadcasts all direction vectors to the corresponding clients; After receiving the direction vector, each client updates its personalized model layer by layer; The above local training, aggregation weight calculation and personalized model aggregation process are repeated until the preset training rounds are reached.
2. According to claim 1, a personalized federated learning scrap steel detection method based on layer-by-layer direction guidance is characterized in that: In the S3 step, for stochastic gradient descent, each round of local training uses a small batch data set to calculate the gradient and update the model parameters, which is defined as: Among them, θ is the model parameter, η is the learning rate, and loss i (θ) represents the loss value of the i-th sample.
3. The personalized federated learning scrap steel detection method based on layer-by-layer direction guidance according to claim 1 is characterized in that: In the S3 step, the cross entropy loss function is defined as: Among them, N is the number of samples in the data set, K is the number of labels in the data set, and y i,k Indicates the probability that the i-th sample actually belongs to the k-th class label, It represents the probability that the model predicts that the i-th sample belongs to the k-th class label.
4. The personalized federated learning scrap steel detection method based on layer-by-layer direction guidance according to claim 1 is characterized in that: In the step S4, the model parameters of each client are defined as w i (1≤i≤M), the server accepts each client model parameter set {w1,w2,…,w M }, the client model can be divided into s layers, then the i-th client model parameters can be divided into According to the cosine similarity, the model similarity of any client at the level can be calculated. The function expression is: Among them, sim(s;i,j) represents the hierarchical similarity between the i-th client model and the j-th client model at the s-th layer of the model.
5. The personalized federated learning scrap steel detection method based on layer-by-layer direction guidance according to claim 1 is characterized in that: In the S4 step, the loss value of each model is defined as l i (1≤i≤M), the server accepts the loss value set {l1,l2,…,l M }, normalize the loss value, function expression: Depend on The two get the aggregation weights of the layers between each model It represents the weight coefficient of client j to client i on the sth layer of the model when performing the personalized model aggregation method based on the layer-by-layer direction guidance mechanism.
6. The personalized federated learning scrap steel detection method based on layer-by-layer direction guidance according to claim 5 is characterized in that: The weight coefficient An increase indicates that client j’s contribution to client i’s model increases, and the weight coefficient The model added to represent client j has a higher similarity with the model of client i, and at the same time, the model itself has a higher accuracy.
7. The personalized federated learning scrap steel detection method based on layer-by-layer direction guidance according to claim 1 is characterized in that: In step S5, the direction vector of each client model to client i is calculated by using the layer-by-layer direction guidance mechanism and utilizing the guidance of each client to client i. The function expression is: in, is the direction vector of the client i selected to participate in the personalized aggregation update at layer l, which is used to guide the client model w i Update direction at layer l. k is the number of clients participating in the personalized aggregation of client i in this round.
8. The personalized federated learning scrap steel detection method based on layer-by-layer direction guidance according to claim 1 is characterized in that: In the step S5, after receiving the direction vector, each client updates its personalized model layer by layer, and the function expression is:
Citation Information
Patent Citations
Personalized federal learning method and system based on adaptive clustering layering
CN115840900A
Anti-poison attack privacy protection federated learning method based on block chain
CN116451805A
Personalized Federated Learning Via Sharable Basis Models
US20240119307A1
Model processing method, federated learning method, and related device
WO2023279975A1
Cited By
Longitudinal federal learning method and device combined with early leaving mechanism, and storage medium
CN120725100A