A model training method and system based on federated learning

Through collaborative training between the central server and the client, combining the class average activation vector and Weibull probability distribution, the accuracy and stability problems of the federated learning model in the data heterogeneous environment are solved, and high-accuracy global model training is achieved.

CN119378651BActive Publication Date: 2025-07-11GUANGDONG LAB OF ARTIFICIAL INTELLIGENCE & DIGITAL ECONOMY (SZ)
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411544459.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-31
Publication Date
2025-07-11
Estimated Expiration
2044-10-31

AI Technical Summary

Technical Problem

In the data heterogeneous environment, the federated learning model has low accuracy, low accuracy or inability to converge, especially in heterogeneous data scenarios. Traditional federated learning methods lead to a decrease in model accuracy and stability.

Method used

The data set is divided through the central server and sent to the client for partial gradient update training of the feature extraction layer and feature recognition layer. Combining the class average activation vector and Weibull probability distribution, a personalized model is built, and a metaclassifier is used to integrate the output results of each client to form a global model with strong generalization performance.

Benefits of technology

The accuracy and stability of the model are improved in heterogeneous data scenarios, and efficient data utilization and model training are realized in federated learning.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119378651B_ABST
    Figure CN119378651B_ABST
Patent Text Reader

Abstract

The present invention discloses a model training method and system based on federated learning. The method includes: obtaining a sub-training set of the basic client by the central server according to the total number of categories of the target data set, the number of clients, and the amount of data categories of the basic client; updating and training the basic neural network by the target client according to the distributed gradient of the target sub-training set to obtain candidate extraction layer parameters, a target feature recognition layer, a target class average activation vector, and a target class Weibull probability distribution; calculating the average of all candidate extraction layer parameters by the central server to obtain target extraction layer parameters, and constructing an initial global model by combining a preset meta-classifier and all target feature recognition layers; training the initial global model by 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 target global model. Through the technical solution of the present invention, model training in a heterogeneous data scenario can be realized, and the accuracy of the model is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of distributed machine learning, and particularly 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 emerged. Among them, high-quality training data is the premise and foundation 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 due to concerns about customer privacy, which prevents deep learning models from fully utilizing the data on each host for training. Therefore, in order to break the data silo problem and make the most of the local data between different clients to jointly train a model, the concept of Federated Learning (FL) has been proposed. By training the model locally on each client and only aggregating the updates of the model, such as gradients, to the central server, the transmission of raw data is avoided. Thus, 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 the data between different clients is Independent and Identically Distributed (IID). However, in actual application scenarios, the data distribution is often non-IID. If traditional federated learning methods are used, when the local data distributions vary greatly, the final global model may not be aggregable, reducing the accuracy and stability of the model. Therefore, how to perform model training for federated learning in a heterogeneous data scenario and improve the accuracy and stability of the model is an urgent problem to be solved currently. Summary of the Invention

[0004] The present invention provides a model training method and system based on federated learning, which can solve the problems that the federated learning model has low precision, low accuracy or cannot converge after convergence in a data heterogeneous environment.

[0005] According to one aspect of the present invention, there is provided a model training method based on federated learning, which is applied to a heterogeneous data scenario, and the method includes:

[0006] The central server determines the basic neural network, target dataset, set of basic clients, and the amount of data categories corresponding to each basic client for the current training scenario, divides and processes the target dataset based on the total number of categories in the target dataset, the number of clients in the set of basic clients, and the amount of data categories corresponding to each basic client, obtains sub-training sets corresponding to each basic client, and sends 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 based on the target sub-training set, obtains candidate extraction layer parameters, a target feature recognition layer, a target class average activation vector, and a target class Weibull probability distribution, and sends the candidate extraction layer parameters and the target feature recognition layer to the central server; where the target client is the basic client participating in the training in the current training round;

[0008] The central server performs an average calculation on all candidate extraction layer parameters to obtain target extraction layer parameters, constructs an initial global model based on the target extraction layer parameters, a preset meta-classifier, and all target feature recognition layers, 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, there is provided a model training system based on federated learning, which is applied to a heterogeneous data scenario, and the system includes:

[0011] A central server, configured to determine the basic neural network, target dataset, set of basic clients, and the amount of data categories corresponding to each basic client for the current training scenario, divide and process the target dataset based on the total number of categories in the target dataset, the number of clients in the set of basic clients, and the amount of data categories corresponding to each basic client, obtain sub-training sets corresponding to each basic client, and send each sub-training set and the basic neural network to the corresponding basic client;

[0012] A target client, configured to perform partial gradient update training on the feature extraction layer and the feature recognition layer in the basic neural network based on the target sub-training set, obtain candidate extraction layer parameters, a target feature recognition layer, a target class average activation vector, and a target class Weibull probability distribution, and send the candidate extraction layer parameters and the target feature recognition layer to the central server; where the target client is the basic client participating in the training in the current training round;

[0013] A central server, which is configured to perform an average calculation on all candidate extraction layer parameters to obtain target extraction layer parameters, and construct an initial global model based on the target extraction layer parameters, a preset meta-classifier, and all target feature recognition layers, and send the initial global model to a target client;

[0014] The target client is configured to train the initial global model based on a target sub-training set, a target class average activation vector, and a target class Weibull probability distribution to obtain a trained target global model.

