Personalized federated learning method and system based on category reliability weighting prototype and gate
Patent Information
- Application Number
- CN202611135823.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-29
- Publication Date
- 2026-10-30
AI Technical Summary
[0003]然而,实际联邦学习场景中的客户端数据通常并非独立同分布,可能存在类别分布不均、类别缺失、样本数量差异或域偏移
[0029]1、本发明通过类别级可靠性权重按类别评估原型可靠性,降低低样本、高不确定性或高离散度类别原型对共享表示的影响;
Smart Images

Figure CN123014090A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of machine learning and data security technology, and in particular to a personalized federated learning method and system based on category reliability weighted prototyping and gating. Background Technology
[0002] In application scenarios where data security and privacy protection requirements are increasing, federated learning enables multiple clients to collaboratively complete model training without directly uploading raw data by training the model locally on multiple clients and having the interaction of the model or intermediate representation coordinated by the server.
[0003] However, client data in real-world federated learning scenarios is often not independent and identically distributed, and may exhibit uneven class distribution, missing classes, differences in sample numbers, or domain shifts. For prototype-based or class-centered federated learning methods, directly averaging the class prototypes uploaded by clients can easily lead to contamination by low-reliability prototypes such as low sample size, high uncertainty, high dispersion, or anomalous shifts. Fixed-strength global alignment may also weaken the client's adaptability to local data distribution and introduce negative transfer when data heterogeneity is high.
[0004] Therefore, there is an urgent need to provide a personalized federated learning scheme that can evaluate the reliability of client prototypes by category without uploading original samples, and adaptively coordinate between globally shared knowledge, domain-level shared knowledge, and local personalized knowledge. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this invention provides a personalized federated learning method and system based on category reliability weighted prototyping and gating, in order to improve the classification accuracy and personalized adaptation capability of non-independent and identically distributed federated scenarios.
[0006] In a first aspect, this invention provides a personalized federated learning method based on category reliability weighted prototyping and gating, including:
[0007] The client maps local samples to a public feature space and calculates local category prototypes and category statistics by category.
[0008] The client uploads the local category prototype, category statistics, and client descriptor corresponding to the valid category to the server.
[0009] The class-level reliability weight of the client corresponding to the valid class is determined by the class statistics of each valid class by the server;
[0010] The server maintains a global category prototype based on the category-level reliability weights.
[0011] The server groups clients based on the client descriptor and maintains domain-level category prototypes within each client group based on the category-level reliability weights.
[0012] Normalized gating coefficients are generated using the client's local state, the global category prototype, and the domain-level category prototype.
[0013] The client uses normalized gating coefficients to fuse the classification outputs of the global branch, domain-level branch, and local branch, and uses the global branch gating weights and domain-level branch gating weights in the normalized gating coefficients to adjust the alignment training intensity of local features to the global category prototype and the domain-level category prototype, respectively.
[0014] Secondly, the present invention provides a personalized federated learning system based on category reliability weighted prototyping and gating, including a server and multiple clients;
[0015] The client is configured with a first module, a second module, a third module, and a fourth module;
[0016] The server is configured with a fifth module, a sixth module, and a seventh module; wherein:
[0017] The first module is used to map the client's local samples to the public feature space and calculate the local category prototype and category statistics by category;
[0018] The second module is used to upload the local category prototype, category statistics and client descriptor corresponding to the valid category to the server.
[0019] The fifth module is used to determine the category-level reliability weight of the corresponding valid category for the client based on the category statistics of each valid category;
[0020] The sixth module is used to maintain a global category prototype based on the category-level reliability weights;
[0021] The seventh module is used to group clients according to the client descriptor and maintain domain-level category prototypes within the client group based on the category-level reliability weights.
[0022] The third module is used to generate normalized gating coefficients based on the client's local state, the global category prototype, and the domain-level category prototype.
[0023] The fourth module is used to fuse the classification outputs of the global branch, the domain-level branch, and the local branch using normalized gating coefficients, and to adjust the alignment training intensity of the local features to the global category prototype and the domain-level category prototype using the global branch gating weight and the domain-level branch gating weight in the normalized gating coefficients, respectively.
[0024] Thirdly, the present invention provides an electronic device, comprising:
[0025] At least one processor;
[0026] and a memory communicatively connected to the at least one processor;
[0027] The memory stores a computer program that can be executed by the at least one processor, and when the computer program is executed by the at least one processor, it implements the personalized federated learning method based on category reliability weighted prototyping and gating.
[0028] The beneficial effects of this invention are as follows:
[0029] 1. This invention evaluates prototype reliability by category through category-level reliability weights, thereby reducing the impact of low-sample, high-uncertainty, or high-dispersion category prototypes on shared representations;
[0030] 2. This invention improves the adaptability to heterogeneous data by collaboratively maintaining global category prototypes and domain-level category prototypes, providing an intermediate layer of knowledge between globally shared knowledge and locally personalized knowledge;
[0031] 3. This invention, through client-side grouping and domain-level category prototypes, generates domain-level knowledge that better matches the client distribution without uploading original samples;
[0032] 4. This invention enables clients to adaptively coordinate global knowledge, domain-level knowledge, and local knowledge based on local state, global category prototype, and domain-level category prototype through gating fusion.
[0033] 5. This invention uses the same gating coefficient for classification information fusion and adjusts the corresponding prototype alignment training intensity through the global branch weight and domain-level branch weight, respectively, thereby reducing the negative transfer risk that fixed-intensity shared alignment may cause in heterogeneous data scenarios. Attached Figure Description
[0034] Figure 1 This is a flowchart illustrating the method of an embodiment of the present invention;
[0035] Figure 2 This is a structural framework diagram of the system according to an embodiment of the present invention;
[0036] In the diagram, 10 represents the server and 20 represents the client.
[0037] 101 - Module 1; 102 - Module 2; 103 - Module 3; 104 - Module 4;
[0038] 201 - Module 5; 202 - Module 6; 203 - Module 7. Detailed Implementation
[0039] The specific embodiments of the present invention will be further described below with reference to the accompanying drawings:
[0040] like Figure 1 As shown, this embodiment provides a personalized federated learning method based on category reliability weighted prototyping and gating, including:
[0041] S1: Map local samples to the public feature space via the client, and calculate local category prototypes and category statistics by category;
[0042] S2: Upload the local category prototype, category statistics, and client descriptor corresponding to the valid category to the server through the client;
[0043] S3: Determine the category-level reliability weight of the client corresponding to the valid category by using the category statistics of each valid category by the server;
[0044] S4: The server maintains a global category prototype based on the category-level reliability weights;
[0045] S5: The server groups clients according to the client descriptor and maintains domain-level category prototypes within the client groups based on the category-level reliability weights;
[0046] S6: Generate normalized gating coefficients using the client's local state, the global category prototype, and the domain-level category prototype;
[0047] S7: The client uses normalized gating coefficients to fuse the classification outputs of the global branch, the domain-level branch, and the local branch, and uses the global branch gating weights and the domain-level branch gating weights in the normalized gating coefficients to adjust the alignment training intensity of the local features to the global category prototype and the domain-level category prototype, respectively.
[0048] In this embodiment, step S1 involves mapping local samples to a public feature space via a client, and calculating local category prototypes and category statistics by category, including:
[0049] S11: Divide the local samples into multiple batches, input the samples into the client's private local feature extractor to extract the underlying private features, and then project the underlying private features across clients using a common feature mapping function. By performing a normalization operation, a unified common feature is obtained, i.e.:
[0050] ;
[0051] In the formula, For the first Sample Mapped common features; For the first Local feature extractor for each client; To indicate the first Local feature extractor parameters for each client; This indicates a normalization operation; For common feature mapping functions; This represents the common feature mapping parameters.
[0052] S12: Iterate through all local sample real labels, group them by category, and construct a sample set for each category;
[0053] ;
[0054] In the formula, For the first A local sample set for each client; For the first Category of clients The sample set; For the sample The true label; For category;
[0055] S13: Count the number of samples in each category set. If the number of samples is less than the minimum effective sample threshold, the corresponding category is determined to be an invalid category; if the number of samples is greater than or equal to the minimum effective sample threshold, the corresponding category is determined to be a valid category.
[0056] S14: For each valid category, calculate the mean of features based on the common features of the category set as the local category prototype for the corresponding valid category, i.e.:
[0057] ;
[0058] In the formula, For the first Each client corresponds to a valid category The local category prototype; This represents the number of samples.
[0059] S15: For each valid category, calculate the number of category samples, category prediction uncertainty, intra-class feature dispersion, and prototype offset in parallel.
[0060] In this embodiment, the calculation of the category prediction uncertainty includes:
[0061] Category set through client-side local model Forward inference is performed on all samples to obtain the predicted probability distribution for each category. Based on the category predicted probability distribution, the predicted entropy of a single sample is calculated using the prediction entropy, and the category set is then selected. The mean of the prediction entropy of all samples is used as the category prediction uncertainty. ,Right now:
[0062] ;
[0063] In the formula, For the sample Predicted entropy; For any category label; Indicates a given input sample At that time, the local model predicts that it belongs to category The posterior probability.
[0064] In this embodiment, the calculation of the intra-class feature dispersion includes:
[0065] Traverse the category collection Each public feature And calculate each common feature With local category prototype Euclidean distance;
[0066] And calculate all common features With local category prototype The mean of the Euclidean distance is used as the within-class feature dispersion. .
[0067] In this embodiment, the calculation of the prototype offset includes:
[0068] Read the global category prototype issued by the server in the previous round. And calculate the local category prototype. Compared to the previous round of global category prototypes L2 distance as prototype offset .
[0069] In some embodiments, the category statistics include at least the number of category samples, category prediction uncertainty, intra-class feature dispersion, and prototype offset.
[0070] In this embodiment, in step S2, the client descriptor includes at least:
[0071] The category distribution vector represents the proportion of all valid category samples in the client's local sample set to the total local sample set.
[0072] Valid category mask;
[0073] The statistical aggregation results include the average number of samples for all valid categories in the local dataset, the average category prediction uncertainty, and the average intra-class feature dispersion.
[0074] In this embodiment, step S3, determining the category-level reliability weight of the client corresponding to the valid category through the category statistics of each valid category by the server, includes:
[0075] S31: Obtain the client's information at the... Based on the valid identifiers of the local category prototypes corresponding to the valid categories and the number of category samples, clients that meet the conditions are assigned to the set of valid clients for this round of valid categories, that is:
[0076] ;
[0077] In the formula, For the first Wheel valid categories A set of valid upload clients; The minimum effective sample threshold; For the first The client in the first Wheel corresponding to valid category The number of samples in each category; For the client In the The local category prototype valid identifier corresponding to the valid category;
[0078] S32: For any valid client, calculate the class determination reliability score based on the number of class samples, class prediction uncertainty, intra-class feature dispersion, and prototype offset of the valid client, i.e.:
[0079] ;
[0080] In the formula, For the first The client in the first Wheel corresponding to valid category Category reliability score; The influence coefficient of sample size; This is the sample size gain term; , , Category prediction uncertainty Intra-class feature dispersion Prototype offset The penalty weight;
[0081] S33: Sum the category-based reliability scores for valid upload clients of valid categories, and calculate the category-level reliability weight for each client, i.e.:
[0082]
[0083] In the formula, For the first The client in the first Wheel corresponding to valid category Category-level reliability weights; This represents a stability constant used to avoid a denominator of zero.
[0084] In this embodiment, step S4, maintaining a global category prototype based on the category-level reliability weights by the server, includes:
[0085] S41. For all valid clients under the valid category, calculate the weighted aggregate prototype for this round using the category-level reliability weight and the local category prototype, i.e.:
[0086] ;
[0087] In the formula, For the first Wheel corresponding to valid category The weighted aggregation prototype;
[0088] S42. Use the global prototype update rate to fuse the previous round's global category prototype with the current round's weighted aggregate prototype to obtain the current round's global category prototype, i.e.:
[0089] ;
[0090] In the formula, This represents the global prototype update rate. Indicates the first Wheel valid categories The global category prototype; This is the prototype of the global category from the previous round.
[0091] In this embodiment, step S5 involves the server grouping clients according to the client descriptor and maintaining domain-level category prototypes within each client group based on the category-level reliability weights, including:
[0092] S51: Perform a sliding average smoothing on the multi-round client descriptors to obtain smoothed client descriptors, and then perform standardization on the smoothed client descriptors to obtain standardized client descriptors.
[0093] In this embodiment, the multi-round client descriptor is smoothed by a moving average to obtain a smoothed client descriptor, represented as:
[0094] ;
[0095] In the formula, Let t be the client descriptor after smoothing in round t; The descriptor moving average decay coefficient; Let k be the client descriptor for client k in round t.
[0096] The smoothed client descriptor is then standardized to obtain a standardized client descriptor.
[0097] ;
[0098] In the formula, , These are the mean and variance of the smoothed client descriptors for all clients, respectively. It is the minimum stability constant; A standardized client descriptor.
[0099] S52: Use the standardized client descriptors of all clients as sample input for iterative clustering calculation to obtain the client grouping results, including:
[0100] S521: Concatenate the standardized client descriptors of all the clients into a descriptor input matrix. ,Right now:
[0101] ;
[0102] In the formula, To ensure the effective uploading of customer numbers.
[0103] S522: Based on the standardized client descriptors, calculate the Euclidean distance between the standardized client descriptors and each cluster center, and assign the client to the cluster with the smallest Euclidean distance, i.e.:
[0104] ;
[0105] ;
[0106] In the formula, For client k and cluster class European distance, Cluster Cluster centers; Number of clusters; It is a cluster;
[0107] S523: Based on the standardized client descriptors of all clients in each cluster, recalculate the new cluster centers, i.e.:
[0108] ;
[0109] In the formula, Cluster The number of clients; As the new cluster center;
[0110] S524: Following the steps S522-S523, regroup the clients based on the new cluster centers, and then calculate the cluster centers of the new clusters until the change in cluster centers is less than the threshold, at which point training stops.
[0111] In some embodiments, clients are grouped using the standardized descriptor cosine similarity of the clients, i.e.:
[0112] ;
[0113] If any two clients k and Standardized descriptor cosine similarity Greater than the similarity threshold Then the client k and the client They were grouped together.
[0114] In some embodiments, clients are grouped using graph-based community detection, including:
[0115] An undirected graph is constructed using clients as nodes and the standardized cosine similarity of the clients' descriptors as weights. Louvain and other community partitioning algorithms are run to automatically output group numbers, including:
[0116] Set nodes Currently not part of the community Calculate the node Moving into the community Modularity gain ,Right now:
[0117] ;
[0118] ;
[0119] ;
[0120] ;
[0121] ;
[0122] In the formula, It is an adjacency matrix; For nodes and The weights; The similarity threshold; For a set of nodes; For nodes The total weight; This represents the sum of the edge weights of an undirected graph. For the community Total out-degree weight of all nodes;
[0123] When modularity gain If the value is greater than 0, then the node will be... Moving into the community ;
[0124] Node-by-node traversal, attempting to move nodes into adjacent communities while preserving modularity gain. The largest and positive community division;
[0125] Compress all nodes in the same community into a super node. The edge weight between super nodes is the sum of the weights of all cross-community edges in the original community. Repeat the local movement.
[0126] Until the change in global modularity is less than the minimum threshold after two rounds of iteration. The global modularity mentioned The calculation formula is:
[0127] ;
[0128] In the formula, For the community The total internal weight.
[0129] S53: Perform intra-group normalization on the client category-level reliability weights of all valid clients within the group to obtain the normalized intra-group category-level reliability weights, i.e.:
[0130] ;
[0131] In the formula, For the first Normalized within-group category-level reliability weights for groups; In the first Round Group Valid Categories The corresponding set of valid clients, i.e. ;
[0132] S54: Based on the normalized intra-group category-level reliability weights, a weighted summation of all client-local category prototypes in the group is obtained to determine the intra-group aggregation center for this round, i.e.:
[0133] ;
[0134] In the formula, For the first The group's current aggregation center;
[0135] S55: Based on the group's current aggregation center and domain-level prototype update rate By integrating the historical domain prototype with the aggregation results within the current group, a domain-level category prototype is obtained, namely:
[0136] ;
[0137] In the formula, Indicates the first Wheel client group Medium category Domain-level category prototype, This represents the prototype of the corresponding domain-level category in the previous round. Indicates the domain-level prototype update rate; This represents the normalized category-level reliability weights within the group; This indicates the corresponding local category prototype.
[0138] In this implementation, step S6, generating normalized gating coefficients using the client's local state, the global category prototype, and the domain-level category prototype, includes:
[0139] S61: The client generates a gated input based on the local state, the global category prototype, the domain-level category prototype, and the average category prediction uncertainty, namely:
[0140] ;
[0141] In the formula, Indicates the first The client in the first Wheel gating input, This indicates a splicing operation. Indicates the client descriptor. This represents the average distance between the local category prototype and the global category prototype. This represents the average distance between the local category prototype and the domain-level category prototype. This indicates the client's average category prediction uncertainty;
[0142] In this embodiment, the average distance between the local category prototype and the global category prototype is... Represented as:
[0143] ;
[0144] In the formula, It is an L2 norm.
[0145] In this embodiment, the average distance between the local category prototype and the domain-level category prototype is... Represented as:
[0146] ;
[0147] In this embodiment, the client's average category prediction uncertainty Represented as:
[0148] ;
[0149] S62: Uses the gating parameters and biases issued by the server to perform a linear mapping on the gating input, and introduces a temperature coefficient to perform Softmax, generating normalized gating coefficients, i.e.:
[0150] ;
[0151] In the formula, Indicates the first The client in the first Round-normalized gating coefficients; B is the temperature coefficient; B is the gating parameter; b is the bias term.
[0152] S63: Decompose the normalized gating coefficients into global branch gating weights, domain-level branch gating weights, and local branch gating weights.
[0153] In this embodiment, in step S7, the client fuses the classification outputs of the global branch, domain-level branch, and local branch using normalized gating coefficients, and adjusts the alignment training intensity of local features to the global category prototype and the domain-level category prototype using the global branch gating weight and the domain-level branch gating weight in the normalized gating coefficients, respectively, including:
[0154] S71: Based on the common features of the samples With global category prototype Calculate category similarity and map it to obtain the global branch classification output. ;
[0155] Based on the common features of the samples With domain-level category prototypes Calculate similarity to obtain the domain branch classification output. ;
[0156] Based on the common features of the samples Input the client's local private category header to get the local branch category output. ;
[0157] S72: Utilizes global branch gating weights, domain-level branch gating weights, and local branch gating weights to fuse global branch classification output. Domain branch classification output Local branch classification output This results in personalized classification output; that is:
[0158] ;
[0159] In the formula, For personalized categorization output; Global branch gating weights; Domain-level branch gating weights; Local branch gating weights;
[0160] S73: Utilizing personalized classification output Calculate the classification cross-entropy loss ,Right now:
[0161] ;
[0162] In the formula, To represent the number of samples in a training batch; For the sample The true label; Indicates real label The corresponding personalized classification output probability;
[0163] S74: Calculate prototype alignment loss based on valid identifiers of global category prototypes and domain-level category prototypes. ,Right now:
[0164] ;
[0165] In the formula, For real labels A flag indicating whether the corresponding global category prototype is valid. This indicates that the global category prototype is invalid; For real labels A marker indicating whether the corresponding domain-level category prototype is valid. This indicates that the domain-level category prototype is invalid. For real labels The corresponding global category prototype; For the first Real tags in the client group to which each client belongs The corresponding domain-level category prototype;
[0166] S75: Introduces gated regularization loss and combines it with prototype alignment loss. and classification cross-entropy loss Calculate total loss ,Right now:
[0167] ;
[0168] In the formula, , Prototype alignment loss and gated regularization loss Weighting coefficients;
[0169] In this embodiment, the gated regularization loss Represented as:
[0170] ;
[0171] In the formula, This represents the gating weight corresponding to the s-th branch; Indicates a global branch; Indicates a domain-level branch; Indicates a local branch.
[0172] like Figure 2 As shown, another embodiment of this application is a personalized federated learning system based on category reliability weighted prototyping and gating, including a server 10 and multiple clients 20;
[0173] The client 10 is configured with a first module 101, a second module 102, a third module 103, and a fourth module 104;
[0174] The server 20 is configured with a fifth module 201, a sixth module 202, and a seventh module 203; wherein:
[0175] The first module 101 is used to map the client's local samples to the public feature space and calculate the local category prototype and category statistics by category;
[0176] The second module 102 is used to upload the local category prototype, category statistics and client descriptor corresponding to the valid category to the server.
[0177] Module 5, 201, is used to determine the category-level reliability weight of the corresponding valid category for the client based on the category statistics of each valid category.
[0178] The sixth module 202 is used to maintain a global category prototype based on the category-level reliability weights;
[0179] The seventh module 203 is used to group clients according to the client descriptor and maintain domain-level category prototypes within the client group based on the category-level reliability weights.
[0180] The third module 103 is used to generate normalized gating coefficients through the local state of the client, the global category prototype, and the domain-level category prototype;
[0181] The fourth module 104 is used to fuse the classification outputs of the global branch, the domain branch and the local branch using normalized gating coefficients, and to adjust the alignment training intensity of the local features to the global category prototype and the domain category prototype respectively using the global branch gating weight and the domain branch gating weight in the normalized gating coefficients.
[0182] In this embodiment, the first module 101 maps the client's local samples to the public feature space and calculates the local category prototype and category statistics by category, including:
[0183] The first module 101 divides the local samples into multiple batches and then... Input client private local feature extractor Extract the underlying private features and map these features through a common feature mapping function. By performing a unified spatial projection across clients and then normalizing it, a unified common characteristic is obtained, namely:
[0184] ;
[0185] In the formula, For the first Sample Mapped common features; For the first Local feature extractor for each client; To indicate the first Local feature extractor parameters for each client; This indicates a normalization operation; For common feature mapping functions; This represents the common feature mapping parameters.
[0186] The first module 101 traverses all local sample labels Group by category c and construct a sample set for each category. ;
[0187] ;
[0188] In the formula, For the first A local sample set for each client; For the first Category of clients The sample set.
[0189] The first module 101 counts the set of each category. Number of samples If the sample size If the number of samples is less than the minimum valid sample threshold, the corresponding category is determined to be an invalid category; if the number of samples is... If the value is greater than or equal to the minimum effective sample threshold, the corresponding category is determined to be a valid category.
[0190] The first module 101, for each valid category, according to the category set public characteristics Calculate the feature mean as the local category prototype for the corresponding effective category. ,Right now:
[0191] ;
[0192] In the formula, For the first Each client corresponds to a valid category The local category prototype.
[0193] For each valid category, the first module 101 calculates in parallel the number of category samples, category prediction uncertainty, intra-class feature dispersion, and prototype offset.
[0194] In this embodiment, the calculation of the category prediction uncertainty includes:
[0195] Category set through client-side local model Forward inference is performed on all samples to obtain the predicted probability distribution for each category. Based on the category predicted probability distribution, the predicted entropy of a single sample is calculated using the prediction entropy, and the category set is then selected. The mean of the prediction entropy of all samples is used as the category prediction uncertainty. ,Right now:
[0196] ;
[0197] In the formula, For the sample Predicted entropy; For any category label; Indicates a given input sample At that time, the local model predicts that it belongs to category The posterior probability.
[0198] In this embodiment, the calculation of the intra-class feature dispersion includes:
[0199] Traverse the category collection Each public feature And calculate each common feature With local category prototype Euclidean distance;
[0200] And calculate all common features With local category prototype The mean of the Euclidean distance is used as the within-class feature dispersion. .
[0201] In this embodiment, the calculation of the prototype offset includes:
[0202] Read the global category prototype issued by the server in the previous round. And calculate the local category prototype. Compared to the previous round of global category prototypes L2 distance as prototype offset .
[0203] In some embodiments, the category statistics include at least the number of category samples, category prediction uncertainty, intra-class feature dispersion, and prototype offset.
[0204] In this embodiment, the fifth module 201 determines the category-level reliability weight of the client corresponding to the valid category based on the category statistics of each valid category, including:
[0205] The fifth module 201 acquires the client. In the Wheel corresponding to valid category Valid identifier of local category prototype And the number of samples in each category, to classify clients that meet the criteria into valid categories. The set of valid clients in this round is as follows:
[0206] ;
[0207] In the formula, For the first Wheel valid categories A set of valid upload clients; The minimum effective sample threshold; For the first The client in the first Wheel corresponding to valid category The number of samples in each category.
[0208] The fifth module 201 applies to any valid client. Based on valid clients The class determination reliability score is calculated based on the number of class samples, class prediction uncertainty, intra-class feature dispersion, and prototype offset.
[0209] ;
[0210] In the formula, For the first The client in the first Wheel corresponding to valid category Category reliability score; The influence coefficient of sample size; This is the sample size gain term; , , Category prediction uncertainty Intra-class feature dispersion Prototype offset The penalty weight.
[0211] The fifth module 201 specifies the valid categories. The reliability scores of valid upload customers are determined by summing them, and a category-level reliability weight is calculated for each customer, i.e.:
[0212]
[0213] In the formula, For the first The client in the first Wheel corresponding to valid category Category-level reliability weights; This represents a stability constant used to avoid a denominator of zero.
[0214] In this embodiment, the sixth module 202 maintains a global category prototype based on the category-level reliability weights, including:
[0215] The sixth module 202 specifies the valid categories. For all valid clients k, calculate the weighted aggregate prototype for this round using the category-level reliability weight and the local category prototype, i.e.:
[0216] ;
[0217] In the formula, For the first Wheel corresponding to valid category The weighted aggregation prototype.
[0218] The sixth module 202 uses the global prototype update rate to fuse the previous round of global category prototypes. With this round of weighted aggregation prototype This yields the global category prototype for this round, namely:
[0219] ;
[0220] In the formula, This represents the global prototype update rate. Indicates the first Wheel valid categories The global category prototype.
[0221] In this embodiment, the seventh module 203 groups clients according to the client descriptor and maintains domain-level category prototypes within the client groups based on the category-level reliability weights, including:
[0222] The seventh module 203 performs a sliding average smoothing on the multi-round client descriptors to obtain smoothed client descriptors, and then performs standardization processing on the smoothed client descriptors to obtain standardized client descriptors.
[0223] In this embodiment, the multi-round client descriptor is smoothed by a moving average to obtain a smoothed client descriptor, represented as:
[0224] ;
[0225] In the formula, Let t be the client descriptor after smoothing in round t; The descriptor moving average decay coefficient; Let k be the client descriptor for client k in round t.
[0226] The smoothed client descriptor is then standardized to obtain a standardized client descriptor.
[0227] ;
[0228] In the formula, , These are the mean and variance of the smoothed client descriptors for all clients, respectively. It is the minimum stability constant; A standardized client descriptor.
[0229] The seventh module 203 uses the standardized client descriptors of all clients as sample inputs to perform clustering iterative calculations, obtaining the client grouping results, including:
[0230] The standardized client descriptors of all the clients are concatenated into a descriptor input matrix. ,Right now:
[0231] ;
[0232] In the formula, To ensure the effective uploading of customer numbers.
[0233] Based on the normalized client descriptor of client k, calculate the Euclidean distance between the normalized client descriptor and each cluster center, and assign client k to the cluster with the smallest Euclidean distance. , Right now:
[0234] ;
[0235] ;
[0236] In the formula, For client k and cluster class European distance, Cluster Cluster centers; Number of clusters;
[0237] Based on each cluster class Standardized client descriptors for all clients, recalculate new clusters. ,Right now:
[0238] ;
[0239] In the formula, Cluster The number of clients.
[0240] According to the new clustering The clients are regrouped until the change in cluster centers is less than a threshold, at which point training stops and all client grouping results are obtained.
[0241] In some embodiments, clients are grouped using the standardized descriptor cosine similarity of the clients, i.e.:
[0242] ;
[0243] If any two clients k and Standardized descriptor cosine similarity Greater than the similarity threshold Then the client k and the client They were grouped together.
[0244] In some embodiments, clients are grouped using graph-based community detection, including:
[0245] An undirected graph is constructed using clients as nodes and the standardized cosine similarity of the clients' descriptors as weights. Louvain and other community partitioning algorithms are run to automatically output group numbers, including:
[0246] Set nodes Currently not part of the community Calculate the node Moving into the community Modularity gain ,Right now:
[0247] ;
[0248] ;
[0249] ;
[0250] ;
[0251] ;
[0252] In the formula, It is an adjacency matrix; For nodes and The weights; The similarity threshold; For a set of nodes; For nodes The total weight; This represents the sum of the edge weights of an undirected graph. For the community Total out-degree weight of all nodes;
[0253] When modularity gain If the value is greater than 0, then the node will be... Moving into the community ;
[0254] Node-by-node traversal, attempting to move nodes into adjacent communities while preserving modularity gain. The largest and positive community division;
[0255] Compress all nodes in the same community into a super node. The edge weight between super nodes is the sum of the weights of all cross-community edges in the original community. Repeat the local movement.
[0256] Until the change in global modularity is less than the minimum threshold after two rounds of iteration. The global modularity mentioned The calculation formula is:
[0257] ;
[0258] In the formula, For the community The total internal weight.
[0259] The seventh module 203 performs intra-group normalization on the client category-level reliability weights of all valid clients within the group, resulting in normalized intra-group category-level reliability weights, namely:
[0260] ;
[0261] In the formula, For the first Normalized within-group category-level reliability weights for groups; In the first Round Group Valid Categories The corresponding set of valid clients, i.e. .
[0262] The seventh module 203 obtains the current-round aggregation center within the group by weighted summation of all client-local category prototypes in the group based on normalized intra-group category-level reliability weights, namely:
[0263] ;
[0264] In the formula, For the first The current aggregation center within the group.
[0265] The seventh module 203 is based on the group's current-round aggregation center and the domain-level prototype update rate. By integrating the historical domain prototype with the aggregation results within the current group, a domain-level category prototype is obtained, namely:
[0266] ;
[0267] In the formula, Indicates the first Wheel client group Medium category Domain-level category prototype, This represents the prototype of the corresponding domain-level category in the previous round. Indicates the domain-level prototype update rate; This represents the normalized category-level reliability weights within the group; This indicates the corresponding local category prototype.
[0268] In this implementation, the third module 103 generates normalized gating coefficients based on the client's local state, the global category prototype, and the domain-level category prototype, including:
[0269] The client in the third module 103 generates gated inputs based on local state, global category prototype, domain-level category prototype, and average category prediction uncertainty, namely:
[0270] ;
[0271] In the formula, Indicates the first The client in the first Wheel gating input, This indicates a splicing operation. Indicates the client descriptor. This represents the average distance between the local category prototype and the global category prototype. This represents the average distance between the local category prototype and the domain-level category prototype. This indicates the client's average category prediction uncertainty;
[0272] In this embodiment, the average distance between the local category prototype and the global category prototype is... Represented as:
[0273] ;
[0274] In the formula, It is an L2 norm.
[0275] In this embodiment, the average distance between the local category prototype and the domain-level category prototype is... Represented as:
[0276] ;
[0277] In this embodiment, the client's average category prediction uncertainty Represented as:
[0278] ;
[0279] The third module 103 uses the gating parameters B and bias b issued by the server to control the input. Perform a linear mapping and introduce a temperature coefficient to execute Softmax, generating normalized gating coefficients, i.e.:
[0280] ;
[0281] In the formula, Indicates the first The client in the first Round-normalized gating coefficients; Temperature coefficient;
[0282] The third module 103 will normalize the gating coefficients. Decompose into global branch gating weights Domain-level branch gating weights Local branch gating weights .
[0283] In this embodiment, the fourth module 104 fuses the classification outputs of the global branch, domain-level branch, and local branch using normalized gating coefficients, and adjusts the alignment training intensity of local features to the global category prototype and the domain-level category prototype using the global branch gating weights and domain-level branch gating weights in the normalized gating coefficients, respectively, including:
[0284] The fourth module 104 uses the common features of the samples With global category prototype Calculate category similarity and map it to obtain the global branch classification output. ;
[0285] The fourth module 104 uses the common features of the samples With domain-level category prototypes Calculate similarity to obtain the domain branch classification output. ;
[0286] The fourth module 104 uses the common features of the samples Input the client's local private category header to get the local branch category output. .
[0287] The fourth module 104 utilizes global branch gating weights Domain-level branch gating weights Local branch gating weights Merge global branch classification output Domain branch classification output Local branch classification output This results in personalized classification output; that is:
[0288] ;
[0289] In the formula, Output for personalized categories.
[0290] The fourth module 104 utilizes personalized classification output. Calculate the classification cross-entropy loss ,Right now:
[0291] ;
[0292] In the formula, To represent the number of samples in a training batch; For the sample The true label; Indicates real label The corresponding personalized classification output probability.
[0293] The fourth module 104 calculates the prototype alignment loss based on the valid identifiers of the global category prototype and the domain-level category prototype. ,Right now:
[0294] ;
[0295] In the formula, For real labels A flag indicating whether the corresponding global category prototype is valid. This indicates that the global category prototype is invalid; For real labels A marker indicating whether the corresponding domain-level category prototype is valid. This indicates that the domain-level category prototype is invalid. For real labels The corresponding global category prototype; For the first Real tags in the client group to which each client belongs The corresponding domain-level category prototype.
[0296] The fourth module 104 introduces gated regularization loss and combines it with prototype alignment loss. and classification cross-entropy loss Calculate total loss ,Right now:
[0297] ;
[0298] In the formula, , Prototype alignment loss and gated regularization loss Weighting coefficients;
[0299] In this embodiment, the gated regularization loss Represented as:
[0300] ;
[0301] In the formula, This represents the gating weight corresponding to the s-th branch; Indicates a global branch; Indicates a domain-level branch; Indicates a local branch.
[0302] Embodiments of this application also provide an electronic device, including:
[0303] At least one processor;
[0304] and a memory communicatively connected to the at least one processor;
[0305] The memory stores a computer program that can be executed by the at least one processor, and when the computer program is executed by the at least one processor, it implements the personalized federated learning method based on category reliability weighted prototyping and gating.
[0306] In a fourth embodiment of this application, a computer storage medium is provided, which stores a computer program that, when executed by a processor, implements the personalized federated learning method based on category reliability weighted prototyping and gating.
[0307] The embodiments and descriptions above are merely illustrative of the principles and preferred embodiments of the present invention. Various changes and modifications may be made to the present invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the present invention as claimed.
Claims
1. A personalized federated learning method based on category reliability weighted prototyping and gating, characterized in that, include: The client maps local samples to a public feature space and calculates local category prototypes and category statistics by category. The client uploads the local category prototype, category statistics, and client descriptor corresponding to the valid category to the server. The class-level reliability weight of the client corresponding to the valid class is determined by the class statistics of each valid class by the server; The server maintains a global category prototype based on the category-level reliability weights. The server groups clients based on the client descriptor and maintains domain-level category prototypes within each client group based on the category-level reliability weights. Normalized gating coefficients are generated using the client's local state, the global category prototype, and the domain-level category prototype. The client uses normalized gating coefficients to fuse the classification outputs of the global branch, domain-level branch, and local branch, and uses the global branch gating weights and domain-level branch gating weights in the normalized gating coefficients to adjust the alignment training intensity of local features to the global category prototype and the domain-level category prototype, respectively.
2. The method according to claim 1, characterized in that: The client maps local samples to a public feature space and calculates local category prototypes and category statistics by category, including: The local samples are divided into multiple batches, and the samples are input into the client's private local feature extractor to extract the underlying private features. The underlying private features are then projected across the client's unified space through a public feature mapping function. By performing a normalization operation, unified public features are obtained. Iterate through all local sample labels, group them by category, and construct a sample set for each category; Count the number of samples in each category set. If the number of samples is less than the minimum valid sample threshold, the corresponding category is determined to be an invalid category; if the number of samples is greater than or equal to the minimum valid sample threshold, the corresponding category is determined to be a valid category. For each valid category, the mean of features is calculated based on the common features of the category set as the local category prototype for the corresponding valid category; For each valid category, the number of category samples, category prediction uncertainty, intra-class feature dispersion, and prototype offset are calculated in parallel.
3. The method according to claim 2, characterized in that: The class-level reliability weight of the client for each valid class is determined by the class statistics of the server for each valid class, including: Get the client in the first Wheel corresponding to valid category Based on the valid identifiers of the local category prototypes and the number of category samples, clients that meet the criteria are assigned to valid categories. The set of valid clients in this round; For any valid client, based on valid clients The reliability score for class determination is calculated based on the number of class samples, class prediction uncertainty, intra-class feature dispersion, and prototype offset. The reliability scores of valid upload customers in the valid categories are summed, and the category-level reliability weight of each client is calculated.
4. The method according to claim 3, characterized in that: The server maintains a global category prototype based on the category-level reliability weights, including: For all valid clients under the valid category, calculate the weighted aggregate prototype for this round using the category-level reliability weight and the local category prototype; The global prototype is obtained by fusing the previous round's global category prototype with the current round's weighted aggregate prototype using the global prototype update rate.
5. The method according to claim 4, characterized in that: The server groups clients based on the client descriptor and maintains domain-level category prototypes within each client group based on the category-level reliability weights, including: The client descriptors are smoothed by moving average to obtain smoothed client descriptors. The smoothed client descriptors are then standardized to obtain standardized client descriptors. The standardized client descriptors of all customers are used as sample input for clustering iterative calculation to obtain the grouping results of the clients; The client category-level reliability weights of all valid clients within the group are normalized within the group to obtain normalized intra-group category-level reliability weights. Based on the weighted summation of all client-local category prototypes in the group using normalized intra-group category-level reliability weights, the intra-group aggregation center for this round is obtained. Based on the current aggregation center within the group and the domain-level prototype update rate, the historical domain prototype is combined with the current aggregation results within the group to obtain the domain-level category prototype.
6. The method according to claim 5, characterized in that: Clustering iterative calculations are performed using standardized client descriptors of all clients as sample inputs to obtain the client grouping results, including: The standardized client descriptors of all the clients are concatenated into a descriptor input matrix; Based on the standardized client descriptors, calculate the Euclidean distance between the standardized client descriptors and each cluster center, and assign the client to the cluster with the smallest Euclidean distance; Based on the standardized client descriptors of all clients in each cluster, new cluster centers are recalculated; The clients are regrouped based on the new cluster centers, and then the cluster centers of the new clusters are calculated. Training is stopped when the change in cluster centers is less than a threshold, and the grouping results of all clients are obtained.
7. The method according to claim 5, characterized in that: Normalized gating coefficients are generated using the client's local state, the global category prototype, and the domain-level category prototype, including: The client generates gated inputs based on local state, global category prototype, domain-level category prototype, and average category prediction uncertainty. The gating input is linearly mapped using the gating parameters and biases issued by the server, and a temperature coefficient is introduced to perform Softmax to generate normalized gating coefficients. The normalized gating coefficients are decomposed into global branch gating weights, domain-level branch gating weights, and local branch gating weights.
8. The method according to claim 7, characterized in that: The client utilizes normalized gating coefficients to fuse the classification outputs of the global branch, domain-level branch, and local branch. It then uses the global branch gating weights and domain-level branch gating weights within the normalized gating coefficients to adjust the alignment training intensity of local features towards the global category prototype and the domain-level category prototype, respectively. The class similarity is calculated by comparing the common features of the samples with the global class prototype, and the global branch classification output is obtained by mapping the common features of the samples. Calculate similarity with the domain-level category prototype to obtain the domain branch classification output; input the common features of the samples into the client's local private classification head to obtain the local branch classification output; By combining global branch gating weights, domain-level branch gating weights, and local branch gating weights, the global branch classification output, domain branch classification output, and local branch classification output are obtained, personalized classification output is achieved. Calculate the classification cross-entropy loss using personalized classification output; Calculate prototype alignment loss based on effective identifiers of global category prototypes and domain-level category prototypes; We introduce gated regularization loss and combine it with prototype alignment loss and classification cross-entropy loss to calculate the total loss.
9. A personalized federated learning system based on category reliability weighted prototyping and gating, comprising a server and multiple clients; characterized in that: The client is configured with a first module, a second module, a third module, and a fourth module; The server is configured with a fifth module, a sixth module, and a seventh module; wherein: The first module is used to map the client's local samples to the public feature space and calculate the local category prototype and category statistics by category; The second module is used to upload the local category prototype, category statistics and client descriptor corresponding to the valid category to the server. The fifth module is used to determine the category-level reliability weight of the corresponding valid category for the client based on the category statistics of each valid category; The sixth module is used to maintain a global category prototype based on the category-level reliability weights; The seventh module is used to group clients according to the client descriptor and maintain domain-level category prototypes within the client group based on the category-level reliability weights. The third module is used to generate normalized gating coefficients based on the client's local state, the global category prototype, and the domain-level category prototype. The fourth module is used to fuse the classification outputs of the global branch, the domain-level branch, and the local branch using normalized gating coefficients, and to adjust the alignment training intensity of the local features to the global category prototype and the domain-level category prototype using the global branch gating weight and the domain-level branch gating weight in the normalized gating coefficients, respectively.
10. An electronic device, comprising: At least one processor; and a memory communicatively connected to the at least one processor; The memory stores a computer program that can be executed by the at least one processor, wherein the computer program, when executed by the at least one processor, implements the personalized federated learning method based on category reliability weighted prototyping and gating as described in any one of claims 1-8.
