A model training method, apparatus, device, and medium for edge devices.
By using an improved fireworks algorithm to select the optimal client combination for local model training in edge devices, the problem of low model training efficiency in traditional methods is solved, and efficient edge device model training and accuracy improvement are achieved.
Patent Information
- Application Number
- CN202210067014.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-20
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2042-01-20
AI Technical Summary
Traditional centralized deep neural network training methods are limited by cloud computing power and data encryption requirements in edge devices, resulting in low model training efficiency and difficulty in guaranteeing model accuracy.
An improved fireworks algorithm is used to select the optimal client combination in edge devices for local model training. Training efficiency is improved by splitting and aggregating. Chaotic mapping and Gaussian mutation sparks are used to optimize population search, thereby achieving efficient training of local models and improved accuracy of global models.
Efficient training of large models was achieved in a limited edge network, improving model training accuracy and optimizing resource allocation and aggregation of training results, thus ensuring the high quality of the final model.
Smart Images

Figure CN114519417B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of deep learning technology, and in particular to a model training method, apparatus, device, and medium for edge devices. Background Technology
[0002] With the emergence of the Internet of Things (IoT), massive amounts of data are generated at the network edge. Deep Neural Networks (DNNs) are being trained on vast amounts of data to significantly improve their usability. However, traditional centralized DNN training methods require collecting large amounts of raw data from network nodes, uploading the collected data to the cloud, and then training the model entirely in the cloud. This approach places significant limitations on the computing power of the cloud and the scale of the model. Furthermore, since all data is aggregated in the cloud, there are high requirements for the cloud's data encryption capabilities. Summary of the Invention
[0003] This invention provides a model training method, apparatus, device, and medium for edge devices, which can improve the model training accuracy of edge devices.
[0004] To achieve the above objectives, in a first aspect, embodiments of the present invention provide a model training method for an edge device, the method being applied to a server, comprising:
[0005] Obtain the model parameters of the model to be trained;
[0006] Based on the improved fireworks algorithm, an optimal group of clients is selected, and the model parameters are sent to each client in the group according to a preset splitting method, so that each client can train the local model corresponding to the client according to the corresponding model parameters.
[0007] Obtain the locally trained model and its corresponding model parameters sent by the client, and aggregate the locally trained model and its corresponding parameters to obtain the globally trained model.
[0008] When it is determined that the first preset iteration termination condition is not met, the process returns to the improved fireworks algorithm, selects an optimal group of clients, and sends the model parameters to each client in the group according to a preset splitting method, so that each client can train the local model corresponding to the client based on the corresponding model parameters.
[0009] As one optional embodiment, the improved fireworks algorithm selects an optimal group of clients and sends the model parameters to each client in the group according to a preset splitting method, so that each client trains its corresponding local model based on the model parameters, including:
[0010] A set of fireworks of a specified population size is generated based on a pre-defined chaotic mapping method, and the fitness value of each of the fireworks is calculated.
[0011] The number of explosion sparks for each firework is calculated based on its fitness value, and the number of explosion sparks is limited.
[0012] The explosion radius of each firework is calculated based on its fitness value, and the minimum value among the explosion radii is detected.
[0013] Explosion sparks and Gaussian mutation sparks are generated based on the number of explosion sparks and the explosion radius;
[0014] Based on the fireworks, the explosion sparks, and the Gaussian mutation sparks, a new candidate population is obtained, and the current optimal value is obtained based on the candidate population;
[0015] Determine whether the second preset iteration termination condition is met. If so, stop the iteration and send the split model parameters to each client in the group according to the preset splitting method.
[0016] If not, a new firework is obtained according to the preset selection rules, and the process returns to the step of calculating the number of explosion sparks and the explosion radius of each firework based on its fitness value.
[0017] As one optional embodiment, the formula for calculating the number of explosion sparks for each firework based on its fitness value is as follows:
[0018]
[0019] Among them, S i Let F(w) be the number of sparks generated by the explosion of firework i. i ) represents the fitness value of firework i, and y represents the fitness value of firework i. min =min(F(w) i )), y max =maX(F(w i )), ε is a constant.
[0020] As one optional embodiment, the formula for calculating the blast radius of each firework based on its fitness value is as follows:
[0021]
[0022] Among them, R i Let R be the explosion radius of firework i, R be the initial maximum explosion radius, Gen be the current iteration number, and MaxGen be the maximum iteration number.
[0023] As one optional embodiment, after obtaining the trained local model and its corresponding model parameters sent by the client, and aggregating the local model and its corresponding parameters to obtain the trained global model, the method further includes:
[0024] The global loss value for this training is calculated based on the global model, and the global loss value is used as the fitness value of the improved fireworks algorithm.
[0025] This invention provides a model training apparatus for edge devices, comprising:
[0026] The model parameter acquisition module is used to obtain the model parameters of the model to be trained.
[0027] The model parameter sending module is used to select an optimal group of clients based on the improved fireworks algorithm, and send the model parameters to each client in the group according to a preset splitting method, so that each client can train the local model corresponding to the client according to the corresponding model parameters.
[0028] The global model aggregation module is used to obtain the trained local model and its corresponding model parameters sent by the client, and aggregate the local model and its corresponding parameters to obtain the trained global model.
[0029] The model training iteration module is used to return to the improved fireworks algorithm when it is determined that the first preset iteration termination condition is not met, select a group of optimal clients, and send the model parameters to each client in the group according to the preset splitting method, so that each client can train the local model corresponding to the client according to the corresponding model parameters.
[0030] As one optional embodiment, the model parameter sending module, based on an improved fireworks algorithm, selects an optimal group of clients and sends the model parameters to each client in the group according to a preset splitting method, so that each client can train its corresponding local model based on the corresponding model parameters, including:
[0031] A set of fireworks of a specified population size is generated based on a pre-defined chaotic mapping method, and the fitness value of each of the fireworks is calculated.
[0032] The number of explosion sparks for each firework is calculated based on its fitness value, and the number of explosion sparks is limited.
[0033] The explosion radius of each firework is calculated based on its fitness value, and the minimum value among the explosion radii is detected.
[0034] Explosion sparks and Gaussian mutation sparks are generated based on the number of explosion sparks and the explosion radius;
[0035] Based on the fireworks, the explosion sparks, and the Gaussian mutation sparks, a new candidate population is obtained, and the current optimal value is obtained based on the candidate population;
[0036] Determine whether the second preset iteration termination condition is met. If so, stop the iteration and send the split model parameters to each client in the group according to the preset splitting method.
[0037] If not, a new firework is obtained according to the preset selection rules, and the process returns to the step of calculating the number of explosion sparks and the explosion radius of each firework based on its fitness value.
[0038] This invention provides a terminal device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements the model training method for the edge device described in any of the above embodiments.
[0039] This invention provides a computer-readable storage medium including a stored computer program, wherein the computer program, when running, controls the device where the computer-readable storage medium is located to execute the model training method described in any of the above embodiments.
[0040] Compared with existing technologies, the model training method, apparatus, device and medium for edge devices provided in this embodiment of the invention can select the best combination of clients participating in training during each training session based on an improved fireworks algorithm to ensure the training accuracy of the final model. In addition, by splitting the global model on the cloud platform server into multiple local models through a splitting method, the models are distributed to different clients for training, and the training results are sent to the server for aggregation. This achieves efficient training of large models in a limited edge network, thereby further improving the model training accuracy of edge devices. Attached Figure Description
[0041] Figure 1 This is a flowchart illustrating a model training method for an edge device provided in an embodiment of the present invention;
[0042] Figure 2 This is a schematic diagram of the structure of a model training device for an edge device provided in an embodiment of the present invention;
[0043] Figure 3 This is a schematic diagram of the structure of a terminal device provided in an embodiment of the present invention. Detailed Implementation
[0044] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0045] In a first aspect, embodiments of the present invention provide a model training method for edge devices, wherein the method is applied to a server, see [link to relevant documentation]. Figure 1 This is a flowchart illustrating a model training method for edge devices provided in an embodiment of the present invention, the method comprising steps S11 to S14:
[0046] S11. Obtain the model parameters of the model to be trained.
[0047] Specifically, the server defines the structure of all models to be trained by clients, determines the hyperparameters of local and global models (such as the learning rate of the optimizer or neural network), and broadcasts the models and parameters to the clients. In the first round, the broadcast model is not trained, while in subsequent rounds, the server broadcasts a model aggregated from the local models trained by the clients.
[0048] S12. Based on the improved fireworks algorithm, select an optimal group of clients and send the model parameters to each client in the group according to a preset splitting method, so that each client can train the local model corresponding to the client according to the corresponding model parameters.
[0049] S13. Obtain the local model that has been trained and its corresponding model parameters sent by the client, and aggregate the local model and its corresponding parameters to obtain the global model that has been trained.
[0050] Understandably, each client trains a local model on its own, and after each client completes its training, it shares its trained model with the server.
[0051] It should be noted that the training time of each server can be asynchronous. After the client finishes training, it can connect to the server independently without waiting for all local models to finish training.
[0052] S14. When it is determined that the first preset iteration termination condition is not met, return to the improved fireworks algorithm, select a group of optimal clients, and send the model parameters to each client in the group according to the preset splitting method, so that each client can train the local model corresponding to the client according to the corresponding model parameters.
[0053] Understandably, the server aggregates the local models trained by the clients to construct a global model, calculates the global loss as the fitness function of the Fireworks algorithm, and determines whether the conditions are met. If the conditions are met, the next training is performed; if the conditions are not met, the process returns to step S12 for another iteration to select a better client combination.
[0054] Furthermore, it's understandable that in existing technologies, with the development of distributed strategies, the entire model is being split into smaller parts. Local models are trained separately by clients, and then the parameters of these local models are periodically aggregated onto a centralized node. The global model is then updated using a federated averaging algorithm. By performing local training and parameter aggregation over multiple federated epochs, a globally accurate DNN model is obtained. However, this distributed training method still faces challenges in ensuring the accuracy of the global model, and the issues of client selection and resource allocation during training remain largely unresolved.
[0055] To address this, this invention proposes a novel strategy for collaborative training of edge devices based on an improved fireworks algorithm. Compared to existing technologies, the model training method for edge devices provided in this invention, based on the improved fireworks algorithm, optimizes the selection of client combinations participating in training during each training iteration to ensure the training accuracy of the final model. Furthermore, by splitting the global model on the cloud platform server into multiple local models and distributing them to different clients for training, the training results are sent to the server for aggregation. This achieves efficient training of large models within a limited edge network, thereby further improving the model training accuracy of edge devices.
[0056] As one optional embodiment, step S12 includes:
[0057] S121. Generate a set of fireworks with a specified population size based on a preset chaotic mapping method, and calculate the fitness value of each of the fireworks.
[0058] S122. Calculate the number of explosion sparks for each of the fireworks based on the fitness value of each of the fireworks, and limit the number of explosion sparks;
[0059] S123. Calculate the explosion radius of each firework based on the fitness value of each firework, and detect the minimum value among the explosion radii;
[0060] S124. Generate explosion sparks and Gaussian mutation sparks according to the number of explosion sparks and the explosion radius;
[0061] S125. Based on the fireworks, the explosion sparks, and the Gaussian mutation sparks, a new candidate population is obtained, and the current optimal value is obtained based on the candidate population.
[0062] S126. Determine whether the second preset iteration termination condition is met. If so, stop the iteration and send the split model parameters to each client in the group according to the preset splitting method.
[0063] S126. If not, then a new firework is obtained according to the preset selection rules, and the process returns to the step of calculating the number of explosion sparks and the explosion radius of each firework based on the fitness value of each firework.
[0064] Specifically, an elite random selection operator is used to avoid significant computational overhead. Here, the best firework discovered to date is used as a new individual for the next iteration, while other firework is randomly selected from the population.
[0065] It's worth noting that collaborative training on edge devices and uploading the final results to the cloud platform allows for model updates to be shared with the server, thus aggregating and building a global model. This provides optimal training results for edge-device collaborative model training. Furthermore, an improved fireworks algorithm incorporates chaotic mapping during initialization, resulting in a more even and diverse initial population distribution. Limitations on the minimum explosion radius and the number of explosion sparks are added during the explosion phase to enhance the algorithm's retrieval capabilities and prevent it from getting trapped in local optima.
[0066] As one optional embodiment, exemplaryly, step S121 specifically includes:
[0067] Generate a sequence of chaotic variables C of length D with the same population size N using the chaotic mapping equation. x ={cx l ,cx2,...,cx N ), where cx i ={cx i1 ,cx i2 ,…,cx id ,…,cx iD}, N is the population size, and D is the dimension of the fireworks. Then, according to the following formula (1), the chaotic variable cx d = (0, 1) maps to (L) d U d This expands the traversal of chaotic motion from (0, 1) to (L). d U d This generates an initial firework of size N, x = {x1, x2, ..., x...}. N}. Where x i ={xi1 ,x i2 ,…,x id ,…,x iD},(L d U d The variable interval of the optimization problem is the client's encoding interval. In this invention, all clients are encoded. For example, assuming there are 10 clients available for allocation, these 10 clients are encoded as {'0','1','2',…,'9'}. In this case, the variable interval of the optimization problem is the client's encoding interval.
[0068] As one optional embodiment, exemplaryly, step S122 specifically includes:
[0069] The server's model is split and the client trains the local model. After training, the local model and parameters are sent back to the server for aggregation. After aggregation, the loss of this training is calculated and used as the fitness value of the firework. Then, the global loss of the i-th firework in this firework algorithm iteration, i.e., the fitness, can be defined as F(w i ), where w i The parameters represent the global model.
[0070] It's important to note that the global model contains numerous parameters that need training, say 100. Since each local model needs to train all 100 parameters, and considering the limited data in each local model would result in low accuracy with only 100 parameters, the 100 parameters are divided into 10 parts: 1-10, 11-20, ..., 90-100. The first part (1-10) is sent to clients designated 1-100 for local model training, where these local models primarily optimize parameters 1-10. The second part is sent to clients designated 101-200 for local model training, thus placing each part of the parameters on different clients. The model splitting occurs on the global server, and then each client optimizes its corresponding parameters before uploading them to the global model.
[0071] Furthermore, in the fireworks algorithm, fireworks and the sparks produced by their explosions together constitute the entire fireworks population. Each firework explodes and produces a certain amplitude of sparks. To balance the algorithm's development and exploration capabilities, each firework produces a different number of sparks. Generally, poorer fireworks, i.e., fireworks with lower fitness, have a larger explosion radius and produce fewer sparks; better fireworks, i.e., fireworks with higher fitness, have a smaller explosion radius and produce more sparks. The number of sparks from the explosion of the i-th firework can be calculated, i.e., the formula for calculating the number of sparks from the explosion of each firework based on its fitness value is:
[0072]
[0073] Among them, S i is the number of explosion sparks of firework i, and F(w i ) is the fitness value of firework i, and y min = min(F(w i )), and y max = max(F(w i )), is a constant used to control the number of explosion sparks, and ε is a very small constant used to ensure that the denominator is not zero.
[0074] Furthermore, in order to avoid too many sparks being generated by fireworks with good fitness and too few sparks being generated by fireworks with poor fitness, the number of sparks is restricted by formula (2):
[0075]
[0076] Among them, 0 < a, b < 1 are two constant parameters that limit the population size.
[0077] As one of the optional embodiments,示例性地, step S123 specifically includes:
[0078] In the traditional enhanced fireworks algorithm, the maximum explosion radius is set as a constant, which will weaken the fine search ability in the later stage of the algorithm and result in low solution accuracy of the algorithm. Inspired by the idea of dynamic search, if the maximum explosion radius generally shows a non-linear decreasing trend, it will be beneficial for global search in the early stage of the algorithm and local search in the later stage, achieving the effect of adaptive acceleration. In the present invention, the maximum explosion radius is set as the simulated annealing factor. Let R be the initial maximum explosion radius, Gen be the current iteration number, and MaxGen be the maximum iteration number. Then the maximum explosion radius of the i-th firework is defined as follows:
[0079]
[0080] Then the explosion radius of the firework with the maximum explosion radius as the simulated annealing factor can be defined as:
[0081]
[0082] Among them, R i is the explosion radius of firework i, R is set as the initial maximum explosion radius, Gen is the current iteration number, and MaxGen is the maximum iteration number.
[0083] Furthermore, in order to avoid the best firework generating explosion fireworks within a small radius, a minimum radius check strategy is performed on the fireworks located at (almost) the same position as itself. For each dimension k, the bounds of the explosion radius are as follows:
[0084]
[0085] Here, in each iteration... The value of can be obtained from the nonlinear decreasing function of equation (6).
[0086]
[0087] Among them, A ibit and A final Eval represents the initial and final minimum amplitudes, respectively. max It represents the maximum number of times the function is evaluated, and t represents the current number of evaluations.
[0088] It is worth noting that by adopting the fireworks algorithm and adaptive explosion radius, the algorithm will benefit global search in the early stage and local search in the later stage, thereby improving the retrieval and search capabilities of the algorithm and speeding up the algorithm process.
[0089] As one optional embodiment, exemplaryly, step S124 specifically includes:
[0090] To maintain population diversity, m(m) ≤ N fireworks in the population are randomly selected and mutated in k dimensions. To avoid wasting search resources on test functions where the optimal value is not at the origin, a novel Gaussian mutation is used, defined as follows:
[0091] x ik =x ik +g*(x Bk -x ik (7)
[0092] Where, x Bk The optimal location for the currently discovered fireworks / explosion spark is given by g = N(0,1).
[0093] When the position of a new spark exceeds the search range of dimension k, the new spark will be mapped to another position within the current firework algorithm's search range, as shown below:
[0094] x ik =x LB,k +rand(x UB,k -x LB,k (8)
[0095] Where, x LB,k and x UB,k These are the upper and lower bounds of the search space in k dimensions, respectively.
[0096] As one optional embodiment, after step S13, the method further includes:
[0097] The global loss value for this training is calculated based on the global model, and the global loss value is used as the fitness value of the improved fireworks algorithm.
[0098] See Figure 2 This is a schematic diagram of the structure of a model training device for an edge device provided in an embodiment of the present invention. The embodiment of the present invention provides a model training device for an edge device, comprising:
[0099] Model parameter acquisition module 21 is used to acquire the model parameters of the model to be trained;
[0100] The model parameter sending module 22 is used to select an optimal group of clients based on the improved fireworks algorithm, and send the model parameters to each client in the group according to a preset splitting method, so that each client can train the local model corresponding to the client according to the corresponding model parameters.
[0101] The global model aggregation module 23 is used to obtain the local model that has been trained and its corresponding model parameters sent by the client, and to aggregate the local model and its corresponding parameters to obtain the global model that has been trained.
[0102] The model training iteration module 24 is used to return to the improved fireworks algorithm when it is determined that the first preset iteration termination condition is not met, select a group of optimal clients, and send the model parameters to each client in the group according to the preset splitting method, so that each client can train the local model corresponding to the client according to the corresponding model parameters.
[0103] Compared with existing technologies, the model training device for edge devices provided in this embodiment of the invention can select the best combination of clients participating in training during each training session based on an improved fireworks algorithm to ensure the training accuracy of the final model. In addition, by splitting the global model on the cloud platform server into multiple local models through a splitting method, the models are distributed to different clients for training, and the training results are sent to the server for aggregation. This achieves efficient training of large models in a limited edge network, thereby further improving the model training accuracy of edge devices.
[0104] As one optional embodiment, the model parameter sending module 22 includes:
[0105] A set of fireworks of a specified population size is generated based on a pre-defined chaotic mapping method, and the fitness value of each of the fireworks is calculated.
[0106] The number of explosion sparks for each firework is calculated based on its fitness value, and the number of explosion sparks is limited.
[0107] The explosion radius of each firework is calculated based on its fitness value, and the minimum value among the explosion radii is detected.
[0108] Explosion sparks and Gaussian mutation sparks are generated based on the number of explosion sparks and the explosion radius;
[0109] Based on the fireworks, the explosion sparks, and the Gaussian mutation sparks, a new candidate population is obtained, and the current optimal value is obtained based on the candidate population;
[0110] Determine whether the second preset iteration termination condition is met. If so, stop the iteration and send the split model parameters to each client in the group according to the preset splitting method.
[0111] If not, a new firework is obtained according to the preset selection rules, and the process returns to the step of calculating the number of explosion sparks and the explosion radius of each firework based on its fitness value.
[0112] As one optional embodiment, exemplaryly, the method based on a preset chaotic mapping to generate a set of fireworks of a specified population size, and calculating the fitness value of each of the fireworks specifically includes:
[0113] Generate a sequence of chaotic variables C of length D with the same population size N using the chaotic mapping equation. x ={cx1,cx2,…,cx N}, where cx i ={cx i1 ,cx i2 ,…,cx id ,…,cx iD}, N is the population size, and D is the dimension of the fireworks. Then, the chaotic variable cx is calculated according to the following formula (9). d = (0, 1) maps to (L) d U d This expands the traversal of chaotic motion from (0, 1) to (L). d U d This generates an initial firework of size N, x = {x1, x2, ..., x...}. N}. Where x i ={x i1 ,x i2 ,…,x id ,…,x iD},(L d U dThe variable interval of the optimization problem is the client's encoding interval. In this invention, all clients are encoded. For example, assuming there are 10 clients available for allocation, these 10 clients are encoded as {'0','1','2',…,'9'}. In this case, the variable interval of the optimization problem is the client's encoding interval.
[0114] As one optional embodiment, exemplaryly, the step of calculating the number of explosion sparks for each firework based on its fitness value and limiting the number of explosion sparks specifically includes:
[0115] The server's model is split and the client trains the local model. After training, the local model and parameters are sent back to the server for aggregation. After aggregation, the loss of this training is calculated and used as the fitness value of the firework. Then, the global loss of the i-th firework in this firework algorithm iteration, i.e., the fitness, can be defined as F(w i ), where w i The parameters represent the global model.
[0116] The global model contains numerous parameters that need to be trained, such as 100 parameters. Since each local model needs to train on 100 parameters, and considering the limited data available to each local model, the accuracy of training with only 100 parameters would be low. Therefore, the 100 parameters are divided into 10 parts: 1-10, 11-20, ..., 90-100. The first part (1-10) is sent to clients designated 1-100 for local model training, where these models primarily optimize parameters 1-10. The second part is sent to clients designated 101-200 for local model training, and so on, with each part of the parameters trained on different clients. The model splitting is performed on the global server, and then each client optimizes its corresponding parameters before uploading them to the global model.
[0117] Furthermore, in the fireworks algorithm, fireworks and the sparks produced by their explosions together constitute the entire fireworks population. Each firework explodes and produces a certain amplitude of sparks. To balance the algorithm's development and exploration capabilities, each firework produces a different number of sparks. Generally, poorer fireworks, i.e., fireworks with lower fitness, have a larger explosion radius and produce fewer sparks; better fireworks, i.e., fireworks with higher fitness, have a smaller explosion radius and produce more sparks. The number of sparks from the explosion of the i-th firework can be calculated, i.e., the formula for calculating the number of sparks from the explosion of each firework based on its fitness value is:
[0118]
[0119] Among them, S iis the number of explosion sparks of firework i, F(w i ) is the fitness value of firework i, y min = min(F(w i )), y max = max(F(w i )), is a constant used to control the number of explosion sparks, and ε is an extremely small constant used to ensure that the denominator is not zero.
[0120] Furthermore, in order to avoid too many sparks being generated by fireworks with good fitness and too few sparks being generated by fireworks with poor fitness, the number of sparks is restricted by formula (2):
[0121]
[0122] where 0 < a, b < 1 are two constant parameters that limit the population size.
[0123] As one of the optional embodiments,示例性, calculating the explosion radius of each firework according to the fitness value of each firework and detecting the minimum value in the explosion radii specifically includes:
[0124] In the traditional enhanced fireworks algorithm, the maximum explosion radius is set as a constant, which will weaken the fine search ability in the later stage of the algorithm and result in low solution accuracy of the algorithm. Inspired by the idea of dynamic search, if the maximum explosion radius generally shows a non-linear decreasing trend, it will be beneficial for global search in the early stage of the algorithm and local search in the later stage, achieving the effect of adaptive acceleration. In this invention, the maximum explosion radius is set as the simulated annealing factor. Let R be the initial maximum explosion radius, Gen be the current iteration number, and MaxGen be the maximum iteration number. Then the maximum explosion radius of the i-th firework is defined as follows:
[0125]
[0126] Then the explosion radius of the firework with the maximum explosion radius as the simulated annealing factor can be defined as:
[0127]
[0128] where R i is the explosion radius of firework i, R is set as the initial maximum explosion radius, Gen is the current iteration number, and MaxGen is the maximum iteration number.
[0129] Furthermore, in order to avoid the best firework generating explosion fireworks within a small radius, the explosion fireworks will make a minimum radius check strategy for the fireworks located (almost) at the same position as itself. For each dimension k, the bounds of the explosion radius are as follows:
[0130]
[0131] Here, in each iteration... The value of can be obtained from the nonlinear decreasing function of equation (6).
[0132]
[0133] Among them, A init and A final Eval represents the initial and final minimum amplitudes, respectively. max It represents the maximum number of times the function is evaluated, and t represents the current number of evaluations.
[0134] It is worth noting that by adopting the fireworks algorithm and adaptive explosion radius, the algorithm will benefit global search in the early stage and local search in the later stage, thereby improving the retrieval and search capabilities of the algorithm and speeding up the algorithm process.
[0135] As one optional embodiment, exemplaryly, the generation of explosion sparks and Gaussian mutation sparks based on the number of explosion sparks and the explosion radius specifically includes:
[0136] To maintain population diversity, m(m) ≤ N fireworks in the population are randomly selected and mutated in k dimensions. To avoid wasting search resources on test functions where the optimal value is not at the origin, a novel Gaussian mutation is used, defined as follows:
[0137] x ik =x ik +g*(x Bk -x ik (15)
[0138] Where, x Bk The optimal location for the currently discovered fireworks / explosion spark is given by g = N(0,1).
[0139] When the position of a new spark exceeds the search range of dimension k, the new spark will be mapped to another position within the current firework algorithm's search range, as shown below:
[0140] X ik =X LB,k +rand(X UB,k -X LB,k (16)
[0141] Where, x LB,k and x UB,k These are the upper and lower bounds of the search space in k dimensions, respectively.
[0142] As one optional embodiment, after the global model aggregation module 23, the device is further configured to:
[0143] The global loss value for this training is calculated based on the global model, and the global loss value is used as the fitness value of the improved fireworks algorithm.
[0144] In addition, it should be noted that the specific implementation schemes and beneficial effects of the various embodiments of the model training device for edge devices provided in the embodiments of the present invention correspond to the specific implementation schemes and beneficial effects of the various embodiments of the model training method for edge devices provided in the embodiments of the present invention, and will not be repeated here.
[0145] This invention provides a terminal device, see [link to relevant documentation]. Figure 3 This is a schematic diagram of the structure of a terminal device provided in an embodiment of the present invention. The terminal device 3 of this embodiment includes: a processor 30, a memory 31, and a computer program stored in the memory 31 and executable on the processor 30. When the processor 30 executes the computer program, it implements the model training method for the edge device described in any of the embodiments of the first aspect above. Alternatively, when the processor 30 executes the computer program, it implements the functions of each module in the above-described device embodiments.
[0146] For example, the computer program may be divided into one or more modules, which are stored in the memory 31 and executed by the processor 30 to complete the present invention. The one or more modules may be a series of computer program instruction segments capable of performing specific functions, which describe the execution process of the computer program in the terminal device 3.
[0147] The terminal device 3 can be a desktop computer, laptop, handheld computer, cloud server, or other computing device. The terminal device 3 may include, but is not limited to, a processor 30 and a memory 31. Those skilled in the art will understand that the schematic diagram is merely an example of a terminal device and does not constitute a limitation on the terminal device. It may include more or fewer components than shown, or combine certain components, or use different components. For example, the terminal device 3 may also include input / output devices, network access devices, buses, etc.
[0148] The processor 30 may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor. The processor 30 is the control center of the terminal device 3, connecting all parts of the terminal device 3 via various interfaces and lines.
[0149] The memory 31 can be used to store the computer programs and / or modules. The processor 30 implements various functions of the terminal device 3 by running or executing the computer programs and / or modules stored in the memory 31 and calling the data stored in the memory 31. The memory 31 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the mobile phone (such as audio data, phonebook, etc.). In addition, the memory 31 may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, memory, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0150] If the modules integrated in the terminal device 3 are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by the processor 30, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electrical carrier signals and telecommunication signals.
[0151] It should be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the device embodiments provided by this invention, the connection relationships between modules indicate that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort.
[0152] This invention provides a computer-readable storage medium including a stored computer program, wherein the computer program, when running, controls the device where the computer-readable storage medium is located to execute the model training method for edge devices as described above.
[0153] Those skilled in the art will understand that modules in the apparatus of the embodiments can be adaptively modified and placed in one or more apparatuses different from that embodiment. Modules or units in the embodiments can be combined into a single module or unit, and further, they can be divided into multiple sub-modules or sub-units. Except where at least some of such features and / or processes or units are mutually exclusive, any combination can be used to combine all features disclosed in this specification (including the accompanying claims, abstract, and drawings) and all processes or units of any method or apparatus so disclosed. Unless expressly stated otherwise, each feature disclosed in this specification (including the accompanying claims, abstract, and drawings) may be replaced by an alternative feature that serves the same, equivalent, or similar purpose.
[0154] It should be noted that the above embodiments are illustrative of the invention and not restrictive, and that those skilled in the art can devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements.
[0155] Furthermore, those skilled in the art will understand that although some embodiments described herein include certain features but not others included in other embodiments, combinations of features from different embodiments are intended to be within the scope of the invention and form different embodiments. For example, in the claims of this invention, any of the claimed embodiments can be used in any combination.
[0156] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A model training method for edge devices, characterized in that, The method is applied to a server and includes: Obtain the model parameters of the model to be trained; Based on the improved fireworks algorithm, an optimal group of clients is selected, and the model parameters are sent to each client in the group according to a preset splitting method, so that each client can train the local model corresponding to the client according to the corresponding model parameters. Obtain the locally trained model and its corresponding model parameters sent by the client, and aggregate the locally trained model and its corresponding parameters to obtain the globally trained model. After obtaining the trained local model and its corresponding model parameters sent by the client, and aggregating the local model and its corresponding parameters to obtain the trained global model, the global loss value of this training is calculated based on the global model, and the global loss value is used as the fitness value of the improved fireworks algorithm. When it is determined that the first preset iteration termination condition is not met, the process returns to the improved fireworks algorithm, selects an optimal group of clients, and sends the model parameters to each client in the group according to the preset splitting method, so that each client can train the local model corresponding to the client according to the corresponding model parameters. The improved fireworks algorithm selects an optimal group of clients and sends the model parameters to each client in the group according to a preset splitting method. This allows each client to train its local model based on the corresponding model parameters. The process includes: generating a set of fireworks of a specified population size based on a preset chaotic mapping method, and calculating the fitness value of each fireworks. Specifically, all clients are encoded, and the traversal range of the chaotic motion is extended to the client's encoding interval to generate initial fireworks. The parameters of the global model are split and trained by different clients respectively. After training, the loss is aggregated to determine the fitness value of each fireworks. The number of explosion sparks for each fireworks is calculated based on its fitness value, and a limit is imposed. The process involves: counting the number of explosion sparks; calculating the explosion radius of each firework based on its fitness value, and detecting the minimum explosion radius; generating explosion sparks and Gaussian mutation sparks based on the number of explosion sparks and the explosion radius; obtaining a new candidate population based on the firework, the explosion sparks, and the Gaussian mutation sparks, and obtaining the current optimal value based on the candidate population; determining whether the second preset iteration termination condition is met; if so, stopping the iteration and sending the split model parameters to each client in the group according to the preset splitting method; if not, obtaining a new firework according to the preset selection rule and returning to the step of calculating the number of explosion sparks and the explosion radius of each firework based on its fitness value.
2. The model training method for edge devices according to claim 1, characterized in that, The formula for calculating the number of explosion sparks for each firework based on its fitness value is as follows: Among them, S i Let F(w) be the number of sparks generated by the explosion of firework i. i ) represents the fitness value of firework i, and y represents the fitness value of firework i. max =max(F(w) i )), ε is a constant.
3. The model training method for edge devices according to claim 1, characterized in that, The explosion radius of each firework is calculated based on its fitness value, including: Let the maximum explosion radius be set as the simulated annealing factor, R as the initial maximum explosion radius, Gen as the current iteration number, and MaxGen as the highest iteration number. Then, the maximum explosion radius of the i-th firework is defined as follows: The maximum explosion radius of fireworks, calculated using the simulated annealing factor, is defined as follows: Among them, y min =min(F(w) i )).
4. A model training device for edge devices, characterized in that, include: The model parameter acquisition module is used to obtain the model parameters of the model to be trained. The model parameter sending module is used to select an optimal group of clients based on the improved fireworks algorithm, and send the model parameters to each client in the group according to a preset splitting method, so that each client can train the local model corresponding to the client according to the corresponding model parameters. The global model aggregation module is used to obtain the trained local model and its corresponding model parameters sent by the client, and aggregate the local model and its corresponding parameters to obtain the trained global model. The global loss calculation module is used to calculate the global loss value for this training based on the global model, and use the global loss value as the fitness value of the improved fireworks algorithm. The model training iteration module is used to return to the improved fireworks algorithm when it is determined that the first preset iteration termination condition is not met, select a group of optimal clients, and send the model parameters to each client in the group according to the preset splitting method, so that each client can train the local model corresponding to the client according to the corresponding model parameters. The model parameter sending module, based on an improved fireworks algorithm, selects an optimal group of clients and sends the model parameters to each client in the group according to a preset splitting method. This allows each client to train its corresponding local model based on the model parameters. The process includes: generating a set of fireworks of a specified population size based on a preset chaotic mapping method, and calculating the fitness value of each fireworks. Specifically, all clients are encoded, and the traversal range of chaotic motion is extended to the client's encoding interval to generate initial fireworks. The parameters of the global model are split and trained by different clients respectively. After training, the loss is aggregated to determine the fitness value of each fireworks. Finally, the number of explosion sparks for each fireworks is calculated based on its fitness value. The process involves: limiting the number of explosion sparks; calculating the explosion radius of each firework based on its fitness value, and detecting the minimum explosion radius; generating explosion sparks and Gaussian mutation sparks based on the number of explosion sparks and the explosion radius; obtaining a new candidate population based on the firework, the explosion sparks, and the Gaussian mutation sparks, and obtaining the current optimal value based on the candidate population; determining whether a second preset iteration termination condition is met; if so, stopping the iteration and sending the split model parameters to each client in the group according to a preset splitting method; if not, obtaining a new firework according to a preset selection rule and returning to the step of calculating the number of explosion sparks and the explosion radius of each firework based on its fitness value.
5. A terminal device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor executes the computer program to implement the model training method for an edge device as described in any one of claims 1 to 3.
6. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored computer program, wherein, when the computer program is executed, it controls the device on which the computer-readable storage medium is located to perform the model training method for an edge device as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Model joint training method and equipment, and storage medium
CN112163675A
Federated learning method for power grid edge computing system and related device thereof
CN113221470A