[0015] The technical solution of the embodiment of the present invention determines the basic neural network, target data set, basic client set corresponding to the current training scenario, and the amount of data categories corresponding to each basic client through the central server, divides and processes the target data set 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 sub-training sets corresponding to each basic client, and sends 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 to obtain candidate extraction layer parameters, a target feature recognition layer, a target class average activation vector, and a target class Weibull probability distribution, and sends the candidate extraction layer parameters and the target feature recognition layer to the central server; the central server performs an average calculation on all candidate extraction layer parameters to obtain target extraction layer parameters, and constructs an initial global model based on the target extraction layer parameters, a preset meta-classifier, and all target feature recognition layers, 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. Since a personalized model with good recognition effect on the local data set is constructed by using the local data set of the client, and at the same time, the class average activation vector and the class Weibull probability distribution of the trained data are stored to realize the recognition of unknown data, the concept of constructing a "weak classifier" in ensemble learning is realized. Finally, in the form of designing a 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 that the accuracy is low, the accuracy is low or the convergence cannot be achieved after the federated learning model converges in a data heterogeneous environment, and can perform the model training of federated learning in a heterogeneous data scenario, improving the accuracy and stability of the model.

[0016] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present invention, nor is it used to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. Description of the Drawings

[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the accompanying drawings required for the description of the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can be obtained based on these drawings.

[0018] Figure 1 is a flowchart of a model training method based on federated learning provided in Embodiment 1 of the present invention;

[0019] Figure 2 is a flowchart of a model training method based on federated learning provided in Embodiment 2 of the present invention;

[0020] Figure 3 is a flowchart of an alternative model training method based on federated learning provided in Embodiment 2 of the present invention;

[0021] Figure 4 is a schematic diagram of the architecture of a global model provided in Embodiment 2 of the present invention;

[0022] Figure 5 is a schematic diagram of the structure of a model training system based on federated learning provided in Embodiment 3 of the present invention. Detailed implementation manners

[0023] In order to enable those skilled in the art to better understand the solutions of the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope 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 accompanying drawings are used to distinguish similar objects, and do not necessarily need to describe a specific order or sequence. It should be understood that such used data can be interchanged under appropriate circumstances so that the embodiments of the present invention described here can be implemented in an order other than those illustrated or described here. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units does not necessarily need to be limited to those clearly listed steps or units, but may include other steps or units that are not clearly listed or are inherent to these processes, methods, products, or devices.

[0025] It should be noted that in the technical solution of this application, the acquisition, storage, use, processing, etc. of data all comply with the relevant provisions of national laws and regulations.

[0026] Embodiment 1

[0027] Figure 1 FIG. is a flowchart of a model training method based on federated learning provided by Embodiment 1 of the present invention. This embodiment is applicable to the situation of model training in a heterogeneous data scenario. As Figure 1 shown, the method includes:

[0028] S110. Determine the basic neural network, target data set, basic client set corresponding to the current training scenario and the amount of data categories corresponding to each basic client through the central server. Divide and process the target data set 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 sub-training sets corresponding to each basic client, and send each sub-training set and the basic neural network to the corresponding basic client.

[0029] Among them, the server can refer to a high-performance computer that provides various services for other computers or devices in a network environment. Usually, the server has powerful computing capabilities, large-capacity storage, and stable network connections. The central server can refer to the server responsible for unified task scheduling and data distribution. Usually, there is only one central server in the process of an ensemble learning. The current training scenario can refer to the actual scenario applied in the current training process. Exemplarily, the current training scenario can be an education scenario, a medical scenario, a trading scenario, etc.

[0030] Among them, the basic neural network can refer to an untrained or pre-trained initial neural network architecture corresponding to the current training scenario. The target data set can refer to a pre-selected data set for model training. Exemplarily, the target data set can be any publicly available data set. For example, MNIST or CIFAR-10, etc. Among them, CIFAR-10 contains 10 categories of data including airplanes, cars, birds, cats, deer, dogs, frogs, horses, ships, and trucks. The basic client can refer to each client that needs to participate in the training during the model training process. The basic client set can refer to the set composed of each basic client participating in the training process of the same basic neural network. Usually, before performing the model training of the basic neural network, the number of basic clients in the basic client set can be preset, for example, 30, 50, or 100, etc.

[0031] Among them, the data category quantity can refer to the number of categories of data sample classes owned by each basic client. Usually, the data category quantity can be dynamically adjusted according to the current training requirements. Exemplarily, if the current training requirement is a scenario with a relatively high degree of heterogeneity, the data category quantity can be a relatively small value such as two or three. Generally, the higher the degree of heterogeneity, the lower the data category quantity, indicating that the number of data categories owned by each client is smaller. It should be noted that the data category quantities corresponding to each basic client are generally the same. The total category quantity can refer to the number of categories of data sample classes included in the target data set. Usually, after the target data set is selected, the total category quantity corresponding to the target data set can be determined. The partitioning process can refer to the operation of partitioning the target data set into the data samples separately owned by each basic client. The sub-training set can refer to the data sample set used by each basic client during the training process. Usually, the sub-training set is a subset of the target data set, and there is no data overlap between the sub-training sets.

[0032] S120. 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 candidate extraction layer parameters, the target feature recognition layer, the target class average activation vector, and the target class Weibull probability distribution, and sends the candidate extraction layer parameters 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 can refer to the process in which the model performs a complete forward propagation and backward propagation through the training data when training a machine learning model. The current training round can refer to the training round at the current moment. The target client can 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 a long training duration when all clients participate in the training. The target sub-training set can refer to the sub-training set corresponding to the target client. Usually, the number of data category quantities included in each target sub-training set is one. The number of target sub-training sets corresponding to each target client is the same as the data category quantity corresponding to each basic client. The feature extraction layer can refer to the network layer that extracts the image information contained in the input image. Exemplarily, the image information can be background information, shape information, color information, etc. The feature recognition layer can refer to the network layer that determines the category of the feature information of the image. The partial gradient update training can refer to the operation of separately performing gradient update on the feature extraction layer and the feature recognition layer in the same training round.

[0034] Among them, the extraction layer parameters can refer to the adjustment parameters corresponding to the feature extraction layer. Exemplarily, the extraction layer parameters can be represented by the symbol Φ. The candidate extraction layer parameters can refer to the extraction layer parameters obtained after the basic neural network completes the preliminary training. Exemplarily, the candidate extraction layer parameters can be the extraction layer parameters in the current training round when the basic neural network completes the preliminary training. The target feature recognition layer can refer to the feature recognition layer obtained after the basic neural network completes the preliminary training. The class average activation vector can refer to the average value of each activation vector under the same data category. Exemplarily, if there are 3 activation vectors (v1, v2, v3) under the same data category, the class average activation vector v corresponding to v1, v2, and v3 avg 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 class Weibull 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 class Weibull probability distribution corresponding to the target sub-training set.

[0035] S130. Perform an average calculation on all candidate extraction layer parameters through 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 all target feature recognition layers, and send the initial global model to the target client.

[0036] Among them, the average calculation can refer to the operation of calculating the average value of all candidate extraction layer parameters. The target extraction layer parameters can refer to the extraction layer parameters obtained after performing an average calculation on all candidate extraction layer parameters. The base classifier can refer to a single classifier used to classify the input data. The meta-classifier can refer to a classifier composed of multiple base classifiers, used to classify the input data and give the final classification result. The preset meta-classifier can refer to the pre-selected meta-classifier. Exemplarily, the preset meta-classifier can be a fully connected layer. Through the preset meta-classifier, each target feature recognition layer can be connected to integrate the output results of each target feature recognition layer. The initial global model can refer to the untrained global model constructed based on the target extraction layer parameters, the preset meta-classifier, and all target feature recognition layers.

[0037] S140. Train 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 the trained target global model.

[0038] Among them, the target global model can refer to the global model obtained after training based on the target sub-training set.

[0039] In an alternative 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, the following steps may further be included: sending the trained target global model to the central server by the target client; receiving, by the central server, a model acquisition request sent by the test client and determining 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 making a class determination on the current test data corresponding to the test client according to the target global model by the test client to generate a class result.

[0040] Among them, the test client may refer to a client with a classification requirement in an actual application scenario. The model acquisition request may refer to the requirement for obtaining 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 may 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 the eye examination report of a certain patient. The class result may refer to the classification result corresponding to the current test data. Exemplarily, if the current test data is the eye examination report of a certain patient, the class result may be the eye disease condition of the patient, such as, the eyes are healthy or there are diseases in the eyes; or, the class result may also be a specific disease category.

[0041] Specifically, after the training of the target global model is completed, the target global model may be sent to the central server by the target client for storage and scheduling. When the test client sends a model acquisition request to the central server, the central server determines the request scenario of the model acquisition request and determines 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 makes a class determination on the locally stored data according to the target global model to generate a class result; if the request scenario is inconsistent with the current training scenario of the target global model, no operation is performed. Thereby, the target global model can be correctly used in the corresponding application scenario, ensuring the security of the global model.

[0042] In the technical solution of the embodiment of the present invention, the central server determines the basic neural network, target data set, basic client set corresponding to the current training scenario, and the amount of data categories corresponding to each basic client. The target data set is divided and processed 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 sub-training sets corresponding to each basic client, and each sub-training set and the basic neural network are sent 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, to obtain candidate extraction layer parameters, a target feature recognition layer, a target class average activation vector, and a target class Weibull probability distribution, and the candidate extraction layer parameters and the target feature recognition layer are sent to the central server; the central server performs an average calculation on all candidate extraction layer parameters to obtain target extraction layer parameters, and constructs an initial global model based on the target extraction layer parameters, a preset meta-classifier, and all target feature recognition layers, 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. Since a personalized model with a good recognition effect on the local data set is constructed by using the local data set of the client, and at the same time, the recognition of unknown data is realized by storing the class average activation vector and the class Weibull probability distribution of the trained data, the concept of constructing a "weak classifier" in ensemble learning is realized. Finally, in the form of designing a meta-classifier, the output results of each "weak classifier" are integrated, so as to obtain a global model that can make full use of local data, has strong generalization performance and high accuracy. The problem that the federated learning model has low precision, low accuracy or cannot converge after convergence in a data heterogeneous environment is solved, and the model training of federated learning can be carried out in a heterogeneous data scenario, improving the accuracy and stability of the model.

[0043] Embodiment 2

[0044] Figure 2The flowchart of a model training method based on federated learning provided in the second embodiment of the present invention. This embodiment is refined based on the above embodiment. Specifically, 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 the sub-training sets corresponding to each basic client is refined. Specifically, it may include: determining, by the central server, the data division amount corresponding to each data category in the target data set 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, by the central server, a basic label list according to the data division amount and the total number of categories of the target data set, and generating a target label list by converting and processing the basic label list based on a preset adjustment function; where the target label list includes the basic client label numbers and the corresponding class label data; determining, by the central server, the sub-training sets corresponding to each basic client according to the target class label data in the target label list. As Figure 2 shown, the method includes:

[0045] S210. Determine, by the central server, the basic neural network, the target data set, the basic client set corresponding to the current training scenario, and the amount of data categories corresponding to each basic client.

[0046] Specifically, before model training, the central server can first determine the basic neural network corresponding to the current training scenario, the target data set for training, the basic client set participating in the training, and the amount of data categories corresponding to each basic client, providing an effective basis for subsequent work.

[0047] S220. Determine, by the central server, the data division amount corresponding to each data category in the target data set 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.

[0048] Among them, the data division amount may refer to the number of data division copies corresponding to the data sets of each data category in the target data set. Usually, the data division amounts corresponding to each data category in the same target data set are the same. The sample data corresponding to each data division amount in the data set of the same data category are different from each other.

[0049] Specifically, the formula X = P_class * N / C_class can be used to calculate the data division quantity corresponding to each data category in the target data set. Among them, P_class can represent the data category quantity 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. Thus, through the total number of categories in the target data set, the number of clients in the basic client set, and the data category quantity corresponding to each basic client, the data division quantity corresponding to each data category in the target data set can be determined, providing an effective basis for subsequent operations.

[0050] S230. The central server constructs a basic label list according to the data division quantity and the total number of categories in 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 basic client label numbers and corresponding class label data.

[0051] Among them, the basic label list can refer to the initially constructed label list. Usually, all data categories in the target data set can be included in this basic label list. Specifically, the basic label list can be defined by the formula: rand_set = list(range(C_class)) * X. Thus, a label list containing X copies of all data categories C_class can be obtained.

[0052] Among them, the preset adjustment function can refer to a preset adjustment function for randomly shuffling the list. Exemplarily, the preset adjustment function can be the reshape function. Specifically, the reshape(N, -1) function can be used to convert the basic label list rand_set into the category labels randomly assigned to the basic clients. It should be noted that in the embodiments of the present invention, the shuffle function can also be used to perform a shuffle operation on the basic label list rand_set to achieve random shuffling of the label list. The embodiments of the present invention do not make specific limitations on this.

[0053] Among them, the target label list can refer to the label list obtained after conversion and processing. Usually, the target label list can include the class label numbers of the corresponding data categories owned by each basic client. The basic client label number can refer to the array number corresponding to each basic client. The class label data can refer to the data category labels corresponding to each basic client.

[0054] Specifically, after constructing the basic label list based on the data division quantity and the total quantity of categories in the target data set, a preset adjustment function can be used to randomly shuffle the basic label list, and 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, then the array indices of the target label list are 10, and each array index of the target label list corresponds to a basic client. Thus, uniform distribution of the target data set can be achieved, ensuring data independence among basic clients and providing an effective basis for subsequent model training.

[0055] S240. The central server determines the sub-training sets corresponding to each basic client according to the target class label data in the target label list, and sends each sub-training set and the basic neural network to the corresponding basic client.

[0056] Among them, the target class label data may refer to the label data representing the data category in the target label list. Exemplarily, in the target label list rand_set, rand_set(0) may represent basic client 0, and the data in rand_set(0) can 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 indices of each basic client in the target label list. Then, the data set corresponding to the data category of the class label data is determined in the target data set using the class label data. Finally, a randomly selected piece of data in this data set is determined as the sub-training set corresponding to the basic client. Thus, the function that different basic clients have different data categories can be achieved, thereby simulating the data heterogeneous environment in federated learning.

[0058] It should be noted that in the embodiments of the present invention, after determining a randomly selected piece of data as the sub-training set corresponding to a basic client, this data does not participate in the determination process of the sub-training set of the next basic client, that is, the data between each sub-training set is independent. The embodiments of the present invention do not elaborate on this additionally.

[0059] S250. The target client performs distributed 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 an intermediate neural network and basic extraction layer parameters, and sends the basic extraction layer parameters to the central server.

[0060] Among them, the intermediate neural network may refer to the neural network obtained after preliminary training and update. The basic extraction layer parameters may refer to the extraction layer parameters obtained after the end of the first training round.

[0061] In an alternative embodiment, the step of the target client performing 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 an intermediate neural network and basic extraction layer parameters may include: The target client performs backpropagation 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 basic extraction layer parameters and an intermediate feature extraction layer; The target client performs backpropagation 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 an intermediate feature recognition layer; The target client combines and processes the intermediate feature extraction layer and the intermediate feature recognition layer to obtain an intermediate neural network.

[0062] Wherein, the training threshold may refer to a preset value for evaluating the number of training times in each training round. Generally, it can be set according to historical experience, and the embodiments of the present invention do 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 in 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 in the first training process.

[0063] Specifically, in the first training round, the target client performs backpropagation 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, to obtain basic extraction layer parameters and an intermediate feature extraction layer. At the same time, the target client performs backpropagation gradient update on the feature recognition layer in the basic neural network until the number of training times of the feature recognition layer meets the second training threshold, to obtain an intermediate feature recognition layer. Furthermore, the intermediate feature extraction layer and the intermediate feature recognition layer are combined to obtain an intermediate neural network, providing an effective basis for the model training in the next training round.

[0064] In an alternative embodiment, the step of the target client performing backpropagation gradient update on the feature extraction layer in the basic neural network according to the target sub-training set may include: The target client fixes the recognition layer parameters of the feature recognition layer in the basic neural network and performs backpropagation gradient update on the extraction layer parameters of the feature extraction layer in the basic neural network according to the target sub-training set;

[0065] The step of the target client performing backpropagation gradient update on the feature recognition layer in the basic neural network according to the target sub-training set may include: The target client fixes the extraction layer parameters of the feature extraction layer in the basic neural network and performs backpropagation gradient update on 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 , and the extraction layer parameter Φ of the feature extraction layer in the basic neural network is modified according to the target sub-training set i . The specific update method is: Φ i = F(Φ, α), completing the backpropagation gradient update of the feature extraction layer; where F(Φ, α) represents a representation function that updates the variable Φ using the gradient of the function F with respect 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 , and the recognition layer parameter Θ of the feature recognition layer in the basic neural network is modified according to the target sub-training set i , completing the backpropagation gradient update of the feature recognition layer.

[0067] S260. Receive the full amount of basic extraction layer parameters in the current training round through the central server, calculate the average of 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.

[0068] Among them, the intermediate extraction layer parameters can refer to the extraction layer parameters obtained by averaging the full amount of basic extraction layer parameters in the current training round.

[0069] Specifically, after the end of the first training round, the Φ i parameters in the model of the target client i are all uploaded to the central server. The central server calculates the average of the full amount of basic extraction layer parameters in the current training round, obtains the intermediate extraction layer parameters, and sends the intermediate extraction layer parameters 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. Through the target client, perform distributed 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 until the current training round reaches the first-round threshold, obtain the candidate extraction layer parameters 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 candidate extraction layer parameters and the target feature recognition layer to the central server.

[0071] Among them, the round threshold can refer to a numerically value preset for evaluating the training round. Generally, it can be set according to historical experience, and the embodiments of the present invention do not specifically limit this. The first-round threshold can refer to the round threshold for personalized model training of each target client. Exemplarily, the first-round threshold can be 5 times or 10 times.

[0072] Specifically, after completing the first training round, the target client in the new training round updates and trains the feature extraction layer and the feature recognition layer of the intermediate neural network in a distributed gradient manner based on 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. Furthermore, the central server receives the full set of basic extraction layer parameters in the new training round, calculates the average of the full set of 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 for each training round is completed until the current training round reaches the first-round threshold, and the candidate extraction layer parameters and the target feature recognition layer are obtained.

[0073] It should be noted that in the embodiments 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 the set composed of the 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 should be noted that in the embodiments 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 alternative embodiment, determining the target class average activation vector and the target class Weibull probability distribution corresponding to the target sub-training set by the target client based on the target activation vector set corresponding to the target feature recognition layer may include: processing the target activation vectors in the target activation vector set by the target client based on the mean value of the sample data volume of the target sub-training set 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] Among them, 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 actual 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 volume of the target sub-training set is n, and the target activation vector set is (v1, v2,..., v h ); 1 ≤ h ≤ n, then for each target activation vector under the same data category l, the target class average activation vector can be (v1 + v2 +... + v h ) / h. Furthermore, the target Euclidean distance between the target activation vector and the corresponding target class average activation vector is determined to be 1 ≤ j ≤ h. Finally, by combining the target Euclidean distances corresponding to each target activation vector in the target sub-training set, the target class Weibull probability distribution corresponding to the target sub-training set can be obtained.

