Model training method and device, electronic equipment and storage medium
By determining the weight value of the image vector representation according to the round and data quality in federated learning and performing clustering, the problem of poor global model training effect is solved and better model generalization ability and data utilization are achieved.
Patent Information
- Application Number
- CN202410693867.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-30
- Publication Date
- 2024-09-03
AI Technical Summary
In the federated learning process, the training effect of the global model is affected by the data quality of the central node device, resulting in poor model training effect and easy to fall into the local optimal solution.
By receiving model training data from multiple edge node devices, according to the round and data quality, the weight value represented by the image vector is determined, clustered, and the global model parameters are updated to avoid local optimal solutions.
It improves the training effect of the global model, prevents the model from falling into local optimality, improves the utilization of data quality, and enhances the generalization ability of the model.
Smart Images

Figure CN118586529A
Abstract
Description
Technical Field
[0001] The present application relates to the field of model training, and in particular to a model training method, device, electronic device and storage medium. Background Art
[0002] Federated learning is an emerging distributed machine learning paradigm that focuses on privacy protection. There is currently a multimodal federated learning framework CreamFL that can train larger central node device models from edge node devices with heterogeneous model architectures and data modalities. During the federated learning process, the local data sets between the edge node devices are not shared with each other.
[0003] The central node device establishes a global model and sends the output results of the global model to each edge node device. Each edge node device uses the local model and local data set to train the model and outputs the trained results to the central node device, so that the central node device can update the global model according to the training results of each edge node.
[0004] However, in the actual application of federated learning, the global model has the problem that if the data quality of the central node device is poor, it will eventually lead to poor global model training results. Summary of the invention
[0005] The present application provides a model training method, device, electronic device and storage medium to solve the technical problem of poor model training effect.
[0006] In a first aspect, the present application provides a model training method, applied to a central node device, comprising:
[0007] Receiving model training data from multiple edge node devices; the model training data of the edge node device includes n picture vector representations obtained by inputting n pictures in a public data set into a local model of the edge node device respectively, where n is a positive integer greater than 1;
[0008] According to the round of this round of training, the model training data of the multiple edge node devices and the model training data of the central node device, the weight values corresponding to the respective image vector representations in the model training data of the multiple edge node devices are determined respectively; the model training data of the central node device includes n text vector representations obtained by inputting the texts corresponding to the n images in the public data set into the global model respectively;
[0009] Clustering the image vector representations in the model training data of the multiple edge node devices according to the weight values corresponding to the image vector representations in the model training data of the multiple edge node devices to obtain the clustered image vector representations corresponding to the images in the public data set;
[0010] The global model is trained according to each picture in the public data set and the clustered picture vector representation corresponding to each picture to update the model parameters of the global model.
[0011] Optionally, the above method, according to the round of this round of training, the model training data of the plurality of edge node devices, and the model training data of the central node device, respectively determines the weight value corresponding to each image vector representation in the model training data of the plurality of edge node devices, including:
[0012] If the round of this training meets the preset conditions, the weight values corresponding to the image vectors in the model training data of the multiple edge node devices are determined according to the model training data of the multiple edge node devices, the model training data of the central node device and the round of this training.
[0013] Optionally, in the above method, the preset condition includes: the logarithm of the number of rounds of the current training with base 2 is a positive integer.
[0014] Optionally, the above method, according to the model training data of the multiple edge node devices, the model training data of the central node device and the round of the current training, determines the weight value corresponding to each image vector representation in the model training data of the multiple edge node devices, including:
[0015] Taking the k-th image vector representation in the model training data of the first edge node device as an example, the k-th image vector representation corresponds to the k-th image in the public data set, and n text vector representations are obtained by respectively inputting n texts into the global model from the model training data of the central node device; k is between [1, n], and n texts correspond to n images one by one;
[0016] Determine a score corresponding to the k-th image vector representation according to the k-th image vector representation and the n text vector representations;
[0017] Obtain scores corresponding to remaining picture vector representations except the k-th picture vector representation in the model training data of the first edge node device;
[0018] According to the scores corresponding to the representations of the respective picture vectors in the model training data of the first edge node device and the round number of this round of training, the weight values corresponding to the representations of the respective picture vectors in the model training data of the first edge node device are determined.
[0019] Optionally, the above method, according to the weight value corresponding to each image vector representation in the model training data of the plurality of edge node devices, clusters each image vector representation in the model training data of the plurality of edge node devices to obtain the clustered image vector representation corresponding to each image in the public data set, including:
[0020] Taking the first picture in the public data set as an example, obtaining a weight value corresponding to the picture vector representation of the first picture in the model training data of multiple edge node devices;
[0021] According to the weight values corresponding to the image vector representations of the first image in the model training data of the multiple edge node devices, the image vector representations of the first image in the model training data of the multiple edge node devices are weighted summed to obtain the clustered image vector representation corresponding to the first image.
[0022] Optionally, the above method, according to the round of this round of training, the model training data of the plurality of edge node devices, and the model training data of the central node device, respectively determines the weight value corresponding to each image vector representation in the model training data of the plurality of edge node devices, including:
[0023] If the current round of training does not meet the preset conditions, the weight values corresponding to the image vector representations in the model training data of the multiple edge node devices are determined respectively according to the model training data of the multiple edge node devices and the model training data of the central node device.
[0024] Optionally, the above method, according to the model training data of the plurality of edge node devices and the model training data of the central node device, determines the weight value corresponding to each image vector representation in the model training data of the plurality of edge node devices, including:
[0025] Taking the k-th image vector representation in the model training data of the first edge node device as an example, the k-th image vector representation corresponds to the k-th image in the public data set, and n text vector representations are obtained by respectively inputting n texts into the global model from the model training data of the central node device; k is between [1, n], and n texts correspond to n images one by one;
[0026] Determine a score corresponding to the k-th image vector representation according to the k-th image vector representation and the n text vector representations;
[0027] Obtain scores corresponding to remaining picture vector representations except the k-th picture vector representation in the model training data of the first edge node device;
[0028] According to the scores corresponding to the representations of the respective picture vectors in the model training data of the first edge node device and the round number of this round of training, the weight values corresponding to the representations of the respective picture vectors in the model training data of the first edge node device are determined.
[0029] In a second aspect, the present application provides a model training device, applied to a central node device, including:
[0030] A receiving module, used to receive model training data from multiple edge node devices; the model training data of the edge node device includes n picture vector representations obtained by inputting n pictures in the public data set into the local model of the edge node device respectively, where n is a positive integer greater than 1;
[0031] A determination module, for determining weight values corresponding to each image vector representation in the model training data of the plurality of edge node devices, respectively, according to the round of current training, the model training data of the plurality of edge node devices, and the model training data of the central node device; the model training data of the central node device includes n text vector representations obtained by inputting texts corresponding to n images in the public data set into the global model respectively;
[0032] A clustering module, used to cluster the image vector representations in the model training data of the multiple edge node devices according to the weight values corresponding to the image vector representations in the model training data of the multiple edge node devices, and obtain the clustered image vector representations corresponding to the images in the public data set;
[0033] The updating module is used to train the global model according to each picture in the public data set and the clustered picture vector representation corresponding to each picture, so as to update the model parameters of the global model.
[0034] In a third aspect, the present application provides an electronic device, including:
[0035] A processor, and a memory communicatively connected to the processor;
[0036] Memory stores computer-executable instructions;
[0037] The processor executes the computer-executable instructions stored in the memory to implement the method of the present application.
[0038] In a fourth aspect, the present application provides a computer-readable storage medium, comprising:
[0039] The computer-readable storage medium stores computer-executable instructions, which are used to implement the method of the present application when executed by a processor.
[0040] In a fifth aspect, the present application provides a computer program product, including:
[0041] A computer program, which implements the method of the present application when executed by a processor.
[0042] The model training method, device, electronic device and storage medium provided in the present application receive model training data from multiple edge node devices; determine the weight values corresponding to each image vector representation in the model training data of the multiple edge node devices according to the round of current training, the model training data of the multiple edge node devices and the model training data of the central node device; cluster the image vector representations in the model training data of the multiple edge node devices according to the weight values corresponding to each image vector representation in the model training data of the multiple edge node devices to obtain the clustered image vector representations corresponding to each image in the public data set; train the global model according to each image in the public data set and the clustered image vector representations corresponding to each image, so as to update the model parameters of the global model, prevent the model training from falling into the local optimum, and achieve the effect of improving the global model training. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0044] Figure 1 Schematic diagram of the federated learning framework provided for this application;
[0045] Figure 2 Device interaction diagrams provided for this application;
[0046] Figure 3 A flowchart of a model training method provided in this application;
[0047] Figure 4 A flowchart of another model training method provided for this application;
[0048] Figure 5 A flowchart of another model training method provided in this application;
[0049] Figure 6 A schematic diagram of the structure of the model training device provided in this application;
[0050] Figure 7 A schematic diagram of the structure of the electronic device provided in this application.
[0051] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0052] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0053] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0054] First, the terms involved in this application are explained:
[0055] Node is a term that refers to a type of device, which can be a host (PC), server, or switch, router, firewall, etc. that constitutes a transmission network. A central node or edge node is a basic unit based on a distributed computing architecture. It has independent computing resources and can perform various computing tasks. A central node or edge node can be a physical server, virtual machine, or container that works with other nodes to complete tasks together. Each node has its own processor, memory, and storage device to achieve efficient computing. The central node in this application is a central node device, and the edge node is an edge node device.
[0056] Federated learning is an emerging distributed machine learning paradigm that focuses on privacy protection. Currently, there is a multimodal federated learning framework CreamFL that can train larger central node device models from edge node devices with heterogeneous model architectures and data modalities. In the process of federated learning, the local data sets between the edge node devices are not shared with each other. The central node device establishes a global model and sends the output results of the global model to each edge node device. Each edge node device uses the local model and local data set to train the model and outputs the trained results to the central node device. The central node device clusters the results returned by each edge node device to update the global model. Furthermore, the steps of sending the output results of the global model to each edge node device and clustering the results returned by each edge node device to update the global model are repeated until the global model converges, thereby achieving the effect of improving model training.
[0057] The idea of simulated annealing is to find the global optimal solution to the problem by simulating the atomic motion law during the metal annealing process. In the optimization problem, the simulated annealing algorithm randomly searches in the solution space and accepts inferior solutions with a certain probability to avoid falling into the local optimal solution and finally find a better solution. This method is similar to the process of metal gradually cooling and reaching a stable state during the annealing process, so it is called the simulated annealing algorithm.
[0058] Figure 1 The schematic diagram of the federated learning framework provided for this application is as follows: Figure 1 As shown, the federated learning framework includes a central node device and multiple edge node devices. The edge node device can be an edge node device of type 1, type 2, or type 3. There is no data transmission between edge node devices, and data transmission only occurs between the central node device and each edge node device.
[0059] A global model is deployed in the central node device. The functions of the global model can be: input a picture and output the vector representation corresponding to the picture; input text and output the vector representation corresponding to the text, that is, the global model can recognize pictures and text. The central node device trains the global model based on a public data set, where the data structure of the public data set is "picture: text", and there is a corresponding relationship between the picture and text in each set of data in the public data set;
[0060] A local model is deployed in the edge node device of type 1. The function of the local model of the edge node device of type 1 can be: input a picture and output a vector representation corresponding to the picture, that is, the local model can recognize the picture. The edge node device of type 1 trains the local model based on its local data set, where the data structure of the local data set is "picture: category", and there is a corresponding relationship between the picture and the category in each set of data in the local data set.
[0061] A local model is deployed in the type 2 edge node device. The function of the local model of the type 2 edge node device can be: input text and output the vector representation corresponding to the text, that is, the local model can recognize text. The type 2 edge node device trains the local model based on its local data set, where the data structure of the local data set is "text: category", and there is a corresponding relationship between the text and category in each set of data in the local data set.
[0062] A local model is deployed in the type 3 edge node device. The functions of the local model of the type 3 edge node device can be: input a picture and output the vector representation corresponding to the picture; input text and output the vector representation corresponding to the text, that is, the local model of the type 3 edge node device can recognize both pictures and text. The type 3 edge node device trains the local model based on its local data set, where the data structure of the local data set is "picture: text", and there is a corresponding relationship between the picture and text in each set of data in the local data set.
[0063] Figure 2 The device interaction diagram provided for this application, such as Figure 2 As shown, it is assumed that the edge node device is a type 1 edge node device, and the interaction process between the central node device and the type 1 edge node device is described.
[0064] S201. The central node device inputs the public data set into the pre-trained global model to obtain the image vector representation and text vector representation corresponding to the public data set.
[0065] The image vector representation corresponding to the public data set includes the image vector representation corresponding to each image in the public data set, and the text vector representation corresponding to the public data set includes the text vector representation corresponding to each text in the public data set.
[0066] Specifically, the central node device sequentially inputs each image in the public data set into the pre-trained global model to obtain the image vector representation corresponding to each image in the public data set. Also, the central node device sequentially inputs each text in the public data set into the pre-trained global model to obtain the text vector representation corresponding to each text in the public data set.
[0067] The pre-trained global model may be an initial global model or a global model after a previous round of training.
[0068] S202: The central node device sends the image vector representation and the text vector representation corresponding to the public data set generated by the central node device to the edge node device.
[0069] S203: The edge node device updates the local model according to the pictures in the public data set generated by the central node device and the picture vector representation corresponding to the pictures.
[0070] It should be noted that, before S203, the process also includes: training the initial local model according to the local data set to obtain a pre-trained local model.
[0071] In some embodiments, the initial local model is an initialized local model. The pictures in the local data set are used as input of the local model, and the categories corresponding to the pictures in the local data set are used as output. The local model is trained to obtain the initial local model and the model parameters of the initial local model.
[0072] Specifically, S203 includes: using the pictures of the public data set as the input of the pre-trained local model, using the picture vector representation corresponding to the pictures in the public data set as the output of the pre-trained local model, and re-training the pre-trained local model to update the model parameters of the pre-trained local model.
[0073] S204: The edge node device inputs the public data set into the updated local model to obtain the image vector representation corresponding to the public data set generated by the edge node device.
[0074] S205: The edge node device sends the image vector representation corresponding to the public data set generated by the edge node device to the central node device.
[0075] S206. The central node device performs clustering processing according to the image vector representation corresponding to the public data set generated by the edge node device to obtain a clustered image vector representation.
[0076] The clustering process may include:
[0077] The central node device obtains the image vector representation of each image and the text vector representation of each text in the public data set. It can be understood as follows: for the kth image-text group of the public data set P, k = 1, ..., |P|, the model of the central node device will generate the vector representation of this image-text group: in, is the vector representation of the image in this image-text group, is the vector representation of the text of this image-text group;
[0078] According to the vector representation corresponding to the data set generated by the edge node device, for example, for the edge node device c of type 1, for the kth image-text group of the public data set P, a vector representation of the image will be generated If the vector representation of the image from the edge node device of type 1 better matches the "vector representation" of the text corresponding to this image from the central node device And the "vector representation" of other text that does not correspond to this image The vector representation of image k given by such type 1 edge node device should have a higher weight in the cluster. The specific weight formula is:
[0079]
[0080] s (k,c) The score of the image vector representation generated by the c-th type-1 edge node device for the image of the k-th image-text group of the public dataset P.
[0081] Furthermore, the softmax function is used to normalize the scores of the image vector representations generated by the c-th type 1 edge node device for the public dataset P:
[0082] α (k,1) ,α (k,2) ,…,α (k,c) =softmax(s (k,1) ,s (k,2) ,…,s (k,c) ) Formula 2
[0083] Among them, α (k,c) The weight of the image vector representation generated for the cth type 1 edge node device corresponding to the kth image-text group in the public dataset is clustered based on the weights to obtain i (k) ,i (k) satisfy:
[0084]
[0085] Among them, i (k) Clustering results of vector representations generated for images of each image-text group in the public dataset for all type 1 edge node devices.
[0086] S207. The central node device updates the global model according to the clustered image vector representation.
[0087] The images of the public data set are used as the input of the global model of the central node device, and the clustered image vector representation corresponding to the images of the public data set generated by the edge node device is used as the output of the global model. The global model is trained to update the model parameters of the global model.
[0088] It can be seen from the above method that when the central node device clusters the results returned by each edge node device, a weight will be set for the vector representation generated by each edge node device, and the weight is calculated only based on the difference between the vector representation generated by each edge node device for the public data set and the vector representation generated by the central node device for the public data set. If the vector representation generated by the edge node device better matches the vector representation generated by the central node device for the same data group, then for the vector representation generated by the edge node device for the data group, a higher weight is given to the edge node device. There are problems with this approach: if the central node device and the edge node device converge to the local optimum during the iterative convergence of the model training, or the data quality of the central node device is not good, resulting in poor training effect of the central node device, and then in each round of iteration, if the edge node device inputs the public data set and outputs a vector representation, and the vector representation is close to the low-quality vector representation generated by the central node device, then the vector representation is given a larger weight, which ultimately leads to poor global model training effect.
[0089] In response to the problems existing in the actual application of federated learning, the model training method provided in this application refers to the idea of simulated annealing. Every certain number of iterations, a greater weight is given to the edge node device whose output vector representation is farther away from the vector representation produced by the central node device. This approach seems to violate common sense in weight setting, but every certain number of iterations, when the data quality of the public data set is low, a higher weight can be given to the edge node device with higher data quality, thereby assisting the training of the global model of the central node device, preventing the model training from falling into the local optimal situation, and achieving the effect of improving the global model training. The model training method provided by the present application receives model training data from multiple edge node devices; according to the round of this round of training, the model training data of multiple edge node devices, and the model training data of the central node device, the weight values corresponding to each image vector representation in the model training data of multiple edge node devices are determined respectively; according to the weight values corresponding to each image vector representation in the model training data of multiple edge node devices, each image vector representation in the model training data of multiple edge node devices is clustered to obtain the clustered image vector representation corresponding to each image in the public data set; according to each image in the public data set and the clustered image vector representation corresponding to each image, the global model is trained to update the model parameters of the global model. The model training method provided by the present application prevents the model training from falling into the situation where the model training enters the local optimum, and can achieve the effect of improving the global model training.
[0090] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0091] Figure 3 The flow chart of the model training method provided in this application is applied to the central node device, such as Figure 3 As shown, the method includes:
[0092] S301. Receive model training data from multiple edge node devices, where the model training data of the edge node device includes n picture vector representations obtained by inputting n pictures in a public data set into a local model of the edge node device respectively, where n is a positive integer greater than 1.
[0093] Among them, a public data set may refer to a data set containing pictures and texts, and the data structure of each group of data in the public data set is "picture: text". The public data set includes n groups of data, and n is also the total number of data groups in the public data set. There are n pairs of data in total, and n is a positive integer greater than 1. The picture may refer to the image data in the data set, and the format of the picture may include but is not limited to JPEG, PNG, GIF, and BMP formats. The text may refer to the text information corresponding to the picture in the data set, and the format requirements of the text may include but are not limited to the encoding requirements of UTF-8 encoding. For example, if the picture is a scene picture, the text is a paragraph of text describing the scene picture. In order to better limit and adjust the computing resources, the character length of the text can be 50 characters. A set of data sets can be, for example, "a picture of a cat: a small ragdoll cat is eating cat food in a pink bowl, and the cat food is almost eaten up";
[0094] The central node device may refer to a device that is deployed with a global model and can train and update the global model. The central node device stores a public data set, which is the basic data for training the global model. The public data set can also be transmitted to the edge node device through the central node device, so as to facilitate the model training of the local model by the edge node device and the vector representation output corresponding to the public data set. The edge node device may refer to a device that is deployed with a local model and can train and update the local model. The edge node device stores a local data set. The edge node device includes a type 1 edge node device, a type 2 edge node device, and a type 3 edge node device. When describing the edge node device, the present application defaults to the edge node device as a type 1 edge node device.
[0095] The global model may refer to a model deployed on a central node device. The global model may be a neural network model. The function of the global model may be to input a picture and output a vector representation corresponding to the picture, to input text and output a vector representation corresponding to the text. The local model may refer to a model deployed on an edge node device. The local model may be a neural network model. For a type 1 edge node device, the function of the local model may be to input a picture and output a vector representation corresponding to the picture. For a type 2 edge node device, the function of the local model may be to input text and output a vector representation corresponding to the text. For a type 3 edge node device, the function of the local model may be to input a picture and output a vector representation corresponding to the picture, to input text and output a vector representation corresponding to the text.
[0096] Model training data may refer to the vector representation corresponding to the data set. Vector representation may refer to the representation method of converting images and texts into vector form. In the field of natural language processing, vector representation is often used to convert words, sentences or documents into numerical vectors so that computers can understand and process them. Vector representation methods include but are not limited to bag-of-words models, Word2Vec, and GloVe. In the field of image processing, vector representation may also refer to the conversion of images into feature vectors. Therefore, both image vector representation and text vector representation can be processed and analyzed by computers. Image vector representation refers to the vector representation corresponding to images, and text vector representation refers to the vector representation corresponding to text.
[0097] The model training data of the edge node device may refer to the edge node device inputting a public data set and outputting a vector representation corresponding to the public data set. If the edge node device is a type 1 edge node device, the model training data of the edge node device is the image vector representation corresponding to the image of the public data set. If the edge node device is a type 2 edge node device, the model training data of the edge node device is the text vector representation corresponding to the text of the public data set. If the edge node device is a type 3 edge node device, the model training data of the edge node device is the image vector representation corresponding to the image of the public data set and the text vector representation corresponding to the text of the public data set.
[0098] S302: Determine the weight value corresponding to each image vector representation in the model training data of the multiple edge node devices according to the round of current training, the model training data of the multiple edge node devices, and the model training data of the central node device.
[0099] The model training data of the central node device includes n text vector representations obtained by inputting the texts corresponding to n pictures in the public data set into the global model respectively.
[0100] In machine learning and deep learning, training models usually requires multiple iterations, and each iteration is called a training round. The round of this training can refer to the central node device receiving model training data from multiple edge node devices to train the global model based on each picture in the public data set and the clustered picture vector representation corresponding to each picture to update the model parameters of the global model. The initial value of the round is 1, and the value of the round is increased by one each time a round is completed.
[0101] In an optional implementation, S302 may include the following steps:
[0102] S3021. If the round of this training meets the preset conditions, determine the corresponding weight values of each image vector representation in the model training data of multiple edge node devices according to the model training data of multiple edge node devices, the model training data of the central node device and the round of this training.
[0103] In an optional implementation, the preset condition includes: the logarithm of the number of rounds of the current training with base 2 is a positive integer.
[0104] Among them, the preset conditions may refer to the conditions or rules set in the model training method, which are used to determine the weight value or the prerequisite for performing a specific operation. The preset conditions are set in advance by the staff. The purpose is to use different training rounds. According to the simulated annealing idea, the weight value calculation method of the image vector corresponding to the model training data of multiple edge node devices received by the central node device in the round of training is also different.
[0105] In some embodiments, the preset condition may also be that the logarithm of the number of rounds of this round of training with base 3 is a positive integer, or the number of rounds pre-set by the staff is 2, 3, 5, or 8, for example. The purpose is to be consistent with the idea of simulated annealing. When the preset conditions are met and when the preset conditions are not met, the weight values of the picture vectors corresponding to the model training data of multiple edge node devices received by the central node device in the round of training are calculated differently, thereby preventing the situation of entering the local optimum. The embodiments of the present application do not impose any restrictions on the preset conditions.
[0106] In an optional implementation of this embodiment, the k-th image vector representation in the model training data of the first edge node device is taken as an example, wherein the k-th image vector representation corresponds to the k-th image in the public data set.
[0107] The first edge node device is any one of a plurality of edge node devices, and the plurality of edge node devices may all be first edge node devices.
[0108] In some embodiments, if multiple edge node devices are all type 2 edge node devices, the above-mentioned example of the k-th picture vector representation in the model training data of the first edge node device can be adjusted to: taking the k-th text vector representation in the model training data of the first edge node device as an example. In some embodiments, if multiple edge node devices are all type 3 edge node devices, the above-mentioned example of the k-th picture vector representation in the model training data of the first edge node device can be adjusted to: taking the k-th picture vector representation and text vector representation in the model training data of the first edge node device as examples.
[0109] S3021 can be achieved by following the steps below:
[0110] S3021a. Obtain n texts from the model training data of the central node device and input them into the global model to obtain n text vector representations.
[0111] Among them, k is between [1, n], and n texts correspond to n pictures one by one.
[0112] S3021b. Determine a score corresponding to the kth image vector representation according to the kth image vector representation and the n text vector representations.
[0113] S3021c. Obtain scores corresponding to the remaining picture vector representations except the k-th picture vector representation in the model training data of the first edge node device.
[0114] S3021d. Determine a weight value corresponding to each image vector representation in the model training data of the first edge node device according to the score corresponding to each image vector representation in the model training data of the first edge node device and the round of this training.
[0115] Exemplarily, the score corresponding to the k-th image vector representation may be determined by the following formula:
[0116]
[0117] Among them, Iter is the round number of this round of training, s (k,c) is the cth first edge node device, n is the total number of images in the public dataset, is the kth picture vector representation in the model training data of the cth first edge node device, The text vector representation generated by the global model for the text input corresponding to the k-th image in the model training data of the central node device, The text vector representation generated by the global model for the text input corresponding to the j-th image in the model training data of the central node device.
[0118] The score representation corresponding to the k-th image vector representation is represented. If the current training round does not meet the preset conditions, the k-th image vector representation is closer to the text vector representation generated by the k-th image in the model training data of the central node device, and is further away from the text vector representation generated by the j-th image in the model training data of the central node device, then a lower numerical value corresponding to the score of the k-th image vector representation is assigned.
[0119] In some embodiments, if the first edge node device is a type 2 edge node device, the score corresponding to the k-th image vector representation should be adjusted to: The score corresponding to the k-th text vector representation may satisfy the formula:
[0120]
[0121] in, is the kth text vector representation in the model training data of the cth first edge node device, The image vector representation generated by the global model is input into the image corresponding to the kth text in the model training data of the central node device. The picture vector representation generated by the global model is input into the picture corresponding to the j-th text in the model training data of the central node device.
[0122] In some embodiments, if the first edge node device is a type 3 edge node device, the score corresponding to the k-th image vector representation should be adjusted to: the score corresponding to the k-th image vector representation, and the score corresponding to the k-th text vector representation, wherein there is a corresponding relationship between the k-th image and the k-th text, and the formula for the score corresponding to the k-th image vector representation is the same as the score formula used by the type 1 edge node device, and the formula for the score corresponding to the k-th text vector representation is the same as the score formula used by the type 2 edge node device.
[0123] According to the scores corresponding to the image vector representations in the model training data of the first edge node device, the weight values corresponding to the image vector representations in the model training data of the first edge node device are determined, and the scores corresponding to the image vector representations in the model training data of the first edge node device can be normalized using a softmax function. The normalization process can refer to dividing the scores corresponding to the image vector representations in the model training data of the first edge node device into a unified range, so that the image vector representations in the model training data of each edge node device are comparable, which can be specifically expressed as:
[0124] α (k,1) ,α (k,2) ,…,α (k,c) =softmax(s (k,1) ,s (k,2),…,s (k,c) ), α∈[0,1] Formula 6
[0125] Where c is the number of edge node devices, s (k,c) is the score corresponding to the k-th image vector in the model training data of the edge node device, α (k,c) The k-th image vector in the model training data of the edge node device represents the corresponding weight value, and there is a corresponding relationship between the score and the weight value.
[0126] In some embodiments, if the edge node device is a type 2 edge node device, s (k,c) is the score corresponding to the kth text vector in the model training data of the edge node device of type 2, α (k,c) The k-th text vector in the model training data of the edge node device of type 2 represents the corresponding weight value, and there is a corresponding relationship between the score and the weight value.
[0127] In some embodiments, if the edge node device is a type 3 edge node device, s (k,c) The k-th image vector in the model training data of the type 3 edge node device represents the corresponding score, the k-th text vector in the model training data of the type 3 edge node device represents the corresponding score, α (k,c) The k-th image vector in the model training data of the edge node device represents the corresponding weight value, and the k-th text vector in the model training data of the edge node device represents the corresponding weight value, and there is a corresponding relationship between the score and the weight value.
[0128] S3022. If the current round of training does not meet the preset conditions, determine the weight values corresponding to the image vector representations in the model training data of the multiple edge node devices according to the model training data of the multiple edge node devices and the model training data of the central node device.
[0129] In an optional implementation of the present application, the k-th image vector representation in the model training data of the first edge node device is taken as an example, wherein the k-th image vector representation corresponds to the k-th image in the public data set.
[0130] The first edge node device is any one of a plurality of edge node devices, and the plurality of edge node devices may all be first edge node devices.
[0131] S3022 can be achieved by following the steps below:
[0132] S3022a. Obtain n texts from the model training data of the central node device and input them into the global model to obtain n text vector representations.
[0133] Among them, k is between [1, n], and n texts correspond to n pictures one by one.
[0134] S3022b. Determine a score corresponding to the kth image vector representation according to the kth image vector representation and the n text vector representations.
[0135] S3022c. Obtain scores corresponding to the remaining picture vector representations except the k-th picture vector representation in the model training data of the first edge node device.
[0136] S3022d. Determine a weight value corresponding to each image vector representation in the model training data of the first edge node device according to a score corresponding to each image vector representation in the model training data of the first edge node device.
[0137] Exemplarily, the score corresponding to the k-th image vector representation may be determined by the following formula:
[0138]
[0139] Among them, s (k,c) is the cth first edge node device, n is the total number of images in the public dataset, is the k-th picture vector representation in the model training data of the c-th first edge node device, The text vector representation generated by the global model for the text input corresponding to the k-th image in the model training data of the central node device, The text vector representation generated by the global model for the text input corresponding to the j-th image in the model training data of the central node device.
[0140] The score representation corresponding to the k-th image vector representation is represented. If the round of this training meets the preset conditions, the k-th image vector representation is closer to the text vector representation generated by the k-th image in the model training data of the central node device, and is farther away from the text vector representation generated by the j-th image in the model training data of the central node device, then a higher numerical value is assigned to the score corresponding to the k-th image vector representation.
[0141] In some embodiments, if the first edge node device is a type 2 edge node device, the score corresponding to the k-th image vector representation should be adjusted to: The score corresponding to the k-th text vector representation may satisfy the formula:
[0142]
[0143] in, is the kth text vector representation in the model training data of the cth first edge node device, The image vector representation generated by the global model is input into the image corresponding to the kth text in the model training data of the central node device. The picture vector representation generated by the global model is input into the picture corresponding to the j-th text in the model training data of the central node device.
[0144] If the first edge node device is a type 3 edge node device, the score corresponding to the k-th image vector representation should be adjusted to: the k-th image vector representation corresponding score, the k-th text vector representation corresponding score, wherein there is a corresponding relationship between the k-th image and the k-th text, the formula for the score corresponding to the k-th image vector representation is the same as the score formula used by the type 1 edge node device, and the formula for the score corresponding to the k-th text vector representation is the same as the score formula used by the type 2 edge node device.
[0145] After obtaining the scores corresponding to the representations of the various picture vectors in the model training data of the first edge node device based on the foregoing content, the weight values corresponding to the representations of the various picture vectors in the model training data of the first edge node device can be determined according to the scores corresponding to the representations of the various picture vectors in the model training data of the first edge node device. In an optional implementation, the scores corresponding to the representations of the various picture vectors in the model training data of the first edge node device can be normalized using a softmax function to obtain the weight values corresponding to the representations of the various picture vectors in the model training data of the first edge node device.
[0146] Normalization processing may refer to dividing the scores corresponding to the image vector representations in the model training data of the first edge node device into a unified range, so that the image vector representations in the model training data of each edge node device are comparable, which may be specifically expressed as:
[0147] α (k,1) ,α (k,2) ,…,α (k,c) =softmax(s (k,1) ,s (k,2) ,…,s (k,c) ), α∈[0,1] Formula 9
[0148] Where c is the number of edge node devices, s (k,c) is the score corresponding to the k-th image vector in the model training data of the edge node device, α (k,c) The k-th image vector in the model training data of the edge node device represents the corresponding weight value, and there is a corresponding relationship between the score and the weight value.
[0149] In some embodiments, if the edge node device is a type 2 edge node device, s (k,c)is the score corresponding to the kth text vector in the model training data of the edge node device of type 2, α (k,c) The k-th text vector in the model training data of the edge node device of type 2 represents the corresponding weight value, and there is a corresponding relationship between the score and the weight value.
[0150] In some embodiments, if the edge node device is a type 3 edge node device, s (k,c) The k-th image vector in the model training data of the type 3 edge node device represents the corresponding score, the k-th text vector in the model training data of the type 3 edge node device represents the corresponding score, α (k,c) The k-th image vector in the model training data of the edge node device represents the corresponding weight value, and the k-th text vector in the model training data of the edge node device represents the corresponding weight value, and there is a corresponding relationship between the score and the weight value.
[0151] S303. Cluster the image vector representations in the model training data of the multiple edge node devices according to the weight values corresponding to the image vector representations in the model training data of the multiple edge node devices to obtain clustered image vector representations corresponding to the images in the public data set.
[0152] In an optional implementation, taking the first picture in the public data set as an example, the clustered picture vector representation corresponding to the first picture can be determined by the following steps:
[0153] S3031. Obtain a weight value corresponding to the picture vector representation of the first picture in the model training data of multiple edge node devices.
[0154] S3032. Perform weighted summation on the image vector representations of the first image in the model training data of the multiple edge node devices according to the weight values corresponding to the image vector representations of the first image in the model training data of the multiple edge node devices to obtain a clustered image vector representation corresponding to the first image.
[0155] Among them, clustering can mean that for the first picture of the public data set, there is a picture vector representation corresponding to the picture generated by the edge node device, and these picture vector representations are classified together to represent the first picture corresponding to the public data set, so that the central node device can use the clustered picture vector representation to train the global model.
[0156] Among them, the clustered picture vector is represented as follows Figure 2 In formula 3 of S206 of the embodiment, the clustered picture vector representation corresponding to the first picture can be expressed as i (k) ,i (k)The clustering results of the image vector representation generated by all type 1 edge node devices for the k-th image in the public dataset, where k is between [1, n] and n is the total number of images in the public dataset.
[0157] S304: Train the global model according to each picture in the public data set and the clustered picture vector representation corresponding to each picture to update the model parameters of the global model.
[0158] Among them, training the global model can refer to completing the process of updating the model parameters of the global model, and updating the model parameters of the global model can refer to adjusting the model parameters of the global model according to each picture in the public data set and the clustered picture vector representation corresponding to each picture, so as to better fit the correspondence between each picture in the public data set and the clustered picture vector representation corresponding to each picture, so as to make the training effect of the global model better.
[0159] The model training method of the present application presets conditions and selects different aggregation methods under different conditions based on whether the conditions are met, thereby avoiding the model from falling into the global optimal situation and improving the model training effect.
[0160] Figure 4 A flow chart of another model training method provided in this application, which can be applied to Figure 1 The edge node device of type 1 shown in the figure has a local model deployed on the edge node device of type 1, which is used to recognize images. Figure 4 The edge node devices in the embodiments are all type 1 edge node devices.
[0161] It should also be noted that the training method of the local model in the type 3 edge node device can refer to the following embodiment, and the implementation principle of obtaining n picture vector representations is similar to the following embodiment.
[0162] like Figure 4 As shown, the training method includes:
[0163] S401. Train the local model of the edge node device according to the model training data from the central node device to obtain an updated local model.
[0164] Specifically, each type of edge node device uses the vector representation of the image and the vector representation of the text of each public data set generated by the central node device, as well as the local data set of the edge node device, to perform inter-modal contrast learning and intra-modal contrast learning on the model of the edge node device, so as to update the local model. Among them, intra-modal contrast learning can refer to, for example, the edge node device of type 1, where the vector representation of image A generated for the public data set and the vector representation of image A generated by the central node device have a corresponding relationship; inter-modal contrast learning can refer to, for example, the edge node device of type 1, where the vector representation of image A generated for the public data set and the vector representation of text A corresponding to image A generated by the central node device have a corresponding relationship.
[0165] S402: Input n pictures in the public data set into the updated local model in sequence to obtain n picture vector representations corresponding to the n pictures.
[0166] S403: Send model training data to the central node device, where the model training data includes n picture vector representations.
[0167] The local model training method provided in this application uses a local model for training, provides the central node with image vector representations corresponding to the public data set generated by the local model, and enables the global model to obtain image vector representations corresponding to the public data set generated by multiple edge nodes, thereby improving the efficiency of global model training and the richness of training data.
[0168] Figure 5 A flow chart of another model training method provided in this application, which can be applied to Figure 1 The edge node device of type 2 shown in the figure has a local model deployed on the edge node device of type 2, which is used to recognize text. Figure 5 The edge node devices in the embodiments are all type 2 edge node devices.
[0169] It should also be noted that the training method of the local model in the type 3 edge node device can refer to the following embodiment, and the implementation principle of obtaining n text vector representations is similar to the following embodiment.
[0170] like Figure 5 As shown, the training method includes:
[0171] S501. Train the local model of the edge node device according to the model training data from the central node device to obtain an updated local model.
[0172] Specifically, each type of edge node device uses the vector representation of each text of the public data set generated by the central node device and the vector representation of the text, as well as the local data set of the edge node device, to perform inter-modal contrast learning and intra-modal contrast learning on the model of the edge node device, so as to update the local model. Among them, intra-modal contrast learning can refer to, for example, the edge node device of type 1, where the vector representation of text A generated for the public data set and the vector representation of text A generated by the central node device have a corresponding relationship; inter-modal contrast learning can refer to, for example, the edge node device of type 1, where the vector representation of text A generated for the public data set and the vector representation of text A corresponding to the text A generated by the central node device have a corresponding relationship.
[0173] S502: Input n texts in the public data set into the updated local model in sequence to obtain n text vector representations corresponding to the n texts.
[0174] S503: Send model training data to the central node device, where the model training data includes n text vector representations.
[0175] The local model training method provided in this application uses a local model for training, provides the central node with the text vector representation corresponding to the public data set generated by the local model, and enables the global model to obtain the text vector representation corresponding to the public data set generated by multiple edge nodes, thereby improving the efficiency of global model training and the richness of training data.
[0176] Figure 6 A schematic diagram of the structure of the model training device provided in this application, such as Figure 6 As shown, the model training device 60 provided in the embodiment of the present application includes: a receiving module 601, a determining module 602, a clustering module 603, and an updating module 604;
[0177] The receiving module 601 is used to receive model training data from multiple edge node devices; the model training data of the edge node device includes n picture vector representations obtained by inputting n pictures in the public data set into the local model of the edge node device respectively, where n is a positive integer greater than 1;
[0178] A determination module 602 is used to determine the weight values corresponding to the respective image vector representations in the model training data of the plurality of edge node devices, respectively, according to the round of current training, the model training data of the plurality of edge node devices, and the model training data of the central node device; the model training data of the central node device includes n text vector representations obtained by inputting the texts corresponding to the n images in the public data set into the global model respectively;
[0179] The determination module 602 is further used to determine the weight value corresponding to each image vector representation in the model training data of the plurality of edge node devices according to the round of the current training, the model training data of the plurality of edge node devices, and the model training data of the central node device, including:
[0180] If the round of this training meets the preset conditions, the weight values corresponding to the image vectors in the model training data of the multiple edge node devices are determined according to the model training data of the multiple edge node devices, the model training data of the central node device and the round of this training.
[0181] The determination module 602 is further configured to preset a condition including: the logarithm of the number of rounds of the current training with base 2 is a positive integer.
[0182] The determination module 602 is further used to determine the weight value corresponding to each image vector representation in the model training data of the plurality of edge node devices, according to the model training data of the plurality of edge node devices, the model training data of the central node device, and the round of the current training, including:
[0183] Taking the k-th image vector representation in the model training data of the first edge node device as an example, the k-th image vector representation corresponds to the k-th image in the public data set, and n text vector representations are obtained by respectively inputting n texts into the global model from the model training data of the central node device; k is between [1, n], and n texts correspond to n images one by one;
[0184] Determine a score corresponding to the k-th image vector representation according to the k-th image vector representation and the n text vector representations;
[0185] Obtain scores corresponding to remaining picture vector representations except the k-th picture vector representation in the model training data of the first edge node device;
[0186] According to the scores corresponding to the representations of the respective picture vectors in the model training data of the first edge node device and the round number of this round of training, the weight values corresponding to the representations of the respective picture vectors in the model training data of the first edge node device are determined.
[0187] The determination module 602 is further used to determine the weight value corresponding to each image vector representation in the model training data of the plurality of edge node devices according to the round of the current training, the model training data of the plurality of edge node devices, and the model training data of the central node device, including:
[0188] If the current round of training does not meet the preset conditions, the weight values corresponding to the image vector representations in the model training data of the multiple edge node devices are determined respectively according to the model training data of the multiple edge node devices and the model training data of the central node device.
[0189] The determination module 602 is further used to determine the weight value corresponding to each image vector representation in the model training data of the plurality of edge node devices according to the model training data of the plurality of edge node devices and the model training data of the central node device, including:
[0190] Taking the k-th image vector representation in the model training data of the first edge node device as an example, the k-th image vector representation corresponds to the k-th image in the public data set, and n text vector representations are obtained by respectively inputting n texts into the global model from the model training data of the central node device; k is between [1, n], and n texts correspond to n images one by one;
[0191] Determine a score corresponding to the k-th image vector representation according to the k-th image vector representation and the n text vector representations;
[0192] Obtain scores corresponding to remaining picture vector representations except the k-th picture vector representation in the model training data of the first edge node device;
[0193] According to the scores corresponding to the representations of the respective picture vectors in the model training data of the first edge node device, the weight values corresponding to the representations of the respective picture vectors in the model training data of the first edge node device are determined.
[0194] A clustering module 603 is used to cluster the image vector representations in the model training data of the plurality of edge node devices according to the weight values corresponding to the image vector representations in the model training data of the plurality of edge node devices, and obtain the clustered image vector representations corresponding to the images in the public data set;
[0195] The clustering module 603 is further used to cluster the image vector representations in the model training data of the multiple edge node devices according to the weight values corresponding to the image vector representations in the model training data of the multiple edge node devices, and obtain the clustered image vector representations corresponding to the images in the public data set, including:
[0196] Taking the first picture in the public data set as an example, obtaining a weight value corresponding to the picture vector representation of the first picture in the model training data of multiple edge node devices;
[0197] According to the weight values corresponding to the image vector representations of the first image in the model training data of the multiple edge node devices, the image vector representations of the first image in the model training data of the multiple edge node devices are weighted summed to obtain the clustered image vector representation corresponding to the first image.
[0198] The updating module 604 is used to train the global model according to each picture in the public data set and the clustered picture vector representation corresponding to each picture, so as to update the model parameters of the global model.
[0199] Figure 7 A schematic diagram of the structure of the electronic device provided in this application, such as Figure 7 As shown, the electronic device 70 provided in the embodiment of the present application includes: at least one processor 701 and a memory 702. Optionally, the device 70 also includes a communication component 703. The processor 701, the memory 702 and the communication component 703 are connected via a bus 704.
[0200] In a specific implementation process, at least one processor 701 executes the computer-executable instructions stored in the memory 702, so that at least one processor 701 executes the above method.
[0201] The specific implementation process of the processor 701 can be found in the above method embodiment, and its implementation principle and technical effect are similar, so this embodiment will not be repeated here.
[0202] In the above embodiments, it should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.
[0203] The memory may include a high-speed memory (Random Access Memory, RAM), and may also include a non-volatile memory (Non-volatile Memory, NVM), such as at least one disk memory.
[0204] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.
[0205] The present application also provides a computer program product, including a computer program, which implements the above method when executed by a processor.
[0206] The present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the above method is implemented.
[0207] The above-mentioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general or special-purpose computer.
[0208] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.
[0209] It should be further noted that, although the various steps in the flowchart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
[0210] It should be understood that the above-mentioned device embodiments are only illustrative, and the device of the present application can also be implemented in other ways. For example, the division of units / modules in the above-mentioned embodiments is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.
[0211] In addition, unless otherwise specified, each functional unit / module in each embodiment of the present application may be integrated into one unit / module, each unit / module may exist physically separately, or two or more units / modules may be integrated together. The above-mentioned integrated unit / module may be implemented in the form of hardware or in the form of a software program module.
[0212] If the integrated unit / module is implemented in the form of hardware, the hardware may be a digital circuit, an analog circuit, etc. The physical implementation of the hardware structure includes but is not limited to transistors, memristors, etc. If not specifically stated, the processor may be any appropriate hardware processor, such as a CPU, a GPU, an FPGA, a DSP, an ASIC, etc. If not specifically stated, the storage unit may be any appropriate magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory RRAM (Resistive Random Access Memory), a dynamic random access memory DRAM (Dynamic Random Access Memory), a static random access memory SRAM (Static Random-Access Memory), an enhanced dynamic random access memory EDRAM (Enhanced Dynamic Random Access Memory), a high-bandwidth memory HBM (High-Bandwidth Memory), a hybrid memory cube HMC (Hybrid Memory Cube), etc.
[0213] If the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a memory and includes several instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0214] In the above embodiments, the description of each embodiment has its own emphasis. For parts not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0215] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0216] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A model training method, characterized in that: Applied to a central node device, the central node device is deployed with a global model, and the global model is used to recognize pictures and texts; the method includes: Receiving model training data from a plurality of edge node devices; the model training data of the edge node device comprises n picture vector representations obtained by inputting n pictures in a public data set into a local model of the edge node device respectively, where n is a positive integer greater than 1; Determine the weight values corresponding to the respective image vector representations in the model training data of the plurality of edge node devices according to the round of current training, the model training data of the plurality of edge node devices, and the model training data of the central node device; the model training data of the central node device includes n text vector representations obtained by inputting the texts corresponding to the n images in the public data set into the global model respectively; Clustering the image vector representations in the model training data of the plurality of edge node devices according to the weight values corresponding to the image vector representations in the model training data of the plurality of edge node devices to obtain clustered image vector representations corresponding to the images in the public data set; The global model is trained according to each picture in the public data set and the clustered picture vector representation corresponding to each picture to update the model parameters of the global model.
2. The method according to claim 1, characterized in that: The step of determining, according to the round of the current training, the model training data of the plurality of edge node devices, and the model training data of the central node device, the weight values corresponding to the representations of the respective picture vectors in the model training data of the plurality of edge node devices include: If the round of this training meets the preset conditions, the corresponding weight values represented by each image vector in the model training data of the multiple edge node devices are determined respectively according to the model training data of the multiple edge node devices, the model training data of the central node device and the round of this training.
3. The method according to claim 2, characterized in that The preset condition includes: the logarithm of the number of rounds of the current round of training with base 2 is a positive integer.
4. The method according to claim 2, characterized in that: The step of determining, according to the model training data of the plurality of edge node devices, the model training data of the central node device, and the round of the current training, the weight values corresponding to the representations of the respective picture vectors in the model training data of the plurality of edge node devices include: Taking the k-th picture vector representation in the model training data of the first edge node device as an example, the k-th picture vector representation corresponds to the k-th picture in the public data set, and n text vector representations are obtained after n texts are obtained from the model training data of the central node device and input into the global model respectively; k is between [1, n], and the n texts correspond to the n pictures one by one; Determining a score corresponding to the k-th image vector representation according to the k-th image vector representation and the n text vector representations; Obtain scores corresponding to remaining picture vector representations other than the k-th picture vector representation in the model training data of the first edge node device; According to the scores corresponding to the representations of the respective picture vectors in the model training data of the first edge node device and the round number of the current training, the weight values corresponding to the representations of the respective picture vectors in the model training data of the first edge node device are determined.
5. The method according to claim 1, characterized in that The clustering of each picture vector representation in the model training data of the plurality of edge node devices according to the weight value corresponding to each picture vector representation in the model training data of the plurality of edge node devices to obtain the clustered picture vector representation corresponding to each picture in the public data set includes: Taking the first picture in the public data set as an example, obtaining a weight value corresponding to the picture vector representation of the first picture in the model training data of the multiple edge node devices; According to the weight value corresponding to the picture vector representation of the first picture in the model training data of the multiple edge node devices, the picture vector representation of the first picture in the model training data of the multiple edge node devices is weighted summed to obtain the clustered picture vector representation corresponding to the first picture.
6. The method according to claim 1, characterized in that The step of determining, according to the round of the current training, the model training data of the plurality of edge node devices, and the model training data of the central node device, the weight values corresponding to the representations of the respective picture vectors in the model training data of the plurality of edge node devices include: If the round of training does not meet the preset conditions, the weight values corresponding to the image vectors in the model training data of the multiple edge node devices are determined respectively according to the model training data of the multiple edge node devices and the model training data of the central node device.
7. The method according to claim 6, characterized in that The step of determining, according to the model training data of the plurality of edge node devices and the model training data of the central node device, weight values corresponding to the representations of the respective picture vectors in the model training data of the plurality of edge node devices respectively includes: Taking the k-th picture vector representation in the model training data of the first edge node device as an example, the k-th picture vector representation corresponds to the k-th picture in the public data set, and n text vector representations are obtained after n texts are obtained from the model training data of the central node device and input into the global model respectively; k is between [1, n], and the n texts correspond to the n pictures one by one; Determining a score corresponding to the k-th image vector representation according to the k-th image vector representation and the n text vector representations; Obtain scores corresponding to remaining picture vector representations other than the k-th picture vector representation in the model training data of the first edge node device; According to the scores corresponding to the respective picture vector representations in the model training data of the first edge node device, the weight values corresponding to the respective picture vector representations in the model training data of the first edge node device are determined.
8. A model training device, characterized in that: Applied to central node devices, including: A receiving module, configured to receive model training data from a plurality of edge node devices; the model training data of the edge node device comprises n picture vector representations obtained by inputting n pictures in a public data set into a local model of the edge node device respectively, where n is a positive integer greater than 1; A determination module, used to determine the weight values corresponding to the respective image vector representations in the model training data of the plurality of edge node devices, respectively, according to the round of this round of training, the model training data of the plurality of edge node devices, and the model training data of the central node device; the model training data of the central node device includes n text vector representations obtained by inputting the texts corresponding to the n images in the public data set into the global model respectively; A clustering module, configured to cluster the image vector representations in the model training data of the plurality of edge node devices according to the weight values corresponding to the image vector representations in the model training data of the plurality of edge node devices, and obtain clustered image vector representations corresponding to the images in the public data set; An updating module is used to train the global model according to each picture in the public data set and the clustered picture vector representation corresponding to each picture, so as to update the model parameters of the global model.
9. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 7 when executed by a processor.
Citation Information
Patent Citations
Classification model training method and device for automatic question-answering system and automatic question-answering method and device
CN112287089A
Multi-modal federal learning training method and device
CN116386058A
Federal global model training method and device
CN116843038A
