Federal learning-based model training method and system
By dividing the target dataset in federal learning and conducting gradient renewal training in the branch, the problem of low accuracy of federal learning models in the data heterogeneous environment is solved, and global model training with high accuracy and stability has been achieved.
Patent Information
- Application Number
- CN202411544459.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2044-10-31
AI Technical Summary
In the data heterogeneous environment, the federated learning model has low accuracy, low accuracy or inability to converge after convergence.
Divide the target data set through the central server, generate sub -training sets of various basic clients, and perform gradient renewal training on the client. The central server is calculated average of the selected extraction layer parameters, constructing the initial global model, and further training on the client to improve the accuracy and stability of the model.
The federal learning model training is implemented in the heterogeneous data scenario, which improves the accuracy and stability of the model. It can make full use of local data and have strong generalized performance.
Smart Images

Figure CN119378651A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of distributed machine learning technology, and in particular to a model training method and system based on federated learning. Background Art
[0002] With the continuous development of machine learning technology, various high-performance deep learning models have also been born. Among them, high-quality training data is the premise and basis for ensuring the accuracy of deep learning models. However, the explosive amount of data generated by users is stored on different hosts, and the data on different hosts cannot be directly exchanged because of the privacy of customers, which makes it impossible for deep learning models to fully utilize the data on each host for training. Therefore, in order to break the problem of data silos and maximize the use of local data between different clients to jointly train models, the concept of Federated Learning (FL) is proposed. By training the model locally on each client, only the model updates, such as gradients, are aggregated to the central server, thereby avoiding the transmission of original data. As a result, not only the data privacy of each client is protected, but also the data distributed on different clients can be used to train complex models, thereby significantly improving the overall efficiency of data processing and model training.
[0003] In traditional federated learning, it is usually assumed that data between different clients is independent and identically distributed (IID). However, in actual application scenarios, data distribution is often not independent and identically distributed. If traditional federated learning methods are used, when local data distribution varies greatly, the final global model may not be able to aggregate, reducing the accuracy and stability of the model. Therefore, how to train federated learning models in heterogeneous data scenarios and improve the accuracy and stability of the model is a problem that needs to be solved urgently. Summary of the invention
[0004] The present invention provides a model training method and system based on federated learning, which can solve the problem of low precision, low accuracy or failure to converge of a federated learning model after convergence in a data heterogeneous environment.
[0005] According to one aspect of the present invention, a model training method based on federated learning is provided, the method is applied to a heterogeneous data scenario, and the method comprises:
[0006] Determine the basic neural network, target data set, basic client set and the amount of data categories corresponding to each basic client corresponding to the current training scenario through the central server, divide and process the target data set according to the total amount of categories of the target data set, the number of clients in the basic client set and the amount of data categories corresponding to each basic client, obtain a sub-training set corresponding to each basic client, and send each sub-training set and the basic neural network to the corresponding basic client;
[0007] The target client performs partial gradient update training on the feature extraction layer and the feature recognition layer in the basic neural network according to the target sub-training set, obtains the parameters of the extraction layer to be selected, the target feature recognition layer, the target class average activation vector and the target class Weibull probability distribution, and sends the parameters of the extraction layer to be selected and the target feature recognition layer to the central server; wherein the target client is the basic client participating in the training in the current training round;
[0008] The central server averages all the parameters of the candidate extraction layers to obtain the target extraction layer parameters, and constructs an initial global model based on the target extraction layer parameters, a preset meta-classifier and the full target feature recognition layer, and sends the initial global model to the target client;
[0009] The target client trains the initial global model based on the target sub-training set, the target class average activation vector and the target class Weibull probability distribution to obtain a trained target global model.
[0010] According to another aspect of the present invention, a model training system based on federated learning is provided, the system is applied to a heterogeneous data scenario, and the system includes:
[0011] The central server is used to determine the basic neural network, target data set, basic client set and the amount of data categories corresponding to each basic client corresponding to the current training scenario, divide and process the target data set according to the total amount of categories of the target data set, the number of clients in the basic client set and the amount of data categories corresponding to each basic client, obtain a sub-training set corresponding to each basic client, and send each sub-training set and the basic neural network to the corresponding basic client;
[0012] The target client is used to perform partial gradient update training on the feature extraction layer and the feature recognition layer in the basic neural network according to the target sub-training set, obtain the parameters of the extraction layer to be selected, the target feature recognition layer, the target class average activation vector and the target class Weibull probability distribution, and send the parameters of the extraction layer to be selected and the target feature recognition layer to the central server; wherein the target client is the basic client participating in the training in the current training round;
[0013] The central server is used to average all the parameters of the candidate extraction layers to obtain the target extraction layer parameters, and to construct an initial global model based on the target extraction layer parameters, a preset meta-classifier and the full target feature recognition layer, and to send the initial global model to the target client;
[0014] The target client is used to train the initial global model based on the target sub-training set, the target class average activation vector and the target class Weibull probability distribution to obtain a trained target global model.
[0015] The technical solution of the embodiment of the present invention is to determine the basic neural network, target data set, basic client set and the data category quantity corresponding to each basic client corresponding to the current training scenario through a central server, divide and process the target data set according to the total category quantity of the target data set, the number of clients in the basic client set and the data category quantity corresponding to each basic client, obtain the sub-training set corresponding to each basic client, and send each sub-training set and the basic neural network to the corresponding basic client; perform partial gradient update training on the feature extraction layer and the feature recognition layer in the basic neural network according to the target sub-training set by the target client to obtain the parameters of the extraction layer to be selected, the target feature recognition layer, the target class average activation vector and the target class Weibull probability distribution, and send the parameters of the extraction layer to be selected and the target feature recognition layer to the central server; perform average calculation on all the parameters of the extraction layer to be selected by the central server to obtain the target extraction layer parameters, and construct an initial global model based on the target extraction layer parameters, the preset meta-classifier and the full target feature recognition layer, and send the initial global model to the target client; train the initial global model based on the target sub-training set, the target class average activation vector and the target class Weibull probability distribution by the target client to obtain a trained target global model. Since a personalized model with good recognition effect on local data sets is constructed by using the client's local data set, and at the same time, the recognition of unknown data is realized by storing the class average activation vector and class Weibull probability distribution of the trained data, the concept of "weak classifier" construction in ensemble learning is realized. Finally, by designing the form of meta-classifier, the output results of each "weak classifier" are integrated to obtain a global model that can make full use of local data, has strong generalization performance and high accuracy. It solves the problem of low precision, low accuracy or inability to converge after the federated learning model converges in a data heterogeneous environment, and can perform federated learning model training in heterogeneous data scenarios, improving the accuracy and stability of the model.
[0016] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0018] Figure 1 is a flowchart of a model training method based on federated learning provided according to Embodiment 1 of the present invention;
[0019] Figure 2 is a flowchart of a model training method based on federated learning provided according to Embodiment 2 of the present invention;
[0020] Figure 3 is a flowchart of an optional model training method based on federated learning provided according to Embodiment 2 of the present invention;
[0021] Figure 4 is a schematic diagram of the architecture of a global model provided according to the second embodiment of the present invention;
[0022] Figure 5 It is a structural diagram of a model training system based on federated learning provided according to Example 3 of the present invention. DETAILED DESCRIPTION
[0023] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0024] It should be noted that the terms "first", "second", "target", "original", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0025] It is worth noting that the acquisition, storage, use, and processing of data in the technical solution of this application are in compliance with the relevant provisions of national laws and regulations.
[0026] Embodiment 1
[0027] Figure 1 This is a flow chart of a model training method based on federated learning provided in the first embodiment of the present invention. This embodiment is applicable to the case of model training in a heterogeneous data scenario. Figure 1 As shown, the method includes:
[0028] S110, determining the basic neural network, target data set, basic client set and the amount of data categories corresponding to each basic client corresponding to the current training scenario through the central server, dividing and processing the target data set according to the total amount of categories of the target data set, the number of clients in the basic client set and the amount of data categories corresponding to each basic client, obtaining a sub-training set corresponding to each basic client, and sending each sub-training set and the basic neural network to the corresponding basic client.
[0029] Among them, the server may refer to a high-performance computer that provides various services to other computers or devices in a network environment. Generally, the server has powerful computing power, large storage capacity and stable network connection. The central server may refer to a server responsible for unified task scheduling and data distribution. Generally, there is only one central server in an integrated learning process. The current training scenario may refer to the actual scenario in which the current training process is applied. For example, the current training scenario may be an education scenario, a medical scenario, a transaction scenario, etc.
[0030] Among them, the basic neural network may refer to an untrained or pre-trained initial neural network architecture corresponding to the current training scenario. The target data set may refer to a pre-selected data set for model training. Exemplarily, the target data set may be any publicly available public data set. For example, MNIST or CIFAR-10, etc. Among them, CIFAR-10 contains 10 types of data including airplanes, cars, birds, cats, deer, dogs, frogs, horses, ships and trucks. The basic client may refer to each client that needs to participate in the training during the model training process. The basic client set may refer to a set composed of each basic client participating in the same basic neural network training process. Usually, before performing model training of the basic neural network, the number of basic clients in the basic client set can be pre-set, for example, 30, 50 or 100, etc.
[0031] Among them, the amount of data categories may refer to the number of categories of data sample classes owned by each basic client. Generally, the amount of data categories can be dynamically adjusted according to the current training requirements. Exemplarily, if the current training requirement is a scenario with a high degree of heterogeneity, the amount of data categories can be two or three values with smaller data volumes. Generally, the higher the degree of heterogeneity, the lower the amount of data categories, which means that each client has fewer data categories. It is worth noting that the amount of data categories corresponding to each basic client is generally consistent. The total amount of categories may refer to the number of categories of data sample classes contained in the target data set. Generally, after selecting the target data set, the total amount of categories corresponding to the target data set can be determined. Partitioning processing may refer to the operation of dividing the target data set into data samples owned separately by each basic client. A sub-training set may refer to a data sample set used by each basic client during the training process. Generally, a sub-training set is a subset of the target data set, and there is no data overlap between each sub-training set.
[0032] S120. Perform partial gradient update training on the feature extraction layer and the feature recognition layer in the basic neural network according to the target sub-training set through the target client to obtain the parameters of the extraction layer to be selected, the target feature recognition layer, the target class average activation vector and the target class Weibull probability distribution, and send the parameters of the extraction layer to be selected and the target feature recognition layer to the central server; wherein the target client is the basic client participating in the training in the current training round.
[0033] Among them, the training round may refer to the process in which the model performs a complete forward propagation and back propagation through the training data when training the machine learning model. The current training round may refer to the training round at the current moment. The target client may refer to the basic client participating in the training in the current training round. Usually, a set number of basic clients can be set to participate in the training for each training round, thereby avoiding the problem of long training time when all clients participate in the training. The target sub-training set may refer to the sub-training set corresponding to the target client. Usually, the number of data categories contained in each target sub-training set is one. The number of target sub-training sets corresponding to each target client is consistent with the number of data categories corresponding to each basic client. The feature extraction layer may refer to a network layer that extracts image information contained in the input image. Exemplarily, the image information may be background information, shape information, color information, etc. The feature recognition layer may refer to a network layer that classifies the feature information of the image. Partial gradient update training may refer to the operation of gradient updating the feature extraction layer and the feature recognition layer separately in the same training round.
[0034] Among them, the extraction layer parameters may refer to the adjustment parameters corresponding to the feature extraction layer. Exemplarily, the extraction layer parameters can be represented by the symbol Φ. The selected extraction layer parameters may refer to the extraction layer parameters obtained after the basic neural network completes the preliminary training. Exemplarily, the selected extraction layer parameters may be the extraction layer parameters in the current training round when the basic neural network completes the preliminary training. The target feature recognition layer may refer to the feature recognition layer obtained after the basic neural network completes the preliminary training. The class average activation vector may refer to the average value of each activation vector under the same data category. Exemplarily, if there are 3 activation vectors under the same data category: (v1, v2, v3), then the class average activation vector v corresponding to v1, v2 and v3 avg It can be (v1+v2+v3) / 3. The target class average activation vector can refer to the class average activation vector corresponding to the target sub-training set. The Weibull-like probability distribution can refer to the probability distribution of each activation vector under the same data category. The target class Weibull probability distribution can refer to the Weibull-like probability distribution corresponding to the target sub-training set.
[0035] S130. The central server averages all the parameters of the extraction layers to be selected to obtain the target extraction layer parameters, and constructs an initial global model based on the target extraction layer parameters, a preset meta-classifier and the full target feature recognition layer, and sends the initial global model to the target client.
[0036] Among them, the average calculation may refer to the operation of calculating the average value of all the extraction layer parameters to be selected. The target extraction layer parameters may refer to the extraction layer parameters obtained after the average calculation of the full amount of extraction layer parameters to be selected. The base classifier may refer to a single classifier for classifying input data. The meta-classifier may refer to a classifier composed of multiple base classifiers, which is used to classify the input data and give the final classification result. The preset meta-classifier may refer to a pre-selected meta-classifier. Exemplarily, the preset meta-classifier may be a fully connected layer. The preset meta-classifier can be used to connect the various target feature recognition layers and integrate the output results of the various target feature recognition layers. The initial global model may refer to an untrained global model constructed based on the target extraction layer parameters, the preset meta-classifier and the full amount of target feature recognition layers.
[0037] S140, training the initial global model through the target client based on the target sub-training set, the target class average activation vector and the target class Weibull probability distribution to obtain a trained target global model.
[0038] The target global model may refer to a global model obtained after training based on the target sub-training set.
[0039] In an optional embodiment, after the target client trains the initial global model based on the target sub-training set, the target class average activation vector and the target class Weibull probability distribution to obtain the trained target global model, it may also include: sending the trained target global model to the central server through the target client; receiving the model acquisition request sent by the test client through the central server, and judging and processing the request scenario of the model acquisition request, if the request scenario is consistent with the current training scenario, sending the target global model to the test client; and judging the category of the current test data corresponding to the test client according to the target global model through the test client to generate a category result.
[0040] Among them, the test client may refer to a client that has classification requirements in an actual application scenario. The model acquisition request may refer to the requirement to obtain a trained global model. Exemplarily, the model acquisition request may include the name of the global model that the test client wants to obtain, or the scenario that the test client wants to apply. The request scenario may refer to the classification scenario that the test client wants to apply. Exemplarily, the corresponding request scenario can be determined according to the fields included in the model acquisition request. The current test data may refer to the data to be classified stored locally by the test client. Exemplarily, if the request scenario is ophthalmic medical treatment, the current test data may be an eye examination report of a patient. The category result may refer to the classification result corresponding to the current test data. Exemplarily, if the current test data is an eye examination report of a patient, the category result may be the patient's eye condition, such as eye health or eye disease; or, the category result may also be a specific disease category.
[0041] Specifically, after the training of the target global model is completed, the target global model can be sent to the central server for storage and scheduling through the target client. When the test client sends a model acquisition request to the central server, the request scenario of the model acquisition request is determined by the central server, and it is determined whether the request scenario is consistent with the current training scenario of the target global model. If the request scenario is consistent with the current training scenario of the target global model, the target global model is sent to the test client, so that the test client can make a category judgment on the locally stored data based on the target global model and generate a category result; if the request scenario is inconsistent with the current training scenario of the target global model, no operation is performed. In this way, the target global model can be used correctly in the corresponding application scenario, ensuring the security of the global model.
[0042] The technical solution of the embodiment of the present invention is to determine the basic neural network, target data set, basic client set and the data category quantity corresponding to each basic client corresponding to the current training scenario through a central server, divide and process the target data set according to the total category quantity of the target data set, the number of clients in the basic client set and the data category quantity corresponding to each basic client, obtain the sub-training set corresponding to each basic client, and send each sub-training set and the basic neural network to the corresponding basic client; perform partial gradient update training on the feature extraction layer and the feature recognition layer in the basic neural network according to the target sub-training set by the target client to obtain the parameters of the extraction layer to be selected, the target feature recognition layer, the target class average activation vector and the target class Weibull probability distribution, and send the parameters of the extraction layer to be selected and the target feature recognition layer to the central server; perform average calculation on all the parameters of the extraction layer to be selected by the central server to obtain the target extraction layer parameters, and construct an initial global model based on the target extraction layer parameters, the preset meta-classifier and the full target feature recognition layer, and send the initial global model to the target client; train the initial global model based on the target sub-training set, the target class average activation vector and the target class Weibull probability distribution by the target client to obtain a trained target global model. Since a personalized model with good recognition effect on local data sets is constructed by using the client's local data set, and at the same time, the recognition of unknown data is realized by storing the class average activation vector and class Weibull probability distribution of the trained data, the concept of "weak classifier" construction in ensemble learning is realized. Finally, by designing the form of meta-classifier, the output results of each "weak classifier" are integrated to obtain a global model that can make full use of local data, has strong generalization performance and high accuracy. It solves the problem of low precision, low accuracy or inability to converge after the federated learning model converges in a data heterogeneous environment, and can perform federated learning model training in heterogeneous data scenarios, improving the accuracy and stability of the model.
[0043] Embodiment 2
[0044] Figure 2A flowchart of a model training method based on federated learning is provided for the second embodiment of the present invention. This embodiment is refined based on the above embodiment. In this embodiment, the operation of dividing and processing the target data set by the central server according to the total number of categories of the target data set, the number of clients in the basic client set, and the amount of data categories corresponding to each basic client to obtain a sub-training set corresponding to each basic client is specifically refined. It may include: determining the data division amount corresponding to each data category in the target data set by the central server according to the total number of categories of the target data set, the number of clients in the basic client set, and the amount of data categories corresponding to each basic client; constructing a basic label list by the central server according to the data division amount and the total number of categories of the target data set, and converting and processing the basic label list based on a preset adjustment function to generate a target label list; wherein the target label list includes the basic client label number and the corresponding class label data; determining the sub-training set corresponding to each basic client by the central server according to the target class label data in the target label list. Figure 2 As shown, the method includes:
[0045] S210, determining, through the central server, a basic neural network, a target data set, a basic client set, and a data category quantity corresponding to each basic client corresponding to the current training scenario.
[0046] Specifically, before conducting model training, the central server can be used to determine the basic neural network corresponding to the current training scenario, the target data set used for training, the set of basic clients participating in the training, and the amount of data categories corresponding to each basic client, providing an effective basis for subsequent work.
[0047] S220, determining, by the central server, the data division amount corresponding to each data category in the target data set according to the total amount of categories of the target data set, the number of clients in the basic client set, and the amount of data categories corresponding to each basic client.
[0048] The data partition amount may refer to the number of data partitions corresponding to the data set of each data category in the target data set. Usually, the data partition amounts corresponding to each data category in the same target data set are consistent. The sample data corresponding to each data partition amount in the data set of the same data category are different.
[0049] Specifically, the formula: X = P_class*N / C_class can be used to calculate the data division amount corresponding to each data category in the target data set. Among them, P_class can represent the amount of data categories corresponding to each basic client; N can represent the number of clients in the basic client set; C_class can represent the total number of categories in the target data set. Therefore, through the total number of categories in the target data set, the number of clients in the basic client set, and the amount of data categories corresponding to each basic client, the data division amount corresponding to each data category in the target data set can be determined, providing an effective basis for subsequent operations.
[0050] S230. A basic label list is constructed by a central server according to the data division amount and the total number of categories of the target data set, and the basic label list is converted and processed based on a preset adjustment function to generate a target label list; wherein the target label list includes a basic client label number and corresponding class label data.
[0051] The basic label list may refer to the label list initially constructed. Usually, the basic label list may include all data categories in the target data set. Specifically, the basic label list may be defined by the formula: rand_set = list(range(C_class))*X, thereby obtaining a label list containing X copies of all data categories C_class.
[0052] Among them, the preset adjustment function may refer to an adjustment function of a preset random shuffle list. Exemplarily, the preset adjustment function may be a reshape function. Specifically, the reshape(N,-1) function may be used to convert the basic label list rand_set into a category label randomly assigned to the basic client. It is worth noting that in an embodiment of the present invention, the shuffle function may also be used to shuffle the basic label list rand_set to achieve random shuffling of the label list, and the embodiment of the present invention does not specifically limit this.
[0053] The target label list may refer to a label list obtained after the conversion process. Generally, the target label list may include class label numbers of corresponding data categories owned by each basic client. The basic client label number may refer to the array number corresponding to each basic client. Class label data may refer to the data category label corresponding to each basic client.
[0054] Specifically, after constructing a basic label list based on the amount of data partitioning and the total amount of categories in the target data set, the basic label list can be randomly shuffled using a preset adjustment function to convert the basic label list into a label list containing the category labels randomly assigned to each basic client. Exemplarily, if the number of basic clients in the basic client set is 10, the array number of the target label list is 10, and each array number of the target label list corresponds to one basic client. In this way, the target data set can be evenly distributed, ensuring the data independence between each basic client, and providing an effective basis for subsequent model training.
[0055] S240, determining, by the central server, a sub-training set corresponding to each basic client according to the target class label data in the target label list, and sending each sub-training set and the basic neural network to the corresponding basic client.
[0056] The target class label data may refer to label data representing the data category in the target label list. For example, in the target label list rand_set, rand_set(0) may represent basic client 0, and the data in rand_set(0) may represent the class label data corresponding to basic client 0.
[0057] Specifically, after generating the target label list, the class label data corresponding to each basic client can be determined based on the array label of each basic client in the target label list. Then, the class label data is used to determine the data set of the data category corresponding to the class label data in the target data set. Finally, a random piece of data is determined in the data set as the sub-training set corresponding to the basic client. In this way, the function of different basic clients having different data categories can be realized, thereby simulating the data heterogeneous environment in federated learning.
[0058] It is worth noting that in the embodiment of the present invention, after a random piece of data is determined as a sub-training set corresponding to a basic client, the data does not participate in the sub-training set determination process of the next basic client, that is, the data between each sub-training set is independent. The embodiment of the present invention does not provide additional details on this.
[0059] S250, performing partial gradient update training on the feature extraction layer and feature recognition layer in the basic neural network according to the target sub-training set through the target client, obtaining the intermediate neural network and basic extraction layer parameters, and sending the basic extraction layer parameters to the central server.
[0060] The intermediate neural network may refer to a neural network obtained after preliminary training and updating, and the basic extraction layer parameters may refer to the extraction layer parameters obtained after the first training round.
[0061] In an optional embodiment, the target client performs partial gradient update training on the feature extraction layer and the feature recognition layer in the basic neural network according to the target sub-training set to obtain the intermediate neural network and the basic extraction layer parameters, which may include: the target client performs reverse gradient update on the feature extraction layer in the basic neural network according to the target sub-training set until the number of training times meets the first training threshold to obtain the basic extraction layer parameters and the intermediate feature extraction layer; the target client performs reverse gradient update on the feature recognition layer in the basic neural network according to the target sub-training set until the number of training times meets the second training threshold to obtain the intermediate feature recognition layer; the target client combines and processes the intermediate feature extraction layer and the intermediate feature recognition layer to obtain the intermediate neural network.
[0062] Among them, the training threshold may refer to a pre-set value for evaluating the number of training times in each training round. Generally, it can be set according to historical experience, and the embodiment of the present invention does not specifically limit this. The first training threshold may refer to the training threshold corresponding to the feature extraction layer. The intermediate feature extraction layer may refer to the feature extraction layer obtained during the first training process. The second training threshold may refer to the training threshold corresponding to the feature recognition layer. The intermediate feature recognition layer may refer to the feature recognition layer obtained during the first training process.
[0063] Specifically, in the first training round, the target client performs reverse gradient update on the feature extraction layer in the basic neural network according to the target sub-training set and the initial parameters of the basic neural network, until the number of training times of the feature extraction layer meets the first training threshold, and the basic extraction layer parameters and the intermediate feature extraction layer are obtained. At the same time, the feature recognition layer in the basic neural network is reverse gradient updated until the number of training times of the feature recognition layer meets the second training threshold, and the intermediate feature recognition layer is obtained. Then, the intermediate feature extraction layer and the intermediate feature recognition layer are combined to obtain the intermediate neural network, which provides an effective basis for model training in the next training round.
[0064] In an optional embodiment, performing reverse gradient updating on the feature extraction layer in the basic neural network according to the target sub-training set through the target client may include: fixing recognition layer parameters of the feature recognition layer in the basic neural network through the target client, and performing reverse gradient updating on the extraction layer parameters of the feature extraction layer in the basic neural network according to the target sub-training set;
[0065] The reverse gradient updating of the feature recognition layer in the basic neural network according to the target sub-training set by the target client may include: fixing the extraction layer parameters of the feature extraction layer in the basic neural network by the target client, and reverse gradient updating the recognition layer parameters of the feature recognition layer in the basic neural network according to the target sub-training set.
[0066] Specifically, the recognition layer parameter Θ of the feature recognition layer in the basic neural network can be fixed by the target client i i , according to the target sub-training set, the extraction layer parameter Φ of the feature extraction layer in the basic neural network i Modify, the specific update method is: Φ i =F(Φ,α), completing the reverse gradient update of the feature extraction layer; where F(Φ,α) represents the representation function that updates the variable Φ using the gradient of the function F relative to Φ and the step size α. Similarly, the extraction layer parameter Φ of the feature extraction layer in the basic neural network can be fixed by the target client i i , according to the target sub-training set, the recognition layer parameters Θ of the feature recognition layer in the basic neural network i Make modifications to complete the reverse gradient update of the feature recognition layer.
[0067] S260. Receive full basic abstraction layer parameters in the current training round through the central server, average the full basic abstraction layer parameters, obtain intermediate abstraction layer parameters, and send the intermediate abstraction layer parameters to the target client.
[0068] Among them, the intermediate extraction layer parameters may refer to the extraction layer parameters obtained by averaging all the basic extraction layer parameters in the current training round.
[0069] Specifically, after the first training round, the Φ in the target client i model i All parameters are uploaded to the central server, which averages all the basic extraction layer parameters in the current training round to obtain the intermediate extraction layer parameters. The intermediate extraction layer parameters are sent to the target clients participating in the training in the current training round to update the extraction layer parameters and improve the accuracy of the model.
[0070] S270, performing partial gradient update training on the feature extraction layer and feature recognition layer of the intermediate neural network according to the intermediate extraction layer parameters and the target sub-training set through the target client until the current training round reaches the first round threshold, obtaining the candidate extraction layer parameters and the target feature recognition layer, and determining the target class average activation vector and the target class Weibull probability distribution corresponding to the target sub-training set based on the target activation vector set corresponding to the target feature recognition layer, and sending the candidate extraction layer parameters and the target feature recognition layer to the central server.
[0071] Among them, the round threshold may refer to a pre-set value for evaluating the training round. Generally, it can be set according to historical experience, and the embodiment of the present invention does not specifically limit this. The first round threshold may refer to the round threshold for each target client to perform personalized model training. Exemplarily, the first round threshold may be 5 times or 10 times.
[0072] Specifically, after completing the first training round, the target client in the new training round performs partial gradient update training on the feature extraction layer and feature recognition layer of the intermediate neural network according to the intermediate extraction layer parameters and the target sub-training set, generates a new intermediate neural network and new basic extraction layer parameters, and sends the new basic extraction layer parameters to the central server. Then, the central server receives the full basic extraction layer parameters in the new training round, calculates the average of the full basic extraction layer parameters, obtains the new intermediate extraction layer parameters, and sends the new intermediate extraction layer parameters to the target client. Taking this as an example, the model training of each training round is completed until the current training round is the first round threshold, and the extraction layer parameters to be selected and the target feature recognition layer are obtained.
[0073] It is worth noting that in an embodiment of the present invention, the target clients in each training round may be different. If the target client in the current training round does not participate in the model training of the new training round, the target client saves the intermediate extraction layer parameters until the target client participates in the model training process.
[0074] Among them, the target activation vector may refer to the activation vector output by the target feature recognition layer that meets the correct classification requirements. Exemplarily, if the activation vector output by the target feature recognition layer is (v1, v2, ..., v6), and the activation vectors that meet the correct classification requirements are v2, v4 and v6, then the target activation vectors are v2, v4 and v6. The target activation vector set may refer to a set composed of target activation vectors corresponding to the same target feature recognition layer. Exemplarily, following the above example, the target activation vector set may be (v2, v4, v6). It is worth noting that in an embodiment of the present invention, each target activation vector in the target activation vector set is an activation vector under the same data category.
[0075] In an optional embodiment, determining the target class average activation vector and the target class Weibull probability distribution corresponding to the target sub-training set based on the target activation vector set corresponding to the target feature recognition layer by the target client can include: processing the target activation vectors in the target activation vector set based on the mean of the sample data volume of the target sub-training set by the target client to obtain the target class average activation vector; determining the target Euclidean distance between the target activation vector and the corresponding target class average activation vector by the target client, and combining and processing the target Euclidean distances corresponding to each target activation vector to obtain the target class Weibull probability distribution corresponding to the target sub-training set.
[0076] The sample data volume may refer to the number of sample data in the target sub-training set. The Euclidean distance may refer to the true distance between two points in a two-dimensional space. The target Euclidean distance may refer to the Euclidean distance between the target activation vector and the corresponding target class average activation vector.
[0077] Specifically, if the sample data size of the target sub-training set is n, the target activation vector set is (v1, v2, ..., v h ), 1≤h≤n, then the target class average activation vector corresponding to each target activation vector under the same data category l It can be (v1+v2+...+v h ) / h. Then, the target Euclidean distance between the target activation vector and the corresponding target class average activation vector is determined as 1≤j≤h. Finally, the target Euclidean distances corresponding to each target activation vector under the target sub-training set are combined to obtain the target class Weibull probability distribution corresponding to the target sub-training set.
[0078] In an optional embodiment, before determining the target class average activation vector and the target class Weibull probability distribution corresponding to the target sub-training set based on the target activation vector set corresponding to the target feature recognition layer through the target client, it may also include: determining the basic activation vector set corresponding to the target feature recognition layer through the target client, and verifying and processing the basic activation vector set according to the class label data corresponding to the target sub-training set to obtain a target activation vector set that meets preset verification rules.
[0079] Among them, the basic activation vector may refer to the activation vector result directly output by the target feature recognition layer. Usually, the number of data bits contained in the basic activation vector is consistent with the total number of categories of the target data set, and each data bit corresponds to the probability label of a data category. Exemplarily, if the total number of categories of the target data set is 10, the basic activation vector may be (0,0,0,0,0,0,0,0,0,0). The basic activation vector set may refer to a set composed of basic activation vectors corresponding to the same target feature recognition layer. Exemplarily, if the target sub-training set contains 10 training data, the basic activation vector set contains 10 basic activation vectors. The preset verification rule may refer to a pre-set rule for verifying the basic activation vector. Exemplarily, the preset verification rule may be that the category label corresponding to the maximum value in the basic activation vector is consistent with the class label data corresponding to the target sub-training set.
[0080] Specifically, first, the target client determines the basic activation vector set corresponding to the target feature recognition layer, and then verifies each basic activation vector in the basic activation vector set according to the class label data corresponding to the target sub-training set. If there is a basic activation vector in the basic activation vector set that meets the preset verification rule, the basic activation vector is used as the target activation vector, and the target activation vectors under the same data category are combined to generate a target activation vector set. In this way, the accuracy of the target activation vector set is guaranteed, providing an effective basis for improving the accuracy of the model.
[0081] S280. The central server averages all the parameters of the extraction layers to be selected to obtain the target extraction layer parameters, and constructs an initial global model based on the target extraction layer parameters, a preset meta-classifier and the full target feature recognition layer, and sends the initial global model to the target client.
[0082] Specifically, after completing the model training of the first round of thresholds, each target client has achieved personalized model training, and can train a corresponding "weak classifier" (i.e., target feature recognition layer) based on the data set owned by each target client. Therefore, after completing the model training of the first round of thresholds, each target client can send the parameters of the candidate extraction layer to the central server, and the central server will average all the parameters of the candidate extraction layer to obtain the target extraction layer parameters, providing an effective basis for the subsequent training of the global model.
[0083] S290 . Training the initial global model based on the target sub-training set by the target client to obtain a set of activation vectors to be tested corresponding to the target sub-training set.
[0084] The activation vector to be tested may refer to the activation vector result output when the target client trains the initial global model based on the target sub-training set. The activation vector set to be tested may refer to a set of activation vectors to be tested corresponding to the same feature recognition layer.
[0085] Specifically, after the initial global model is sent to the target client through the central server, in the target client, first, the feature extraction layer in the initial global model is used to extract features from the target sub-training set to obtain feature results. Then, the feature results are classified through the feature recognition layer in the initial global model, thereby obtaining a set of activation vectors to be tested corresponding to the target sub-training set.
[0086] S2100. Determine, through the target client, the Euclidean distance to be measured between each activation vector to be measured in the activation vector set to be measured and the corresponding average activation vector of the target class, and compare and process the Euclidean distance to be measured based on the Weibull probability distribution of the target class to obtain a comparison result corresponding to the Euclidean distance to be measured.
[0087] Among them, the Euclidean distance to be measured may refer to the Euclidean distance between the activation vector to be measured in the activation vector set to be measured and the corresponding target class average activation vector. The comparison process may refer to the operation of determining the distribution of the Euclidean distance to be measured according to the target class Weibull probability distribution. The comparison result may refer to the distribution result obtained after the comparison process of the Euclidean distance to be measured according to the target class Weibull probability distribution. Exemplarily, it can be obtained by the formula: Determine the comparison result corresponding to the Euclidean distance to be measured. Wherein, k may represent the Weibull shape, λ may represent the Weibull scale parameter, and d may represent the training data in the local data set D. Generally, the comparison result may be close to the edge or close to the center.
[0088] Specifically, after obtaining the set of activation vectors to be tested corresponding to the target sub-training set through the target client, the target client can calculate the Euclidean distances to be tested between each activation vector to be tested in the set of activation vectors to be tested and the corresponding average activation vector of the target class. Then, the Euclidean distances to be tested are processed by comparing the Weibull probability distribution of the target class to obtain the comparison results corresponding to the Euclidean distances to be tested, thereby providing an effective basis for subsequent operations.
[0089] S2110. The target client adjusts and processes the activation vector to be tested based on a comparison result corresponding to the Euclidean distance to be tested to obtain a candidate activation vector.
[0090] The adjustment process may refer to the operation of modifying and adjusting the output result of the feature recognition layer. For example, the adjustment process may be performed by the formula: j (d) = v j (d)(1-w j (d)) is performed, where v j (d) may represent the activation vector to be tested; or may be the activation vector to be tested set to zero. The candidate activation vector may refer to the activation vector obtained after adjusting the activation vector to be tested.
[0091] Specifically, if the comparison result corresponding to the Euclidean distance to be tested is close to the edge, it indicates that the activation vector to be tested corresponding to the Euclidean distance to be tested may be an unknown category. Therefore, the activation vector to be tested can be adjusted so that the feature recognition layer of the target client i only makes prediction results for the data it has seen, thereby improving the accuracy of the model.
[0092] S2120. Perform reverse gradient update on each candidate feature recognition layer in the initial global model based on the preset meta-classifier and candidate activation vector in the initial global model through the target client until the current training round reaches the second round threshold, thereby obtaining a trained target global model.
[0093] The feature recognition layer to be selected may refer to the feature recognition layer included in the initial global model. The second round threshold may refer to the round threshold when the global model training is completed. Exemplarily, if the first round threshold is t, and the global model is required to be trained T times, then the second round threshold may be (t+T).
[0094] Specifically, after the target client adjusts and processes the activation vector to be tested based on the comparison result corresponding to the Euclidean distance to be tested to obtain the candidate activation vector, the preset meta-classifier in the initial global model can be used to obtain the learning weights of each "weak classifier" (i.e., the feature recognition layer to be selected) in the form of gradient update, learn the identification results of each "weak classifier" for the corresponding data category, and adjust the weight of the output result of each "weak classifier" until the current training round is the second round threshold, and the training of the initial global model is completed.
[0095] The technical solution of the embodiment of the present invention is to determine the basic neural network, target data set, basic client set and the amount of data categories corresponding to each basic client corresponding to the current training scenario through a central server, determine the amount of data division corresponding to each data category in the target data set according to the total amount of categories of the target data set, the number of clients in the basic client set and the amount of data categories corresponding to each basic client, build a basic label list according to the amount of data division and the total amount of categories of the target data set, and convert and process the basic label list based on a preset adjustment function to generate a target label list, determine the sub-training set corresponding to each basic client according to the target class label data in the target label list, and send each sub-training set and the basic neural network to the corresponding basic client; perform partial gradient update training on the feature extraction layer and the feature recognition layer in the basic neural network according to the target sub-training set by the target client to obtain the intermediate neural network and the basic extraction layer parameters, and send the basic extraction layer parameters to the central server; receive the full amount of basic extraction layer parameters in the current training round through the central server, average the full amount of basic extraction layer parameters, obtain the intermediate extraction layer parameters and send the intermediate extraction layer parameters to the target client; perform partial gradient update training on the feature extraction layer and the feature recognition layer of the intermediate neural network according to the intermediate extraction layer parameters and the target sub-training set by the target client Update training until the current training round is the first round threshold, obtain the parameters of the extraction layer to be selected and the target feature recognition layer, and determine the target class average activation vector and the target class Weibull probability distribution corresponding to the target sub-training set based on the target activation vector set corresponding to the target feature recognition layer, and send the parameters of the extraction layer to be selected and the target feature recognition layer to the central server; average the parameters of the extraction layer to be selected through the central server to obtain the target extraction layer parameters, and build an initial global model based on the target extraction layer parameters, the preset meta-classifier and the full target feature recognition layer, and send the initial global model to the target client; average the initial global model based on the target sub-training set through the target client The local model is trained to obtain a set of activation vectors to be tested corresponding to the target sub-training set, the Euclidean distances to be tested between each activation vector to be tested in the set of activation vectors to be tested and the corresponding average activation vector of the target class are determined, and the Euclidean distances to be tested are processed based on the Weibull probability distribution of the target class to obtain a comparison result corresponding to the Euclidean distance to be tested, the activation vector to be tested is adjusted based on the comparison result corresponding to the Euclidean distance to be tested, and a candidate activation vector is obtained, and reverse gradient update is performed on each feature recognition layer to be selected in the initial global model based on the preset meta-classifier and the candidate activation vector in the initial global model until the current training round is the second round threshold, and a trained target global model is obtained.Since a personalized model with good recognition effect on local data sets is constructed by using the client's local data set, and at the same time, the recognition of unknown data is realized by storing the class average activation vector and class Weibull probability distribution of the trained data, the concept of "weak classifier" construction in ensemble learning is realized. Finally, by designing the form of meta-classifier, the output results of each "weak classifier" are integrated to obtain a global model that can make full use of local data, has strong generalization performance and high accuracy. It solves the problem of low precision, low accuracy or inability to converge after the federated learning model converges in a data heterogeneous environment, and can perform federated learning model training in heterogeneous data scenarios, improving the accuracy and stability of the model.
[0096] Figure 3 Shown is a flowchart of an optional model training method based on federated learning provided by an embodiment of the present invention. Exemplarily, assume that there are 5 basic clients participating in federated learning, and the CIFAR-10 dataset is used for training, and each basic client has 2 types of data samples. The CIFAR-10 dataset can be classified according to the class name, and the 10 classes are randomly combined in pairs, for example, {[airplane, car], [bird, cat], [deer, dog], [frog, horse], [ship, truck]}. Assigned to each basic client participating in the training as a data set stored locally by each basic client. Assume that client 1 has training data for the two classes of {airplane, car}. Assume that the local model training round (i.e., the first round threshold) is t, where each round includes feature extraction layer training t Φ times (i.e., the first training threshold) and feature recognition layer training t Θ times (i.e., the second training threshold); the global model training round is T, that is, the second round threshold is (t+T).
[0097] First, each client participating in the training trains a personalized neural network based on the locally stored data set. For example, client 1 obtains the initial neural network structure and initialization parameters to be trained from the central server, and divides the model into two parts: the feature extraction layer and the feature recognition layer. Then, the parameters of the feature recognition layer are frozen, and the locally stored data set is used to train the neural network at t Φ In the process, the parameters of the feature extraction layer are updated by stochastic gradient descent; then, the parameters of the feature extraction layer are frozen and the local dataset is used to update the feature extraction layer parameters at t ΘAmong them, the parameters of the feature recognition layer are updated by means of stochastic gradient descent; Client 1 uploads the parameters of the trained feature extraction layer to the central server, and other clients participating in the training perform the same steps as Client 1. The central server sums and averages all the parameters of the feature recognition layer collected in the same training round, and then distributes the updated parameters of the feature recognition layer to each client participating in the training in this training round, so that each client can continue training using the updated parameters of the feature recognition layer; if the current training round < t, repeat the above steps to complete the training of the personalized neural network, that is, the training of the "weak classifier", until the current training round = t, and complete the last round of the local model training phase.
[0098] After that, each client calculates the class average activation vector and class Weibull probability distribution of the data categories it owns. Exemplarily, after each training data in Client 1 enters the model, the output results of the feature recognition layer of the model are saved in units of classes. For example, when the training data of an airplane enters the model, the correctly classified output results of the feature recognition layer are used as the activation vector and saved in the airplane activation vector set; after all the training is completed, all the activation vectors of the two classes {airplane, car} saved by Client 1 are read respectively, and the average values of the activation vectors of the two classes {airplane, car} are calculated respectively as the class average activation vector v avg and construct the class Weibull probability distribution of the activation vectors correctly classified by Client 1 for the local data {airplane, car} through the Euclidean distance ||R|| between each activation vector in the set and the corresponding class average activation vector v avg ; other clients participating in the training perform the same steps as Client 1.
[0099] Furthermore, the central server separates the trained feature recognition layers of each client and uses a meta-classifier to integrate all the feature recognition layers to form a global model. Figure 4The figure shows a schematic diagram of the architecture of a global model provided by an embodiment of the present invention. Specifically, each client participating in the training obtains the initially trained deep neural network (i.e., the basic neural network) from the central server, and divides the obtained deep neural network into two parts for parameter training, wherein one part is to perform reverse gradient update on the feature extraction layer in the basic neural network according to the local data set, and provide shared parameters for the global model; the other part is to perform reverse gradient update on the feature recognition layer in the basic neural network according to the local data set, and provide exclusive parameters for the local model. Until the first round of thresholds is completed, the activation vector, the feature extraction layer parameters of the last round, and the trained feature recognition layer are output. At the same time, the class average activation vector and class Weibull probability distribution corresponding to the local data set are determined in the feature extraction layer using the correctly classified activation vector set. Further, the central server averages all the feature extraction layer parameters of the last round to obtain the final extraction layer parameters (i.e., the target extraction layer parameters), and integrates the final extraction layer parameters, the meta-classifier, and all the trained feature recognition layers to obtain the global model.
[0100] Finally, the central server sends the global model to each client participating in the training, so that each client can use local data to perform gradient update training on the global model. For example, if t < current training round < = (t + T), then the global model training starts. Specifically, client 1 inputs the training data D into the global model, and the feature recognition layer integrated by the global model will respectively output activation vectors {v1(d), v2(d), ..., v n (d)}, and calculate {v1(d),v2(d),...,v n (d)} and the class average activation vector v of the saved aircraft class 飞机avg The Euclidean distance of ||R 飞机 ||, and the class average activation vector v for the car class 汽车avg The Euclidean distance of ||R 汽车 ||. And, respectively ||R 飞机 || and ||R 汽车 ||Substitute {airplane, car} into the Weibull-like probability distribution, and compare the correct {v1(d), v2(d), ..., v n (d)}, and obtain the new activation vector {v'1(d),v'2(d),...,v' n (d)}. Afterwards, the meta-classifier receives the new activation vectors {v'1(d),v'2(d),...,v' n(d)}, adjust the corresponding weight matrix through the form of reverse gradient update, update the corresponding weight matrix parameters, so as to realize the gradient update between the meta-classifier and the "weak classifier", until (t+T) training rounds are completed, and a trained global model is obtained.
[0101] Embodiment 3
[0102] Figure 5 The following is a schematic diagram of the structure of a model training system based on federated learning provided in the third embodiment of the present invention. The system is applied to heterogeneous data scenarios, such as Figure 5 As shown, the system includes: a central server 310 and a target client 320;
[0103] The central server 310 is used to determine the basic neural network, target data set, basic client set and the amount of data categories corresponding to each basic client corresponding to the current training scenario, divide and process the target data set according to the total amount of categories of the target data set, the number of clients in the basic client set and the amount of data categories corresponding to each basic client, obtain a sub-training set corresponding to each basic client, and send each sub-training set and the basic neural network to the corresponding basic client;
[0104] The target client 320 is used to perform partial gradient update training on the feature extraction layer and the feature recognition layer in the basic neural network according to the target sub-training set, obtain the parameters of the extraction layer to be selected, the target feature recognition layer, the target class average activation vector and the target class Weibull probability distribution, and send the parameters of the extraction layer to be selected and the target feature recognition layer to the central server 310; wherein the target client is the basic client participating in the training in the current training round;
[0105] The central server 310 is used to average all the parameters of the candidate extraction layers to obtain the target extraction layer parameters, and to construct an initial global model based on the target extraction layer parameters, a preset meta-classifier and the full target feature recognition layer, and to send the initial global model to the target client 320;
[0106] The target client 320 is used to train the initial global model based on the target sub-training set, the target class average activation vector and the target class Weibull probability distribution to obtain a trained target global model.
[0107] The technical solution of the embodiment of the present invention is to determine the basic neural network, target data set, basic client set and the data category quantity corresponding to each basic client corresponding to the current training scenario through a central server, divide and process the target data set according to the total category quantity of the target data set, the number of clients in the basic client set and the data category quantity corresponding to each basic client, obtain the sub-training set corresponding to each basic client, and send each sub-training set and the basic neural network to the corresponding basic client; perform partial gradient update training on the feature extraction layer and the feature recognition layer in the basic neural network according to the target sub-training set by the target client to obtain the parameters of the extraction layer to be selected, the target feature recognition layer, the target class average activation vector and the target class Weibull probability distribution, and send the parameters of the extraction layer to be selected and the target feature recognition layer to the central server; perform average calculation on all the parameters of the extraction layer to be selected by the central server to obtain the target extraction layer parameters, and construct an initial global model based on the target extraction layer parameters, the preset meta-classifier and the full target feature recognition layer, and send the initial global model to the target client; train the initial global model based on the target sub-training set, the target class average activation vector and the target class Weibull probability distribution by the target client to obtain a trained target global model. Since a personalized model with good recognition effect on local data sets is constructed by using the client's local data set, and at the same time, the recognition of unknown data is realized by storing the class average activation vector and class Weibull probability distribution of the trained data, the concept of "weak classifier" construction in ensemble learning is realized. Finally, by designing the form of meta-classifier, the output results of each "weak classifier" are integrated to obtain a global model that can make full use of local data, has strong generalization performance and high accuracy. It solves the problem of low precision, low accuracy or inability to converge after the federated learning model converges in a data heterogeneous environment, and can perform federated learning model training in heterogeneous data scenarios, improving the accuracy and stability of the model.
[0108] Optionally, the central server 310 may be specifically used for:
[0109] Determine the data division amount corresponding to each data category in the target data set according to the total amount of categories of the target data set, the number of clients in the basic client set, and the amount of data categories corresponding to each basic client;
[0110] Constructing a basic label list according to the data division amount and the total amount of categories of the target data set, and converting and processing the basic label list based on a preset adjustment function to generate a target label list; wherein the target label list includes the basic client label number and the corresponding class label data;
[0111] The sub-training set corresponding to each basic client is determined according to the target class label data in the target label list.
[0112] Optionally, the target client 320 may be specifically used to: perform partial gradient update training on the feature extraction layer and the feature recognition layer in the basic neural network according to the target sub-training set, obtain the intermediate neural network and the basic extraction layer parameters, and send the basic extraction layer parameters to the central server 310;
[0113] The central server 310 may be specifically configured to: receive the full basic abstraction layer parameters in the current training round, average the full basic abstraction layer parameters, obtain the intermediate abstraction layer parameters, and send the intermediate abstraction layer parameters to the target client 320;
[0114] The target client 320 can be specifically used to: perform partial gradient update training on the feature extraction layer and feature recognition layer of the intermediate neural network according to the intermediate extraction layer parameters and the target sub-training set, until the current training round is the first round threshold, to obtain the selected extraction layer parameters and the target feature recognition layer, and based on the target activation vector set corresponding to the target feature recognition layer, determine the target class average activation vector and the target class Weibull probability distribution corresponding to the target sub-training set.
[0115] Optionally, the target client 320 may be specifically used for:
[0116] Performing reverse gradient update on the feature extraction layer in the basic neural network according to the target sub-training set until the number of training times meets a first training threshold, thereby obtaining basic extraction layer parameters and an intermediate feature extraction layer;
[0117] Performing reverse gradient update on the feature recognition layer in the basic neural network according to the target sub-training set until the number of training times meets a second training threshold, thereby obtaining an intermediate feature recognition layer;
[0118] The intermediate feature extraction layer and the intermediate feature recognition layer are processed in combination to obtain an intermediate neural network.
[0119] Optionally, the target client 320 may be specifically used for:
[0120] Fixing the recognition layer parameters of the feature recognition layer in the basic neural network, and performing reverse gradient update on the extraction layer parameters of the feature extraction layer in the basic neural network according to the target sub-training set;
[0121] The extraction layer parameters of the feature extraction layer in the basic neural network are fixed, and the recognition layer parameters of the feature recognition layer in the basic neural network are reversely updated according to the target sub-training set.
[0122] Optionally, the target client 320 may be specifically used for:
[0123] The target activation vector in the target activation vector set is processed based on the mean of the sample data amount of the target sub-training set to obtain the target class average activation vector;
[0124] Determine the target Euclidean distance between the target activation vector and the corresponding target class average activation vector, combine and process the target Euclidean distances corresponding to each target activation vector, and obtain the target class Weibull probability distribution corresponding to the target sub-training set.
[0125] Optionally, the target client 320 can also be used to: determine the basic activation vector set corresponding to the target feature recognition layer, and verify and process the basic activation vector set according to the class label data corresponding to the target sub-training set before determining the target class average activation vector and the target class Weibull probability distribution corresponding to the target sub-training set through the target client based on the target activation vector set corresponding to the target feature recognition layer, to obtain a target activation vector set that meets preset verification rules.
[0126] Optionally, the target client 320 may be specifically used for:
[0127] Training the initial global model based on the target sub-training set to obtain a set of activation vectors to be tested corresponding to the target sub-training set;
[0128] Determine the Euclidean distance to be measured between each activation vector to be measured in the activation vector set to be measured and the corresponding average activation vector of the target class, and compare and process the Euclidean distance to be measured based on the Weibull probability distribution of the target class to obtain a comparison result corresponding to the Euclidean distance to be measured;
[0129] Adjusting and processing the activation vector to be tested based on the comparison result corresponding to the Euclidean distance to be tested to obtain a candidate activation vector;
[0130] Based on the preset meta-classifier and candidate activation vector in the initial global model, each candidate feature recognition layer in the initial global model is reversely updated with gradient until the current training round reaches the second round threshold, thereby obtaining a trained target global model.
[0131] Optionally, the model training system based on federated learning may further include: a test client;
[0132] The target client 320 may also be used to: after the target client trains the initial global model based on the target sub-training set, the target class average activation vector and the target class Weibull probability distribution to obtain the trained target global model, send the trained target global model to the central server 310;
[0133] The central server 310 may also be used to: receive a model acquisition request sent by a test client, and judge and process the request scenario of the model acquisition request, and if the request scenario is consistent with the current training scenario, send the target global model to the test client;
[0134] The test client is used to perform category judgment on the current test data corresponding to the test client according to the target global model and generate a category result.
[0135] The model training system based on federated learning provided in the embodiment of the present invention can execute the model training method based on federated learning provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0136] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0137] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A model training method based on federated learning, characterized in that: The method is applied to a heterogeneous data scenario, and the method includes: Determine the basic neural network, target data set, basic client set and the amount of data categories corresponding to each basic client corresponding to the current training scenario through the central server, divide and process the target data set according to the total amount of categories of the target data set, the number of clients in the basic client set and the amount of data categories corresponding to each basic client, obtain a sub-training set corresponding to each basic client, and send each sub-training set and the basic neural network to the corresponding basic client; The target client performs partial gradient update training on the feature extraction layer and the feature recognition layer in the basic neural network according to the target sub-training set, obtains the parameters of the extraction layer to be selected, the target feature recognition layer, the target class average activation vector and the target class Weibull probability distribution, and sends the parameters of the extraction layer to be selected and the target feature recognition layer to the central server; wherein the target client is the basic client participating in the training in the current training round; The central server averages all the parameters of the candidate extraction layers to obtain the target extraction layer parameters, and constructs an initial global model based on the target extraction layer parameters, a preset meta-classifier and the full target feature recognition layer, and sends the initial global model to the target client; The target client trains the initial global model based on the target sub-training set, the target class average activation vector and the target class Weibull probability distribution to obtain a trained target global model.
2. The method according to claim 1, characterized in that The target data set is divided and processed by the central server according to the total number of categories of the target data set, the number of clients in the basic client set, and the number of data categories corresponding to each basic client, to obtain a sub-training set corresponding to each basic client, including: The central server determines the data division amount corresponding to each data category in the target data set according to the total amount of categories of the target data set, the number of clients in the basic client set, and the amount of data categories corresponding to each basic client; The central server constructs a basic label list according to the data division amount and the total amount of categories of the target data set, and converts and processes the basic label list based on a preset adjustment function to generate a target label list; wherein the target label list includes the basic client label number and the corresponding class label data; The central server determines the sub-training set corresponding to each basic client according to the target class label data in the target label list.
3. The method according to claim 1, characterized in that The target client performs partial gradient update training on the feature extraction layer and the feature recognition layer in the basic neural network according to the target sub-training set to obtain the parameters of the selected extraction layer, the target feature recognition layer, the target class average activation vector and the target class Weibull probability distribution, including: The target client performs partial gradient update training on the feature extraction layer and the feature recognition layer in the basic neural network according to the target sub-training set to obtain the intermediate neural network and the basic extraction layer parameters, and sends the basic extraction layer parameters to the central server; Receiving full basic abstraction layer parameters in the current training round through a central server, averaging the full basic abstraction layer parameters, obtaining intermediate abstraction layer parameters, and sending the intermediate abstraction layer parameters to a target client; The target client performs partial gradient update training on the feature extraction layer and feature recognition layer of the intermediate neural network according to the intermediate extraction layer parameters and the target sub-training set until the current training round reaches the first round threshold, and obtains the selected extraction layer parameters and the target feature recognition layer, and determines the target class average activation vector and the target class Weibull probability distribution corresponding to the target sub-training set based on the target activation vector set corresponding to the target feature recognition layer.
4. The method according to claim 3, characterized in that The target client performs partial gradient update training on the feature extraction layer and the feature recognition layer in the basic neural network according to the target sub-training set to obtain the parameters of the intermediate neural network and the basic extraction layer, including: Performing reverse gradient update on the feature extraction layer in the basic neural network according to the target sub-training set by the target client until the number of training times meets the first training threshold, thereby obtaining the basic extraction layer parameters and the intermediate feature extraction layer; Performing reverse gradient update on the feature recognition layer in the basic neural network according to the target sub-training set by the target client until the number of training times meets the second training threshold, thereby obtaining an intermediate feature recognition layer; The intermediate feature extraction layer and the intermediate feature recognition layer are processed by the target client combination to obtain an intermediate neural network.
5. The method according to claim 4, characterized in that The step of performing reverse gradient updating on the feature extraction layer in the basic neural network according to the target sub-training set by the target client includes: Fixing the recognition layer parameters of the feature recognition layer in the basic neural network through the target client, and performing reverse gradient update on the extraction layer parameters of the feature extraction layer in the basic neural network according to the target sub-training set; The performing reverse gradient updating on the feature recognition layer in the basic neural network according to the target sub-training set by the target client includes: The extraction layer parameters of the feature extraction layer in the basic neural network are fixed by the target client, and the recognition layer parameters of the feature recognition layer in the basic neural network are reversely updated with gradient according to the target sub-training set.
6. The method according to claim 3, characterized in that: The target class average activation vector and the target class Weibull probability distribution corresponding to the target sub-training set are determined by the target client based on the target activation vector set corresponding to the target feature recognition layer, including: The target client processes the target activation vector in the target activation vector set based on the mean of the sample data amount of the target sub-training set to obtain the target class average activation vector; The target Euclidean distance between the target activation vector and the corresponding target class average activation vector is determined through the target client, and the target Euclidean distances corresponding to each target activation vector are combined to obtain the target class Weibull probability distribution corresponding to the target sub-training set.
7. The method according to claim 3, characterized in that Before determining the target class average activation vector and the target class Weibull probability distribution corresponding to the target sub-training set based on the target activation vector set corresponding to the target feature recognition layer through the target client, the method further includes: The target client determines the basic activation vector set corresponding to the target feature recognition layer, and verifies and processes the basic activation vector set according to the class label data corresponding to the target sub-training set to obtain a target activation vector set that meets the preset verification rules.
8. The method according to claim 1, characterized in that The target client trains the initial global model based on the target sub-training set, the target class average activation vector and the target class Weibull probability distribution to obtain a trained target global model, including: The target client trains the initial global model based on the target sub-training set to obtain a set of activation vectors to be tested corresponding to the target sub-training set; Determine, by the target client, the Euclidean distance to be measured between each activation vector to be measured in the activation vector set to be measured and the corresponding average activation vector of the target class, and compare and process the Euclidean distance to be measured based on the Weibull probability distribution of the target class to obtain a comparison result corresponding to the Euclidean distance to be measured; The target client adjusts and processes the activation vector to be tested based on the comparison result corresponding to the Euclidean distance to be tested to obtain a candidate activation vector; The target client performs reverse gradient update on each candidate feature recognition layer in the initial global model based on the preset meta-classifier and candidate activation vector in the initial global model until the current training round reaches the second round threshold, thereby obtaining a trained target global model.
9. The method according to claim 1, characterized in that: After the target client trains the initial global model based on the target sub-training set, the target class average activation vector and the target class Weibull probability distribution to obtain a trained target global model, the method further includes: Send the trained target global model to the central server through the target client; The central server receives the model acquisition request sent by the test client, and judges and processes the request scenario of the model acquisition request. If the request scenario is consistent with the current training scenario, the target global model is sent to the test client; The test client makes a category judgment on the current test data corresponding to the test client according to the target global model to generate a category result.
10. A model training system based on federated learning, characterized in that: The system is applied to a heterogeneous data scenario, and the system includes: The central server is used to determine the basic neural network, target data set, basic client set and the amount of data categories corresponding to each basic client corresponding to the current training scenario, divide and process the target data set according to the total amount of categories of the target data set, the number of clients in the basic client set and the amount of data categories corresponding to each basic client, obtain a sub-training set corresponding to each basic client, and send each sub-training set and the basic neural network to the corresponding basic client; The target client is used to perform partial gradient update training on the feature extraction layer and the feature recognition layer in the basic neural network according to the target sub-training set, obtain the parameters of the extraction layer to be selected, the target feature recognition layer, the target class average activation vector and the target class Weibull probability distribution, and send the parameters of the extraction layer to be selected and the target feature recognition layer to the central server; wherein the target client is the basic client participating in the training in the current training round; The central server is used to average all the parameters of the candidate extraction layers to obtain the target extraction layer parameters, and to construct an initial global model based on the target extraction layer parameters, a preset meta-classifier and the full target feature recognition layer, and to send the initial global model to the target client; The target client is used to train the initial global model based on the target sub-training set, the target class average activation vector and the target class Weibull probability distribution to obtain a trained target global model.
Citation Information
Patent Citations
Federated learning system based on heterogeneous data
CN113011599A
Big data driven power distribution network harmonic control method and system
CN118232346A
Energy-saving federation method under fault diagnosis based on cross-granularity and prompt learning
CN118333137A
Radiation source individual open set identification method based on similarity weighting
CN118365863A
AU2003901196A0