[0078] In an optional implementation manner, 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 further include: determining, by the target client, the basic activation vector set corresponding to the target feature recognition layer, and verifying and processing the basic activation vector set according to the class label data corresponding to the target sub-training set to obtain the target activation vector set that meets the 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. Generally, the number of data bits included in the basic activation vector is the same as the total number of categories of the target data set, and each data bit corresponds to a 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 the set composed of the basic activation vectors corresponding to the same target feature recognition layer. Exemplarily, if there are 10 training data in the target sub-training set, the basic activation vector set includes 10 basic activation vectors. The preset verification rule may refer to the rule preset for verifying and processing 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. Then, each basic activation vector in the basic activation vector set is verified and processed 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, this basic activation vector is used as the target activation vector, and the target activation vectors under the same data category are combined to generate the target activation vector set. Thus, the accuracy of the target activation vector set is ensured, providing an effective basis for improving the accuracy of the model.

[0081] S280. Calculate the average of all candidate extraction layer parameters through the central server to obtain the target extraction layer parameters, and construct an initial global model based on the target extraction layer parameters, a preset meta-classifier, and all target feature recognition layers, and send the initial global model to the target client.

[0082] Specifically, after the model training of the first-round threshold is completed, each target client has achieved personalized model training and can train a corresponding "weak classifier" (i.e., the target feature recognition layer) according to the dataset owned by each target client itself. Thus, after the model training of the first-round threshold is completed, each target client can send the candidate extraction layer parameters to the central server, and the central server calculates the average of all candidate extraction layer parameters to obtain the target extraction layer parameters, providing an effective basis for subsequent global model training.

