A distributed model training, business execution method, storage medium and device
By obtaining and integrating the features of local classification models in federal learning, the prototype is updated, and the model parameters are updated and the training process is adjusted to solve the poor training effect caused by data heterogeneity in federal learning, and the more efficient model training has been achieved.
Patent Information
- Application Number
- CN202411168953.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-23
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2044-08-23
AI Technical Summary
Due to data heterogeneity in federated learning, the model training effect is poor. How to improve the training effect of federated learning is an urgent problem to be solved.
By obtaining a local classification model, the characteristics of the local training data are classified, and they are sent to the central server for fusion, obtained a fusion model parameter and updated the local classification model, and then adjust the model training process through the target loss value.
By focusing on the common characteristics of local training data, the significant differences in individuals have been ignored, and the training effect of federal learning is effectively improved and the impact of data heterogeneity is reduced.
Smart Images

Figure CN118690209B_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of machine learning technology, and in particular to a distributed model training, business execution method, storage medium and device. Background Art
[0002] With the rapid development of the modern chip manufacturing industry, the computing power of computers has been greatly improved, so that larger deep neural network models can be trained. However, training a complex neural network model requires a large amount of data, and due to data privacy protection and other reasons, a lot of data is stored in various terminal devices, such as: patients' personal pathological information, users' asset information, etc. Therefore, since federated learning has the characteristics of using training data in different terminal devices to train a model, and at the same time does not transmit these training data to a central server to protect the privacy of the training data, federated learning is widely used in model training.
[0003] However, since the training data stored in each terminal device often has data heterogeneity problems (that is, the data distribution of the training data stored in different terminal devices is not the same, for example, the scoring data stored in different terminal devices for scoring a popular novel will be affected by the personal hobbies and educational backgrounds of users of different terminal devices, resulting in the scoring data stored in different terminal devices often varying greatly), the central server of federated learning sums and averages the model parameters uploaded by all terminal devices participating in the training, and retransmits the obtained new model parameters to each terminal device to train the model deployed in each terminal device, and the training effect is often poor.
[0004] Therefore, how to improve the training effect of federated learning is an urgent problem to be solved. Summary of the invention
[0005] This specification provides a distributed model training, business execution method, storage medium and device to partially solve the above-mentioned problems existing in the prior art.
[0006] This manual adopts the following technical solutions:
[0007] This specification provides a distributed model training method, including:
[0008] Obtaining a feature representation prototype corresponding to each classification result output after a preset local classification model classifies each local training data, wherein for each classification result, the feature representation prototype corresponding to the classification result is determined based on each feature representation extracted from the local training data belonging to the classification result by the local classification model, and the feature representation prototype corresponding to the classification result is used to reflect the common features of each local training data belonging to the classification result, wherein the local training data includes: at least one of training text, training image, and training audio;
[0009] Send the feature representation prototype corresponding to each classification result and the model parameters of the local classification model to the central server, so that the central server determines the overall feature representation prototype corresponding to each classification result according to the feature representation prototypes sent by each downstream device, and fuses the model parameters sent by each downstream device to obtain fused model parameters, and returns the overall feature representation prototype corresponding to each classification result and the fused model parameters;
[0010] The local classification model is updated according to the received fusion model parameters to obtain a target classification model;
[0011] For each local training data, the similarity between the feature representation of the local training data determined by the target classification model and the overall feature representation prototype corresponding to the classification result to which the local training data belongs is taken as the first similarity, and the similarity between the feature representation of the local training data and the overall feature representation prototype corresponding to other classification results except the classification result to which the local training data belongs is taken as the second similarity, so as to determine the target loss value according to the ratio between the first similarity and the second similarity, and train the target classification model according to the target loss value, wherein the target loss value is negatively correlated with the ratio.
[0012] Optionally, obtaining a feature representation prototype corresponding to each classification result output after a preset local classification model classifies each local training data specifically includes:
[0013] Obtain local training data;
[0014] Inputting each local training data into a preset local classification model to obtain a feature representation of each local training data output by the local classification model and a classification result corresponding to each local training data;
[0015] For each classification result, the feature representation of each local training data belonging to the classification result is fused to obtain the feature representation prototype corresponding to the classification result.
[0016] Optionally, the feature representation prototype corresponding to each classification result and the model parameters of the local classification model are sent to a central server, so that the central server determines the overall feature representation prototype corresponding to each classification result according to each feature representation prototype sent by each downstream device, specifically including:
[0017] Sending each feature representation prototype, various classification results obtained after the local classification model classifies each local training data, and model parameters of the local classification model to a central server, so that the central server determines the types of various classification results obtained by each downstream device and determines each target classification result;
[0018] For each target classification result, the overall feature representation prototype corresponding to the target classification result is determined according to the feature representation prototypes corresponding to the target classification result in different downstream devices.
[0019] Optionally, the feature representation prototype corresponding to each classification result and the model parameters of the local classification model are sent to the central server, so that the central server determines the overall feature representation prototype corresponding to each classification result according to the feature representation prototype sent by each downstream device, and fuses the model parameters sent by each downstream device to obtain fused model parameters, and returns the overall feature representation prototype corresponding to each classification result and the fused model parameters, which specifically includes:
[0020] Send the feature representation prototype corresponding to each classification result and the model parameters of the local classification model to the central server, so that the central server determines the overall feature representation prototype corresponding to each classification result according to the feature representation prototypes sent by each downstream device, and fuses the overall feature representation prototypes corresponding to each classification result to obtain a central prototype representation, and fuses the model parameters sent by each downstream device to obtain a fused model parameter, and returns the overall feature representation prototype corresponding to each classification result, the central prototype representation and the fused model parameters;
[0021] For each local training data, the similarity between the feature representation of the local training data determined by the target classification model and the overall feature representation prototype corresponding to the classification result to which the local training data belongs is used as the first similarity, and the similarity between the feature representation of the local training data and the overall feature representation prototype corresponding to other classification results other than the classification result to which the local training data belongs is used as the second similarity, so as to determine a target loss value according to a ratio between the first similarity and the second similarity, and train the target classification model according to the target loss value, specifically including:
[0022] For each local training data, the difference between the feature representation of the local training data determined by the target classification model and the central prototype representation is taken as the first difference, the difference between the overall feature representation prototype and the central prototype representation corresponding to the classification result to which the local training data belongs is taken as the second difference, and the difference between the overall feature representation prototype and the central prototype representation corresponding to other classification results except the classification result to which the local training data belongs is taken as the third difference, and the target loss value is determined according to the ratio of the similarity between the first difference and the second difference and the similarity between the first difference and the third difference, and the target classification model is trained according to the target loss value to obtain a trained classification model.
[0023] Optionally, training the target classification model according to the target loss value to obtain a trained classification model specifically includes:
[0024] Determine a reference loss value according to a deviation between a classification result to which the local training data belongs output by the target classification model and an actual classification result corresponding to the local training data, wherein the deviation between the classification result to which the local training data belongs output by the target classification model and the actual classification result corresponding to the local training data is positively correlated with the reference loss value;
[0025] Determine an alignment loss value according to a difference between a feature representation of each local training data output by the target classification model and a central prototype representation, wherein the difference between the feature representation of each local training data output by the target classification model and the central prototype representation is positively correlated with the alignment loss value;
[0026] The target classification model is trained according to the target loss value, the reference loss value and the alignment loss value to obtain a trained classification model.
[0027] Optionally, the model parameters include: feature extraction layer model parameters;
[0028] Sending the feature representation prototype corresponding to each classification result and the model parameters of the local classification model to the central server, so that the central server fuses the model parameters sent by each downstream device to obtain the fused model parameters, and returning the overall feature representation prototype corresponding to each classification result and the fused model parameters, specifically includes:
[0029] Sending the feature representation prototype corresponding to each classification result and the model parameters of the local classification model to the central server, so that the central server fuses the feature extraction layer model parameters sent by each downstream device to obtain the fused feature extraction layer model parameters, and returns the overall feature representation prototype corresponding to each classification result and the fused feature extraction layer model parameters;
[0030] The local classification model is updated according to the received fusion model parameters to obtain a target classification model, specifically including:
[0031] Determine the total amount of training data used by all downstream devices;
[0032] Determining a parameter weight corresponding to the local classification model according to a ratio of the number of each local training data to the total number;
[0033] According to the parameter weights, the feature extraction layer model parameters are fused with the fused feature extraction layer model parameters to obtain the feature extraction layer model parameters to be updated, and the local classification model is updated according to the feature extraction layer model parameters to be updated to obtain the target classification model.
[0034] Optionally, the model parameters include: classification layer model parameters;
[0035] Sending the feature representation prototype corresponding to each classification result and the model parameters of the local classification model to the central server, so that the central server fuses the model parameters sent by each downstream device to obtain the fused model parameters, and returning the overall feature representation prototype corresponding to each classification result and the fused model parameters, specifically includes:
[0036] Send the feature representation prototype corresponding to each classification result and the model parameters of the local classification model to the central server, so that the central server fuses the classification layer model parameters sent by each downstream device to obtain the fused classification layer model parameters, and returns the overall feature representation prototype corresponding to each classification result and the fused classification layer model parameters;
[0037] The local classification model is updated according to the received fusion model parameters to obtain a target classification model, specifically including:
[0038] Determining the number of training rounds for the local classification model;
[0039] Determining a transition weight corresponding to the local classification model according to the number of training rounds;
[0040] According to the transition weights, the classification layer model parameters are fused with the fused classification layer model parameters to obtain the classification layer model parameters to be updated, and the local classification model is updated according to the classification layer model parameters to be updated to obtain the target classification model.
[0041] This specification provides a service execution method, including:
[0042] Acquire data to be processed, wherein the data to be processed includes: at least one of text data, image data, and audio data;
[0043] The data to be processed is input into a pre-trained classification model to determine the feature representation corresponding to the data to be processed through the feature extraction layer of the classification model, and the classification result corresponding to the data to be processed is determined according to the feature representation through the classification layer of the classification model, wherein the classification model is trained by the above-mentioned distributed model training method;
[0044] The business is executed according to the classification result.
[0045] This specification provides a distributed model training device, including:
[0046] An acquisition module, used to acquire a feature representation prototype corresponding to each classification result output after a preset local classification model classifies each local training data. For each classification result, the feature representation prototype corresponding to the classification result is determined based on each feature representation extracted from the local training data belonging to the classification result by the local classification model. The feature representation prototype corresponding to the classification result is used to reflect the common features of each local training data belonging to the classification result. The local training data includes: at least one of training text, training image, and training audio.
[0047] A fusion module, used to send the feature representation prototype corresponding to each classification result and the model parameters of the local classification model to the central server, so that the central server determines the overall feature representation prototype corresponding to each classification result according to the feature representation prototype sent by each downstream device, and fuses the model parameters sent by each downstream device to obtain fused model parameters, and returns the overall feature representation prototype corresponding to each classification result and the fused model parameters;
[0048] An updating module, used for updating the local classification model according to the received fusion model parameters to obtain a target classification model;
[0049] A training module is used to, for each local training data, use the similarity between the feature representation of the local training data determined by the target classification model and the overall feature representation prototype corresponding to the classification result to which the local training data belongs as a first similarity, and use the similarity between the feature representation of the local training data and the overall feature representation prototype corresponding to other classification results except the classification result to which the local training data belongs as a second similarity, so as to determine a target loss value according to the ratio between the first similarity and the second similarity, and train the target classification model according to the target loss value, wherein the target loss value is negatively correlated with the ratio.
[0050] This specification provides a service execution device, including:
[0051] An acquisition module, used for acquiring data to be processed, wherein the data to be processed includes: at least one of text data, image data, and audio data;
[0052] A classification module, used for inputting the data to be processed into a pre-trained classification model, so as to determine the feature representation corresponding to the data to be processed through the feature extraction layer of the classification model, and to determine the classification result corresponding to the data to be processed according to the feature representation through the classification layer of the classification model, wherein the classification model is trained by the above-mentioned distributed model training method;
[0053] An execution module is used to execute business according to the classification result.
[0054] In the distributed model training method provided in the present specification, a feature representation prototype corresponding to each classification result output after a preset local classification model classifies each local training data is obtained, wherein, for each classification result, the feature representation prototype corresponding to the classification result is determined based on each feature representation extracted by the local classification model from the local training data belonging to the classification result, and the feature representation prototype corresponding to the classification result is used to reflect the common features of each local training data belonging to the classification result, and the local training data includes: at least one of training text, training image, and training audio, and the feature representation prototype corresponding to each classification result and the model parameters of the local classification model are sent to the central server, so that the central server determines the overall feature representation prototype corresponding to each classification result according to the feature representation prototypes sent by each downstream device, and sends each downstream device The model parameters sent by the preparation are fused to obtain the fused model parameters, the overall feature representation prototype and the fused model parameters corresponding to each classification result are returned, the local classification model is updated according to the received fused model parameters to obtain the target classification model, for each local training data, the similarity between the feature representation of the local training data determined by the target classification model and the overall feature representation prototype corresponding to the classification result to which the local training data belongs is taken as the first similarity, and the similarity between the feature representation of the local training data and the overall feature representation prototype corresponding to other classification results except the classification result to which the local training data belongs is taken as the second similarity, so as to determine the target loss value according to the ratio between the first similarity and the second similarity, and train the target classification model according to the target loss value, wherein the target loss value is negatively correlated with the ratio.
[0055] It can be seen from the above method that by extracting the feature representation prototype corresponding to each classification result, the model training process can focus on the common characteristics of the local training data stored in the downstream device, that is, the central position of all samples in each category in the feature space, thereby ignoring the significant differences between individuals in the local training data to avoid the influence of data heterogeneity, thereby improving the training effect of federated learning. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] The drawings described herein are used to provide a further understanding of this specification and constitute a part of this specification. The illustrative embodiments and descriptions of this specification are used to explain this specification and do not constitute an improper limitation on this specification. In the drawings:
[0057] Figure 1 A flowchart of a distributed model training method provided in this specification;
[0058] Figure 2 A flowchart of a service execution method provided in this specification;
[0059] Figure 3 A schematic diagram of a distributed model training device provided in this specification;
[0060] Figure 4 A schematic diagram of a service execution device provided in this specification;
[0061] Figure 5 A method corresponding to the Figure 1 Schematic diagram of electronic equipment. DETAILED DESCRIPTION
[0062] In order to make the purpose, technical solutions and advantages of this specification more clear, the technical solutions of this specification will be clearly and completely described below in combination with the specific embodiments of this specification and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of them. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this specification.
[0063] The technical solutions provided by the embodiments of this specification are described in detail below in conjunction with the accompanying drawings.
[0064] Figure 1 A flow chart of a distributed model training method provided in this specification includes the following steps:
[0065] S101: Obtain a feature representation prototype corresponding to each classification result output after a preset local classification model classifies each local training data. For each classification result, the feature representation prototype corresponding to the classification result is determined based on each feature representation extracted from the local training data belonging to the classification result by the local classification model. The feature representation prototype corresponding to the classification result is used to reflect the common features of each local training data belonging to the classification result. The local training data includes: at least one of training text, training image, and training audio.
[0066] In this specification, the central server of the business platform can determine the initial classification model and send the model parameters of the initial classification model to each downstream device in the distributed system. For each downstream device, after receiving the model parameters of the initial classification model, the downstream device can locally deploy a local classification model based on the received model parameters, and then obtain the feature representation prototype corresponding to each classification result output by the local classification model after classifying the local training data stored in the downstream device.
[0067] Among them, for each classification result output after the local classification model deployed in the downstream device classifies each local training data, the feature representation prototype corresponding to the classification result is determined according to the feature representations extracted by the local classification model from the local training data belonging to the classification result, and the feature representation prototype corresponding to the classification result is used to reflect the common characteristics of each local training data belonging to the classification result (the common characteristics here may refer to the characteristics that all local training data of the classification result have, which can reflect the general trend of each local training data of the classification result. For example: in the field of image classification, the common characteristics of the classification results for the cat category can be understood as "cats' ears are usually triangular", "cats' eyes are large and round, usually elliptical. The shape of the pupil changes with the intensity of light, usually shrinking into a vertical slit in strong light and expanding into a circle in weak light", etc.).
[0068] Specifically, the downstream device can obtain each local training data stored in the downstream device, and input each local training data into the local classification model to obtain the feature representation of each local training data output by the local classification model and the classification result corresponding to each local training data. Then, for each classification result, the feature representation of each local training data belonging to the classification result can be fused to obtain the feature representation prototype corresponding to the classification result.
[0069] In the above content, for each classification result, the classification result output by the local classification model deployed in the downstream device after classifying each local training data is the local training data of the classification result, that is, the local training data belonging to the classification result.
[0070] In the above content, there are multiple methods for the downstream device to fuse the feature representation of each local training data belonging to each classification result for each classification result, and obtain the feature representation prototype corresponding to the classification result.
[0071] For example, the downstream device may determine an average feature vector of the feature representation of each local training data belonging to the classification result as the feature representation prototype corresponding to the classification result.
[0072] For another example: the downstream device can use the median of the feature values of the feature representation of each local training data in the feature dimension as the feature value of the feature representation prototype corresponding to the classification result in the feature dimension for each feature dimension of the feature representation of each local training data, so as to obtain the feature representation prototype corresponding to the classification result.
[0073] From the above content, it can be seen that the downstream device can extract the feature representation prototype corresponding to each classification result so that the model training process can focus on the common characteristics of the local training data stored by the downstream device, that is, the central position of all samples in each category in the feature space, thereby ignoring the significant differences between individuals in the local training data to avoid the influence of data heterogeneity, thereby improving the training effect of federated learning.
[0074] Of course, the method by which the downstream device determines the feature representation prototype corresponding to the classification result based on the feature representations extracted from the local training data belonging to the classification result according to the local classification model can also be to input the feature representations extracted from the local training data belonging to the classification result into a preset deep learning model, so as to determine the feature representation prototype corresponding to the classification result based on the feature representations extracted from the local training data belonging to the classification result through the preset deep learning model.
[0075] It should be noted that the above-mentioned local training data may include at least one of training text, training image, and training audio.
[0076] For example, in an image classification business scenario, the local training data may be various animal images, face images, and other image data waiting to be classified, while in a text recognition business scenario, the local training data may be text data such as papers and public account articles waiting to be classified.
[0077] It is worth noting that the aforementioned downstream devices may refer to participants in federated learning, such as: user's mobile phone, user's computer, user's edge server and other terminal devices.
[0078] In the above content, the execution entity used to implement the distributed model training method can refer to any downstream device participating in federated learning. For the sake of convenience of description, the distributed model training method provided in this specification is explained below only by taking the downstream device as the execution entity as an example.
[0079] S102: Send the feature representation prototype corresponding to each classification result and the model parameters of the local classification model to the central server, so that the central server determines the overall feature representation prototype corresponding to each classification result according to the feature representation prototypes sent by each downstream device, and fuses the model parameters sent by each downstream device to obtain fused model parameters, and returns the overall feature representation prototype corresponding to each classification result and the fused model parameters.
[0080] S103: Update the local classification model according to the received fusion model parameters to obtain a target classification model.
[0081] In this specification, after the downstream device obtains the feature representation prototype corresponding to each classification result output after the preset local classification model classifies each local training data, the feature representation prototype, the various classification results obtained after the local classification model classifies each local training data, and the model parameters of the local classification model can be sent to the central server, so that the central server can determine the types of various classification results obtained by each downstream device, determine each target classification result (that is, the non-repeated classification results among the classification results sent by each downstream device, for example: if there are two downstream devices A and B, the various classification results sent by the downstream device A are 1, 2, and the various classification results sent by the downstream device B are 2, 3. At this time, the target classification results determined by the central server are 1, 2, and 3), and then for each target classification result, the overall feature representation prototype corresponding to the target classification result can be determined according to the feature representation prototypes corresponding to the target classification result in different downstream devices (that is, the central server can determine the overall feature representation prototype of target classification result 2 according to the feature representation prototype of target classification result 2 sent by downstream device A and the feature representation prototype of target classification result 2 sent by downstream device B), and the model parameters sent by each downstream device can be fused to obtain the fused model parameters, and then the overall feature representation prototype and fused model parameters corresponding to each classification result can be returned.
[0082] There are multiple methods for the central server to determine the overall feature representation prototype corresponding to the target classification result according to the feature representation prototypes corresponding to the target classification result in different downstream devices. For example, the average feature vector of the feature representation prototypes corresponding to the target classification result in different downstream devices is determined as the overall feature representation prototype.
[0083] As another example: for each feature dimension of the feature representation prototype corresponding to the target classification result in different downstream devices, the central server takes the median of the feature values of each feature representation prototype corresponding to the target classification result in different downstream devices in the feature dimension as the feature value of the overall feature representation prototype corresponding to the target classification result in the feature dimension, so as to obtain the overall feature representation prototype corresponding to the classification result.
[0084] It should be noted that the above-mentioned model parameters may include: feature extraction layer model parameters, classification layer model parameters. Based on this, the downstream device can send the feature representation prototype corresponding to each classification result, the various classification results obtained after the local classification model classifies each local training data, and the feature extraction layer model parameters and classification layer model parameters of the local classification model to the central server, so that the central server can fuse the feature extraction layer model parameters sent by each downstream device to obtain the fused feature extraction layer model parameters, and fuse the classification layer model parameters sent by each downstream device to obtain the fused classification layer model parameters, and then return the overall feature representation prototype, fused feature extraction layer model parameters and fused classification layer model parameters corresponding to each classification result.
[0085] Furthermore, after receiving the fusion feature extraction layer model parameters and the fusion classification layer model parameters returned by the central server, the downstream device can determine the total number of training data used by all downstream devices, so as to determine the parameter weight corresponding to the local classification model according to the ratio of the number of each local training data and the determined total number of training data used by all downstream devices. For details, refer to the following formula:
[0086]
[0087] In the above formula, That is, the parameter weight corresponding to the determined local classification model, is the number of local training data stored in the downstream device, where m is the identifier of the downstream device in each downstream device, that is, the downstream device is the mth downstream device in each downstream device. is the number of downstream devices, This is the total amount of training data used by all downstream devices.
[0088] Further, the downstream device may fuse the feature extraction layer model parameters with the fusion feature extraction layer model parameters according to the determined parameter weights to obtain the feature extraction layer model parameters to be updated, and update the local classification model according to the feature extraction layer model parameters to be updated to obtain the target classification model. For details, refer to the following formula:
[0089]
[0090] In the above formula, That is, the model parameters of the feature extraction layer to be updated. is the determined parameter weight, It is the model parameter of the feature extraction layer.
[0091] In addition, the downstream device can also determine the number of training rounds of the local classification model, and then determine the transition weight corresponding to the local classification model based on the determined number of training rounds of the local classification model, and then fuse the classification layer model parameters of the local classification model with the fusion classification layer model parameters based on the determined transition weight to obtain the classification layer model parameters to be updated, and update the local classification model according to the classification layer model parameters to be updated to obtain the target classification model. For details, please refer to the following formula.
[0092]
[0093] In the above formula, That is, the classification layer model parameters to be updated of the local classification model. is the transition weight, where a is a hyperparameter and can be set according to actual needs. For example, set a=0.3, and t is the number of training rounds for the local classification model. is the fusion classification layer model parameter, That is, the classification layer model parameters of the local classification model.
[0094] It can be seen from the above formula that as the number of training rounds of the local classification model gradually increases, It gradually increases from 0 to 1, so the transition weight of the classification layer model parameters of the local classification model continues to increase, and the transition weight of the fusion classification layer model parameters returned by the central server continues to decrease. This can help downstream devices improve the generalization ability of the classification layer of the local classification model while better fitting the local training data.
[0095] It should be noted that the above tanh(at) function can be replaced by any other increasing function f(t) that satisfies the conditions that f(0)=0, and f(t) converges to 1 as t increases.
[0096] S104: For each local training data, the similarity between the feature representation of the local training data determined by the target classification model and the overall feature representation prototype corresponding to the classification result to which the local training data belongs is taken as the first similarity, and the similarity between the feature representation of the local training data and the overall feature representation prototypes corresponding to other classification results except the classification result to which the local training data belongs is taken as the second similarity, so as to determine a target loss value according to the ratio between the first similarity and the second similarity, and train the target classification model according to the target loss value, wherein the target loss value is negatively correlated with the ratio.
[0097] In the present specification, after receiving the overall feature representation prototype corresponding to each classification result returned by the central server, the downstream device can, for each local training data, use the similarity between the feature representation of the local training data determined by the target classification model and the overall feature representation prototype corresponding to the classification result to which the local training data belongs as the first similarity, and use the similarity between the feature representation of the local training data and the overall feature representation prototypes corresponding to other classification results except the classification result to which the local training data belongs as the second similarity, and then determine the target loss value based on the ratio between the first similarity and the second similarity, and train the target classification model based on the target loss value, wherein the target loss value is negatively correlated with the above ratio.
[0098] Specifically, the downstream device can fuse the overall feature representation prototypes corresponding to each classification result to obtain a central prototype representation, and then, for each local training data, take the difference between the feature representation of the local training data determined by the target classification model and the central prototype representation as the first difference, take the difference between the overall feature representation prototype and the central prototype representation corresponding to the classification result to which the local training data belongs as the second difference, and take the difference between the overall feature representation prototype and the central prototype representation corresponding to other classification results except the classification result to which the local training data belongs as the third difference, determine the similarity between the first difference and the second difference and the ratio of the similarity between the first difference and the third difference, determine the target loss value, and train the target classification model according to the target loss value to obtain a trained classification model. For details, please refer to the following formula.
[0099]
[0100] In the above formula, is the number of local training data stored in the downstream device, i is The i-th local training data in, is a hyperparameter, is the similarity function, That is, the feature representation of the i-th local training data, That is the central prototype representation, That is, the overall feature representation prototype corresponding to the classification result of the i-th local training data. That is, the overall feature representation prototype corresponding to the k-th classification result, and K is the total number of each classification result returned by the central server. That is, it is the difference between the feature representation of the i-th local training data and the central prototype representation.
[0101] It should be noted that there can be two types of each classification result returned by the above-mentioned central server. The first type is each classification result output by the local classification model of the downstream device after classifying each local training data. In other words, after the central server determines the overall feature representation prototype of each target classification result, it can only send the overall feature representation prototype corresponding to each classification result output by the local classification model of the downstream device after classifying each local training data to the downstream device. The second type is the various classification results obtained by all downstream devices, that is, after the central server determines the overall feature representation prototype of each target classification result, it can send the overall feature representation prototype of all target classification results to the downstream device.
[0102] Among them, if each classification result returned by the central server is the first type mentioned above, the downstream device can train the local classification model only based on the overall feature representation prototype of each classification result involved in it, so that the local classification model can be more focused on the distribution of each local training data owned by the downstream device.
[0103] If each classification result returned by the central server is the second type mentioned above, the downstream device can further combine the data distribution information of the training data owned by other downstream devices to train the local classification model to enhance the generalization ability and robustness of the local classification model.
[0104] It is worth noting that there are multiple ways for the above-mentioned downstream device to fuse the overall feature representation prototypes corresponding to each classification result to obtain the central prototype representation.
[0105] For example: determine the average feature vector of the overall feature representation prototype corresponding to each classification result as the central prototype representation.
[0106] For another example: for each feature dimension of the central prototype representation, the median of the feature value of the overall feature representation prototype corresponding to each classification result in the feature dimension is used as the feature value of the determined central prototype representation in the feature dimension to obtain the central prototype representation.
[0107] In addition, the above-mentioned process of fusing the overall feature representation prototypes corresponding to each classification result to obtain the central prototype representation can also be determined by the central server, and then the determined central prototype representation can be sent to each downstream device, so that each downstream device determines the target loss value according to the central prototype representation.
[0108] In addition, in order to further improve the training effect of the local classification model, the downstream device can also determine the reference loss value based on the deviation between the classification result to which the local training data belongs output by the target classification model and the actual classification result corresponding to the local training data, wherein the deviation between the classification result to which the local training data belongs output by the target classification model and the actual classification result corresponding to the local training data is positively correlated with the reference loss value.
[0109] In addition, the downstream device may also determine the alignment loss value according to the difference between the feature representation of each local training data output by the target classification model and the central prototype representation, wherein the difference between the feature representation of each local training data output by the target classification model and the central prototype representation is positively correlated with the alignment loss value, and the specific formula may be referred to as follows:
[0110]
[0111] In the above formula, is the alignment loss value, That is, the number of local training data stored in the downstream device. That is, the feature representation of the i-th local training data, It is the central prototype representation, and d is the dimension of the feature representation of the local training data.
[0112] It should be noted that the above-mentioned target loss value, reference loss value and alignment loss value can be used separately to train the target classification model. Of course, they can also be used together to train the target classification model to obtain a trained classification model.
[0113] When the above target loss value, reference loss value and alignment loss value are used together to train the target classification model, the downstream device can fuse the above target loss value, reference loss value and alignment loss value to obtain a fusion loss value, and then train the target classification model according to the fusion loss value to obtain a trained classification model. For details, refer to the following formula:
[0114]
[0115] In the above formula, is the fusion loss value, is the reference loss value, is the alignment loss value, is the target loss value, is the weight parameter corresponding to the alignment loss value, It is the weight parameter corresponding to the target loss value, which can be set according to actual needs.
[0116] In addition, in actual application scenarios, different downstream devices may have not only data heterogeneity problems, but also model heterogeneity problems. That is, since different downstream devices use different training data, the training methods for training the local classification model may also be different, which may cause the local classification model to have significant differences in performance.
[0117] Based on this, in this specification, the downstream device can also upload only the classification layer model parameters when uploading model parameters, so as to update the classification layer model parameters through the above method, and for the feature extraction layer model parameters, the corresponding model training method can be used according to actual needs to perform training and update locally.
[0118] From the above content, it can be seen that the downstream device can extract the feature representation prototype corresponding to each classification result so that the model training process can focus on the common characteristics of the local training data saved by the downstream device, that is, the central position of all samples in each category in the feature space, thereby ignoring the significant differences between individuals in the local training data to avoid the influence of data heterogeneity, thereby improving the training effect of federated learning.
[0119] For ease of understanding, the following describes in detail the process of executing business on the local classification model trained by the above method. Figure 2 shown.
[0120] Figure 2 A flowchart of a service execution method provided in this specification includes the following steps:
[0121] S201: Acquire data to be processed, where the data to be processed includes at least one of text data, image data, and audio data.
[0122] S202: Input the data to be processed into a pre-trained classification model to determine the feature representation corresponding to the data to be processed through the feature extraction layer of the classification model, and determine the classification result corresponding to the data to be processed according to the feature representation through the classification layer of the classification model. The classification model is trained by the above-mentioned distributed model training method.
[0123] S203: Execute the service according to the classification result.
[0124] In this specification, when a downstream device needs to perform a service, the service data that needs to be processed when executing the service to be executed can be used as the data to be processed.
[0125] For example, in the process of executing the image recognition service, the image data to be recognized can be used as the above-mentioned data to be processed.
[0126] For another example, in the process of executing the text classification service, the text data to be classified can be used as the above-mentioned data to be processed.
[0127] For another example: in the process of executing the intelligent voice customer service response task, the collected audio data containing the questions to be answered raised by the user can be used as the above-mentioned data to be processed.
[0128] Furthermore, the downstream device can input the data to be processed into a pre-trained classification model to determine the feature representation corresponding to the data to be processed through the feature extraction layer of the classification model, and determine the classification result corresponding to the data to be processed according to the feature representation through the classification layer of the classification model, and perform business execution based on the classification result.
[0129] From the above content, it can be seen that the downstream device can extract the feature representation prototype corresponding to each classification result to enable the model training process to focus on the common characteristics of the local training data stored by the downstream device, that is, the central position of all samples in each category in the feature space, thereby ignoring the significant differences between individuals in the local training data to avoid the impact of data heterogeneity, thereby improving the training effect of federated learning, and the classification model trained by the above method can be used to classify the data that needs to be classified in the process of executing the business.
[0130] The above is one or more distributed model training methods implemented in this specification. Based on the same idea, this specification also provides corresponding distributed model training and business execution devices, such as Figure 3 , Figure 4 shown.
[0131] Figure 3 A schematic diagram of a distributed model training device provided for this specification includes:
[0132] An acquisition module 301 is used to acquire a feature representation prototype corresponding to each classification result outputted after a preset local classification model classifies each local training data. For each classification result, the feature representation prototype corresponding to the classification result is determined based on each feature representation extracted from the local training data belonging to the classification result by the local classification model. The feature representation prototype corresponding to the classification result is used to reflect the common features of each local training data belonging to the classification result. The local training data includes: at least one of training text, training image, and training audio.
[0133] The fusion module 302 is used to send the feature representation prototype corresponding to each classification result and the model parameters of the local classification model to the central server, so that the central server determines the overall feature representation prototype corresponding to each classification result according to the feature representation prototype sent by each downstream device, and fuses the model parameters sent by each downstream device to obtain the fusion model parameters, and returns the overall feature representation prototype corresponding to each classification result and the fusion model parameters;
[0134] An updating module 303 is used to update the local classification model according to the received fusion model parameters to obtain a target classification model;
[0135] The training module 304 is used to, for each local training data, use the similarity between the feature representation of the local training data determined by the target classification model and the overall feature representation prototype corresponding to the classification result to which the local training data belongs as the first similarity, and use the similarity between the feature representation of the local training data and the overall feature representation prototype corresponding to other classification results except the classification result to which the local training data belongs as the second similarity, so as to determine a target loss value according to the ratio between the first similarity and the second similarity, and train the target classification model according to the target loss value, wherein the target loss value is negatively correlated with the ratio.
[0136] Optionally, the acquisition module 301 is specifically used to acquire each local training data; input each local training data into a preset local classification model to obtain a feature representation of each local training data output by the local classification model and a classification result corresponding to each local training data; for each classification result, fuse the feature representation of each local training data belonging to the classification result to obtain a feature representation prototype corresponding to the classification result.
[0137] Optionally, the fusion module 302 is specifically used to send each feature representation prototype, various classification results obtained after the local classification model classifies each local training data, and the model parameters of the local classification model to the central server, so that the central server determines the types of various classification results obtained by each downstream device and determines each target classification result; for each target classification result, the overall feature representation prototype corresponding to the target classification result is determined according to the feature representation prototype corresponding to the target classification result in different downstream devices.
[0138] Optionally, the fusion module 302 is specifically used to send the feature representation prototype corresponding to each classification result and the model parameters of the local classification model to the central server, so that the central server determines the overall feature representation prototype corresponding to each classification result according to the feature representation prototypes sent by each downstream device, and fuses the overall feature representation prototypes corresponding to each classification result to obtain a central prototype representation, and fuses the model parameters sent by each downstream device to obtain a fused model parameter, and returns the overall feature representation prototype corresponding to each classification result, the central prototype representation and the fused model parameters;
[0139] The training module 304 is specifically used to, for each local training data, use the difference between the feature representation of the local training data determined by the target classification model and the central prototype representation as the first difference, use the difference between the overall feature representation prototype and the central prototype representation corresponding to the classification result to which the local training data belongs as the second difference, and use the difference between the overall feature representation prototype and the central prototype representation corresponding to other classification results except the classification result to which the local training data belongs as the third difference, and determine the target loss value according to the ratio of the similarity between the first difference and the second difference and the similarity between the first difference and the third difference, and train the target classification model according to the target loss value to obtain a trained classification model.
[0140] Optionally, the training module 304 is specifically used to determine a reference loss value based on a deviation between a classification result to which the local training data belongs output by the target classification model and an actual classification result corresponding to the local training data, wherein the deviation between the classification result to which the local training data belongs output by the target classification model and the actual classification result corresponding to the local training data is positively correlated with the reference loss value; determine an alignment loss value based on a difference between a feature representation and a central prototype representation of each local training data output by the target classification model, wherein the difference between a feature representation and a central prototype representation of each local training data output by the target classification model is positively correlated with the alignment loss value; train the target classification model based on the target loss value, the reference loss value and the alignment loss value to obtain a trained classification model.
[0141] Optionally, the model parameters include: feature extraction layer model parameters;
[0142] The fusion module 302 is specifically used to send the feature representation prototype corresponding to each classification result and the model parameters of the local classification model to the central server, so that the central server fuses the feature extraction layer model parameters sent by each downstream device to obtain the fused feature extraction layer model parameters, and returns the overall feature representation prototype corresponding to each classification result and the fused feature extraction layer model parameters;
[0143] The update module 303 is specifically used to determine the total number of training data used by all downstream devices; determine the parameter weight corresponding to the local classification model according to the ratio of the number of each local training data to the total number; according to the parameter weight, fuse the feature extraction layer model parameters with the fused feature extraction layer model parameters to obtain the feature extraction layer model parameters to be updated, and update the local classification model according to the feature extraction layer model parameters to be updated to obtain the target classification model.
[0144] Optionally, the model parameters include: classification layer model parameters;
[0145] The fusion module 302 is specifically used to send the feature representation prototype corresponding to each classification result and the model parameters of the local classification model to the central server, so that the central server fuses the classification layer model parameters sent by each downstream device to obtain the fused classification layer model parameters, and returns the overall feature representation prototype corresponding to each classification result and the fused classification layer model parameters;
[0146] The update module 303 is specifically used to determine the number of training rounds for the local classification model; determine the transition weight corresponding to the local classification model according to the number of training rounds; fuse the classification layer model parameters with the fused classification layer model parameters according to the transition weight to obtain the classification layer model parameters to be updated, and update the local classification model according to the classification layer model parameters to be updated to obtain the target classification model.
[0147] Figure 4 A schematic diagram of a distributed model training device provided for this specification includes:
[0148] The acquisition module 401 is used to acquire data to be processed, wherein the data to be processed includes at least one of text data, image data, and audio data;
[0149] A classification module 402 is used to input the data to be processed into a pre-trained classification model to determine the feature representation corresponding to the data to be processed through the feature extraction layer of the classification model, and determine the classification result corresponding to the data to be processed according to the feature representation through the classification layer of the classification model, wherein the classification model is trained by the above-mentioned distributed model training method;
[0150] The execution module 403 is used to execute the service according to the classification result.
[0151] This specification also provides a computer-readable storage medium, which stores a computer program, which can be used to execute the above Figure 1 A distributed model training method provided.
[0152] This manual also provides Figure 5 The one shown corresponds to Figure 1 A schematic diagram of the electronic device. Figure 5 As mentioned above, at the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory, and may also include other hardware required for the business. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to achieve the above Figure 1 The distributed model training method described. Of course, in addition to the software implementation, this specification does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0153] For the improvement of a technology, it can be clearly distinguished whether it is a hardware improvement (for example, improvement of the circuit structure of diodes, transistors, switches, etc.) or a software improvement (improvement of the method flow). However, with the development of technology, many improvements of the method flow today can be regarded as direct improvements of the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that the improvement of a method flow cannot be implemented with a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming themselves, without having to ask chip manufacturers to design and make dedicated integrated circuit chips. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one kind of HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.
[0154] The controller may be implemented in any suitable manner, for example, the controller may take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (e.g., software or firmware) executable by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320, and the memory controller may also be implemented as part of the control logic of the memory. It is also known to those skilled in the art that, in addition to implementing the controller in a purely computer-readable program code manner, the controller may be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, such a controller may be considered as a hardware component, and the devices for implementing various functions included therein may also be considered as structures within the hardware component. Or even, the devices for implementing various functions may be considered as both software modules for implementing the method and structures within the hardware component.
[0155] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0156] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0157] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems, or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0158] This specification is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of this specification. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0159] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0160] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0161] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0162] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0163] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0164] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0165] It should be understood by those skilled in the art that the embodiments of this specification may be provided as methods, systems or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0166] This specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0167] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0168] The above description is only an embodiment of the present specification and is not intended to limit the present specification. For those skilled in the art, the present specification may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification shall be included in the scope of the claims of the present specification.
Claims
1. A distributed model training method, characterized in that: include: Obtaining a feature representation prototype corresponding to each classification result output after a preset local classification model classifies each local training data, wherein for each classification result, the feature representation prototype corresponding to the classification result is determined based on each feature representation extracted from the local training data belonging to the classification result by the local classification model, and the feature representation prototype corresponding to the classification result is used to reflect the common features of each local training data belonging to the classification result, wherein the local training data includes: at least one of training text, training image, and training audio; Send the feature representation prototype corresponding to each classification result and the model parameters of the local classification model to the central server, so that the central server determines the overall feature representation prototype corresponding to each classification result according to the feature representation prototypes sent by each downstream device, and fuses the model parameters sent by each downstream device to obtain fused model parameters, and returns the overall feature representation prototype corresponding to each classification result and the fused model parameters; The local classification model is updated according to the received fusion model parameters to obtain a target classification model; For each local training data, the similarity between the feature representation of the local training data determined by the target classification model and the overall feature representation prototype corresponding to the classification result to which the local training data belongs is taken as the first similarity, and the similarity between the feature representation of the local training data and the overall feature representation prototype corresponding to other classification results except the classification result to which the local training data belongs is taken as the second similarity, so as to determine a target loss value according to the ratio between the first similarity and the second similarity, and train the target classification model according to the target loss value, wherein the target loss value is negatively correlated with the ratio; or Send the feature representation prototype corresponding to each classification result and the model parameters of the local classification model to the central server, so that the central server determines the overall feature representation prototype corresponding to each classification result according to the feature representation prototypes sent by each downstream device, and fuses the overall feature representation prototypes corresponding to each classification result to obtain a central prototype representation, and fuses the model parameters sent by each downstream device to obtain a fused model parameter, and returns the overall feature representation prototype corresponding to each classification result, the central prototype representation and the fused model parameters; The local classification model is updated according to the received fusion model parameters to obtain a target classification model; For each local training data, the difference between the feature representation of the local training data determined by the target classification model and the central prototype representation is taken as the first difference, the difference between the overall feature representation prototype and the central prototype representation corresponding to the classification result to which the local training data belongs is taken as the second difference, and the difference between the overall feature representation prototype and the central prototype representation corresponding to other classification results except the classification result to which the local training data belongs is taken as the third difference, and the target loss value is determined according to the ratio of the similarity between the first difference and the second difference and the similarity between the first difference and the third difference, and the target classification model is trained according to the target loss value to obtain a trained classification model.
2. The method according to claim 1, characterized in that Obtain the feature representation prototype corresponding to each classification result output after the preset local classification model classifies each local training data, specifically including: Obtain local training data; Inputting each local training data into a preset local classification model to obtain a feature representation of each local training data output by the local classification model and a classification result corresponding to each local training data; For each classification result, the feature representation of each local training data belonging to the classification result is fused to obtain the feature representation prototype corresponding to the classification result.
3. The method according to claim 1, characterized in that Sending the feature representation prototype corresponding to each classification result and the model parameters of the local classification model to the central server, so that the central server determines the overall feature representation prototype corresponding to each classification result according to each feature representation prototype sent by each downstream device, specifically including: Sending each feature representation prototype, various classification results obtained after the local classification model classifies each local training data, and model parameters of the local classification model to a central server, so that the central server determines the types of various classification results obtained by each downstream device and determines each target classification result; For each target classification result, the overall feature representation prototype corresponding to the target classification result is determined according to the feature representation prototypes corresponding to the target classification result in different downstream devices.
4. The method according to claim 1, characterized in that According to the target loss value, the target classification model is trained to obtain a trained classification model, which specifically includes: Determine a reference loss value according to a deviation between a classification result to which the local training data belongs output by the target classification model and an actual classification result corresponding to the local training data, wherein the deviation between the classification result to which the local training data belongs output by the target classification model and the actual classification result corresponding to the local training data is positively correlated with the reference loss value; Determine an alignment loss value according to a difference between a feature representation of each local training data output by the target classification model and a central prototype representation, wherein the difference between the feature representation of each local training data output by the target classification model and the central prototype representation is positively correlated with the alignment loss value; The target classification model is trained according to the target loss value, the reference loss value and the alignment loss value to obtain a trained classification model.
5. The method according to claim 1, characterized in that The model parameters include: feature extraction layer model parameters; Sending the feature representation prototype corresponding to each classification result and the model parameters of the local classification model to the central server, so that the central server fuses the model parameters sent by each downstream device to obtain the fused model parameters, and returning the overall feature representation prototype corresponding to each classification result and the fused model parameters, specifically includes: Sending the feature representation prototype corresponding to each classification result and the model parameters of the local classification model to the central server, so that the central server fuses the feature extraction layer model parameters sent by each downstream device to obtain the fused feature extraction layer model parameters, and returns the overall feature representation prototype corresponding to each classification result and the fused feature extraction layer model parameters; The local classification model is updated according to the received fusion model parameters to obtain a target classification model, specifically including: Determine the total amount of training data used by all downstream devices; Determining a parameter weight corresponding to the local classification model according to a ratio of the number of each local training data to the total number; According to the parameter weights, the feature extraction layer model parameters are fused with the fused feature extraction layer model parameters to obtain the feature extraction layer model parameters to be updated, and the local classification model is updated according to the feature extraction layer model parameters to be updated to obtain the target classification model.
6. The method according to claim 1, characterized in that The model parameters include: classification layer model parameters; Sending the feature representation prototype corresponding to each classification result and the model parameters of the local classification model to the central server, so that the central server fuses the model parameters sent by each downstream device to obtain the fused model parameters, and returning the overall feature representation prototype corresponding to each classification result and the fused model parameters, specifically includes: Send the feature representation prototype corresponding to each classification result and the model parameters of the local classification model to the central server, so that the central server fuses the classification layer model parameters sent by each downstream device to obtain the fused classification layer model parameters, and returns the overall feature representation prototype corresponding to each classification result and the fused classification layer model parameters; The local classification model is updated according to the received fusion model parameters to obtain a target classification model, specifically including: Determining the number of training rounds for the local classification model; Determining a transition weight corresponding to the local classification model according to the number of training rounds; According to the transition weights, the classification layer model parameters are fused with the fused classification layer model parameters to obtain the classification layer model parameters to be updated, and the local classification model is updated according to the classification layer model parameters to be updated to obtain the target classification model.
7. A service execution method, characterized in that: include: Acquire data to be processed, wherein the data to be processed includes: at least one of text data, image data, and audio data; Inputting the data to be processed into a pre-trained classification model to determine the feature representation corresponding to the data to be processed through the feature extraction layer of the classification model, and determining the classification result corresponding to the data to be processed according to the feature representation through the classification layer of the classification model, wherein the classification model is trained by the method according to any one of claims 1 to 6 above; The business is executed according to the classification result.
8. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method described in any one of claims 1 to 7 is implemented.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method described in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Image classification method and device based on deep learning, server and medium
CN112163635A
Classification model training method, image classification method and device, equipment and medium
CN115239675A