[0083] S290. The target client trains the initial global model based on the target sub-training set to obtain a set of candidate activation vectors corresponding to the target sub-training set.

[0084] Among them, the candidate activation vector can refer to the activation vector result output when the target client trains the initial global model based on the target sub-training set. The set of candidate activation vectors can refer to the set composed of candidate activation vectors corresponding to the same feature recognition layer.

[0085] Specifically, after the central server sends the initial global model to the target client, in the target client, first, the target sub-training set is feature-extracted through the feature extraction layer in the initial global model to obtain a feature result, and then the feature result is classified through the feature recognition layer in the initial global model. Thus, a set of candidate activation vectors corresponding to the target sub-training set is obtained.

[0086] S2100. The target client determines the candidate Euclidean distance between each candidate activation vector in the set of candidate activation vectors and the corresponding average activation vector of the target class, and compares and processes the candidate Euclidean distance based on the Weibull probability distribution of the target class to obtain a comparison result corresponding to the candidate Euclidean distance.

[0087] Among them, the candidate Euclidean distance can refer to the Euclidean distance between the candidate activation vector in the set of candidate activation vectors and the corresponding average activation vector of the target class. The comparison and processing can refer to the operation of determining the distribution of the candidate Euclidean distance according to the Weibull probability distribution of the target class. The comparison result can refer to the distribution result obtained by comparing and processing the candidate Euclidean distance according to the Weibull probability distribution of the target class. Exemplarily, it can be through the formula: Determine the comparison result corresponding to the Euclidean distance to be measured. Among them, k can represent the Weibull shape, λ can represent the Weibull scale parameter, and d can represent the training data in the local dataset D. Generally, the comparison result can be close to the edge or close to the center.

[0088] Specifically, after obtaining the set of activation vectors to be measured corresponding to the target sub-training set through the target client, the target client can calculate the Euclidean distance to be measured between each activation vector to be measured in the set of activation vectors to be measured and the corresponding average activation vector of the target class. Then, use the Weibull probability distribution of the target class to compare and process the Euclidean distance to be measured to obtain the comparison result corresponding to the Euclidean distance to be measured, providing an effective basis for subsequent operations.

[0089] S2110. Adjust and process the activation vector to be measured based on the comparison result corresponding to the Euclidean distance to be measured through the target client to obtain a candidate activation vector.

[0090] Among them, the adjustment process can refer to the operation of modifying and adjusting the output result of the feature recognition layer. Exemplarily, the adjustment process can be through the formula: v' j (d) = v j (d)(1 - w j (d)) is performed, where v j (d) can represent the activation vector to be measured; it can also be to set the activation vector to be measured to zero. The candidate activation vector can refer to the activation vector obtained after adjusting and processing the activation vector to be measured.

[0091] Specifically, if the comparison result corresponding to the Euclidean distance to be measured is close to the edge, it indicates that the activation vector to be measured corresponding to the Euclidean distance to be measured may be an unknown class. Therefore, by adjusting and processing the activation vector to be measured, the feature recognition layer of the target client i can only make prediction results for the data it has seen, improving the accuracy of the model.

[0092] S2120. Perform backpropagation gradient update on each candidate feature recognition layer in the initial global model through the target client based on the preset meta-classifier in the initial global model and the candidate activation vector until the current training round reaches the second-round threshold to obtain the trained target global model.

[0093] Among them, the candidate feature recognition layer can refer to the feature recognition layer included in the initial global model. The second-round threshold can refer to the round threshold when the global model training is completed. Exemplarily, if the first-round threshold is t and the global model requires T times of training during training, the second-round threshold can be (t + T).

[0094] Specifically, after adjusting and processing the activation vector to be measured based on the comparison result corresponding to the target Euclidean distance to obtain a candidate activation vector, the learning weights of each "weak classifier" (i.e., the feature recognition layer to be selected) can be obtained in the form of gradient update through the preset meta-classifier in the initial global model, the discrimination result of each "weak classifier" for the corresponding data category can be learned, and the weights of the output results of each "weak classifier" can be adjusted until the current training round reaches the second-round threshold, completing the training of the initial global model.

[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 the local dataset is constructed by using the local dataset of the client, 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 constructing a "weak classifier" in ensemble learning is realized. Finally, by designing the form of a 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. The problem that the accuracy and accuracy of the federated learning model are low or cannot converge after convergence in a data heterogeneous environment is solved, and the model training of federated learning can be carried out in a heterogeneous data scenario, improving the accuracy and stability of the model.

[0096] Figure 3 The figure shows a flowchart of an optional model training method based on federated learning provided by an embodiment of the present invention. Exemplarily, it is assumed that a total of 5 basic clients participate in federated learning and use the CIFAR-10 dataset for training, and each basic client has 2 types of data samples. The CIFAR-10 dataset can be classified according to class names, and 10 classes are randomly combined in pairs, such as {[airplane, car], [bird, cat], [deer, dog], [frog, horse], [ship, truck]}. It is assigned to each participating basic client as the dataset locally stored by each basic client. Assume that client 1 has the training data of the two classes {airplane, car}. Let the local model training round (i.e., the first-round threshold) be t, where each round includes t Φ times (i.e., the first training threshold) of feature extraction layer training and t Θ times (i.e., the second training threshold) of feature recognition layer training; the global model training round is T, that is, the second-round threshold is (t + T).

[0097] First, each participating client trains a personalized neural network according to the locally stored dataset. Exemplarily, 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: a feature extraction layer and a feature recognition layer. Furthermore, the parameters of the feature recognition layer are frozen, and the locally stored dataset is used to update the parameters of the feature extraction layer in t Φ by means of stochastic gradient descent; subsequently, the parameters of the feature extraction layer are frozen, and the local dataset is used in 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. Other clients participating in the training perform the same steps as Client 1. The central server sums up 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 the 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 stage.

[0098] After that, each client calculates the class-average activation vector and the 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 vectors 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 integrates all the feature recognition layers using a meta-classifier 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 an 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. Among them, one part is to perform backpropagation gradient update on the feature extraction layer in the basic neural network according to the local dataset to provide shared parameters for the global model; the other part is to perform backpropagation gradient update on the feature recognition layer in the basic neural network according to the local dataset to provide exclusive parameters for the local model. Until the first round threshold is completed, an activation vector, the parameter of the feature extraction layer of the last round, and the trained feature recognition layer are output. At the same time, in the feature extraction layer, the class average activation vector and the class Weibull probability distribution corresponding to the local dataset are determined by using the set of correctly classified activation vectors. Further, the central server calculates the average of 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 distributes the global model to each client participating in the training, so that each client can perform gradient update training on the global model using local data. Exemplarily, if t < the 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 layers integrated in the global model will respectively output activation vectors {v1(d), v2(d),..., v n (d)}, and calculate the Euclidean distances ||R n || between {v1(d), v2(d),..., v 飞机avg} and the class average activation vector v 飞机 of the saved aircraft category, as well as the Euclidean distance ||R 汽车avg || between {v1(d), v2(d),..., v 汽车} and the class average activation vector v 飞机 of the car category. And, respectively bring ||R 汽车 || and ||R n (d)} into the class Weibull probability distribution of {aircraft, car}, and compare the correct {v1(d), v2(d),..., v n (d)} based on the class Weibull probability distribution to obtain new activation vectors {v'1(d), v'2(d),..., v' n(d)} Adjust the corresponding weight matrix in the form of reverse gradient update, update the parameters of the corresponding weight matrix, 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 FIG. is a schematic structural diagram of a model training system based on federated learning provided in Embodiment 3 of the present invention. This system is applied to heterogeneous data scenarios, such as Figure 5 As shown, the system includes: a central server 310 and target clients 320;

[0103] Among them, the central server 310 is used to determine the basic neural network, target data set, basic client set corresponding to the current training scenario, and the amount of data categories corresponding to each basic client, divide and process the target data set 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, obtain sub-training sets 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 candidate extraction layer parameters, a target feature recognition layer, a target class average activation vector, and a target class Weibull probability distribution, and send the candidate extraction layer parameters and the target feature recognition layer to the central server 310; among them, the target client is the basic client participating in the training in the current training round;

[0105] The central server 310 is used to perform an average calculation on the full amount of candidate extraction layer parameters to obtain target extraction layer parameters, construct an initial global model based on the target extraction layer parameters, a preset meta-classifier, and the full amount of target feature recognition layers, and 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 determines the basic neural network, target data set, basic client set corresponding to the current training scenario, and the amount of data categories corresponding to each basic client through the central server. The target data set is divided 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 sub-training sets corresponding to each basic client, and each sub-training set and the basic neural network are sent 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 to obtain candidate extraction layer parameters, a target feature recognition layer, a target class average activation vector, and a target class Weibull probability distribution, and sends the candidate extraction layer parameters and the target feature recognition layer to the central server; the central server calculates the average of all candidate extraction layer parameters to obtain target extraction layer parameters, constructs an initial global model based on the target extraction layer parameters, a preset meta-classifier, and all target feature recognition layers, 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. Since a personalized model with good recognition effect on the local data set is constructed by using the local data set of the client, and at the same time, the class average activation vector and the class Weibull probability distribution of the trained data are stored to realize the recognition of unknown data, the concept of constructing "weak classifiers" in ensemble learning is realized. Finally, in the form of designing a 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 problems that the accuracy is low, the accuracy is low or the convergence cannot be achieved after the federated learning model converges in a data heterogeneous environment, can perform model training of federated learning in a heterogeneous data scenario, and improves the accuracy and stability of the model.

[0108] Optionally, the central server 310 can be specifically used for:

[0109] Determine the data division amount corresponding to each data category in the target data set 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;

[0110] Construct a basic label list according to the data division amount and the total number 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; wherein, the target label list includes basic client label numbers and corresponding class label data;

[0111] Determine the sub-training sets corresponding to each basic client according to the target class label data in the target label list.

[0112] Optionally, the target client 320 can be specifically used to: perform distributed 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 an intermediate neural network and basic extraction layer parameters, and send the basic extraction layer parameters to the central server 310;

[0113] The central server 310 can be specifically used to: receive the full amount of basic extraction layer parameters in the current training round, calculate the average of the full amount of basic extraction layer parameters, obtain intermediate extraction layer parameters and send the intermediate extraction layer parameters to the target client 320;

[0114] The target client 320 can be specifically used to: perform distributed 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 until the current training round reaches the first round threshold, obtain candidate extraction layer parameters and a 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.

[0115] Optionally, the target client 320 can be specifically used to:

[0116] Perform backpropagation 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, obtain basic extraction layer parameters and an intermediate feature extraction layer;

[0117] Perform backpropagation 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, obtain an intermediate feature recognition layer;

[0118] Combine and process the intermediate feature extraction layer and the intermediate feature recognition layer to obtain an intermediate neural network.

[0119] Optionally, the target client 320 can be specifically used to:

[0120] Fix the recognition layer parameters of the feature recognition layer in the basic neural network, and perform backpropagation 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] Fix the extraction layer parameters of the feature extraction layer in the basic neural network, and perform backpropagation gradient update on the recognition layer parameters of the feature recognition layer in the basic neural network according to the target sub-training set.

[0122] Optionally, the target client 320 can be specifically used to:

[0123] Process the target activation vectors in the target activation vector set based on the mean of the sample data volumes 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, and combine and process 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.

[0125] Optionally, the target client 320 can also be used to: 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, 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 to obtain the target activation vector set that meets the preset verification rules.

[0126] Optionally, the target client 320 can specifically be used to:

[0127] Train the initial global model based on the target sub-training set to obtain the set of activation vectors to be measured corresponding to the target sub-training set;

[0128] Determine the Euclidean distance to be measured between each activation vector to be measured in the set of activation vectors to be measured and the corresponding target class average activation vector, and compare and process the Euclidean distance to be measured based on the target class Weibull probability distribution to obtain the comparison result corresponding to the Euclidean distance to be measured;

[0129] Adjust and process the activation vector to be measured based on the comparison result corresponding to the Euclidean distance to be measured to obtain the candidate activation vector;

[0130] Perform backpropagation gradient update on each candidate feature recognition layer in the initial global model based on the preset meta-classifier in the initial global model and the candidate activation vector until the current training round reaches the second-round threshold to obtain the 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 can also be used to: after 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 the trained target global model, send the trained target global model to the central server 310;

[0133] The central server 310 can also be used to: receive a model acquisition request sent by a test client, 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 by the embodiments of the present invention can execute the method for training a model based on federated learning provided by any embodiment of the present invention, and has corresponding functional modules and beneficial effects for executing the method.

[0136] It should be understood that various forms of the processes shown above can be used, steps can be reordered, added or deleted. 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, which is not limited herein.

[0137] The above specific embodiments do not constitute a limitation on the protection scope of the present invention. Those skilled in the art should understand that various modifications, combinations, sub - combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principle of the present invention shall be included within 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, by a central server, a basic neural network, a target data set, a set of basic clients, and the amount of data categories corresponding to each basic client for the current training scenario. Divide and process the target data set according to the total number of categories of the target data set, the number of clients in the set of basic clients, and the amount of data categories corresponding to each basic client, to obtain sub-training sets 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 by a target client according to the target sub-training set, to obtain candidate extraction layer parameters, a target feature recognition layer, a target class average activation vector, and a target class Weibull probability distribution, and send the candidate extraction layer parameters and the target feature recognition layer to the central server; wherein, the target client is a basic client participating in training in the current training round; Calculate the average of all candidate extraction layer parameters by the central server to obtain target extraction layer parameters, construct an initial global model based on the target extraction layer parameters, a preset meta-classifier, and all target feature recognition layers, and send the initial global model to the target client; Train the initial global model by 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.

2. The method according to claim 1, wherein 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 set of basic clients, and the amount of data categories corresponding to each basic client to obtain sub-training sets corresponding to each basic client, includes: Determine, by the central server, the data division amount corresponding to each data category in the target data set according to the total number of categories of the target data set, the number of clients in the set of basic clients, and the amount of data categories corresponding to each basic client; Construct 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 perform conversion processing on the basic label list based on a preset adjustment function to generate a target label list; wherein, the target label list includes basic client label numbers and corresponding class label data; Determine, by the central server, the sub-training sets corresponding to each basic client according to the target class label data in the target label list.

3. The method according to claim 1, wherein The performing partial gradient update training on the feature extraction layer and the feature recognition layer in the basic neural network by the target client according to the target sub-training set to obtain candidate extraction layer parameters, a target feature recognition layer, a target class average activation vector, and a target class Weibull probability distribution, includes: Perform partial gradient update training on the feature extraction layer and the feature recognition layer in the basic neural network by the target client according to the target sub-training set, to obtain an intermediate neural network and basic extraction layer parameters, and send the basic extraction layer parameters to the central server; Receive the full set of basic extraction layer parameters in the current training round through the central server, calculate the average of the full set of basic extraction layer parameters to obtain intermediate extraction layer parameters, and send the intermediate extraction layer parameters to the target client; Through the target client, perform distributed 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 until the current training round reaches the first round threshold, obtain the candidate extraction layer parameters 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.

4. The method according to claim 3, characterized in that, The distributed gradient update training of the feature extraction layer and the feature recognition layer in the basic neural network by the target client according to the target sub-training set to obtain the intermediate neural network and the basic extraction layer parameters includes: Through the target client, perform backpropagation 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, obtain the basic extraction layer parameters and the intermediate feature extraction layer; Through the target client, perform backpropagation 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, obtain the intermediate feature recognition layer; Through the target client, combine and process the intermediate feature extraction layer and the intermediate feature recognition layer to obtain the intermediate neural network.

5. The method according to claim 4, wherein The backpropagation gradient update of the feature extraction layer in the basic neural network by the target client according to the target sub-training set includes: Through the target client, fix the recognition layer parameters of the feature recognition layer in the basic neural network, and perform backpropagation 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 backpropagation gradient update of the feature recognition layer in the basic neural network by the target client according to the target sub-training set includes: Through the target client, fix the extraction layer parameters of the feature extraction layer in the basic neural network, and perform backpropagation gradient update on the recognition layer parameters of the feature recognition layer in the basic neural network according to the target sub-training set.

6. The method according to claim 3, wherein The determination of the target class average activation vector and the target class Weibull probability distribution corresponding to the target sub-training set by the target client based on the target activation vector set corresponding to the target feature recognition layer includes: Through the target client, process 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 to obtain the target class average activation vector; Through the target client, determine the target Euclidean distance between the target activation vector and the corresponding target class average activation vector, and combine and process 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.

7. The method according to claim 3, wherein Before determining the target class average activation vector and the target class Weibull probability distribution corresponding to the target sub-training set by the target client based on the target activation vector set corresponding to the target feature recognition layer, it also includes: Determine the set of basic activation vectors corresponding to the target feature recognition layer through the target client, and verify and process the set of basic activation vectors based on the class label data corresponding to the target sub-training set to obtain a set of target activation vectors that meet the preset verification rules.

8. The method according to claim 1, wherein The training of the initial global model by 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 includes: Train the initial global model by the target client based on the target sub-training set to obtain a set of activation vectors to be measured corresponding to the target sub-training set; Determine the Euclidean distance to be measured between each activation vector to be measured in the set of activation vectors to be measured and the corresponding target class average activation vector through the target client, and compare and process the Euclidean distance to be measured based on the target class Weibull probability distribution to obtain a comparison result corresponding to the Euclidean distance to be measured; Adjust and process the activation vectors to be measured through the target client based on the comparison result corresponding to the Euclidean distance to be measured to obtain candidate activation vectors; Update the reverse gradient of each candidate feature recognition layer in the initial global model through the target client based on the preset meta-classifier in the initial global model and the candidate activation vectors until the current training round reaches the second-round threshold to obtain a trained target global model.

9. The method according to claim 1, characterized in that After the training of the initial global model by 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, it further includes: Send the trained target global model to the central server through the target client; Receive the model acquisition request sent by the test client through the central server, and judge and process the request scenario of the model acquisition request. If the request scenario is consistent with the current training scenario, send the target global model to the test client; Generate a category result by judging the category of the current test data corresponding to the test client based on the target global model through the test client.

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: A central server, configured to determine the basic neural network, the target data set, the set of basic clients, 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 number of categories of the target data set, the number of clients in the set of basic clients, and the amount of data categories corresponding to each basic client to 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; A target client, configured to perform partial gradient update training on the feature extraction layer and the feature recognition layer in the basic neural network based on the target sub-training set to obtain candidate extraction layer parameters, a target feature recognition layer, a target class average activation vector, and a target class Weibull probability distribution, and send the candidate extraction layer parameters 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; A central server, which is used to perform an average calculation on all candidate extraction layer parameters to obtain target extraction layer parameters, and construct an initial global model based on the target extraction layer parameters, a preset meta-classifier, and all target feature recognition layers, and send the initial global model to a target client; The target client is used to train the initial global model based on a target sub-training set, a target class average activation vector, and a target class Weibull probability distribution to obtain a trained target global model.

Citation Information

Patent Citations

  • Federated learning system based on heterogeneous data

    CN113011599A

  • AU2003901196A0