A federated learning method, device, server and medium based on edge device
Through the federated learning method based on edge devices, the power prediction model is divided and evaluated, and the efficiency problems of edge device cluster determination and power prediction model evaluation in smart grids are solved, and efficient evaluation of power prediction model and energy consumption reduction are achieved.
Patent Information
- Application Number
- CN202410993593.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-24
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2044-07-24
AI Technical Summary
In the training process of the smart grid power prediction model, how to effectively determine the edge equipment of the target cluster and evaluate the power prediction model, the existing method relies on manual evaluation and is cumbersome, affecting efficiency.
Using federated learning method based on edge devices, the cluster is divided by hot coded vectors, and the total power consumption model is generated, the cluster with the minimum total power consumption is marked as the target cluster, and upload instructions are sent to it, local model parameters are aggregated, and the power prediction model is generated and evaluated. .
The evaluation process of the power prediction model is simplified, the overall energy consumption of edge devices is reduced, and the evaluation efficiency of the power prediction model is improved.
Smart Images

Figure CN118551864B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technology, and in particular to a federated learning method, device, server and medium based on edge devices. Background Art
[0002] Smart grid is regarded as the future development direction of power grid. The power forecasting model of smart grid provides an important basis for power companies to formulate reasonable power supply plans by accurately predicting the peak and low periods of power consumption in a certain period of time in the future, as well as the power demand in various regions. This forecasting ability enables power companies to flexibly allocate power resources and ensure the balance between supply and demand, thereby improving the efficiency and reliability of the power system.
[0003] However, during the training process of the power prediction model, a large number of edge devices need to continuously collect, process and transmit data. Therefore, there are many edge devices, and how to determine the edge devices of the target cluster is an urgent problem to be solved. In addition, the existing power prediction model relies on manual evaluation, and the evaluation process is cumbersome, which is not conducive to improving the evaluation efficiency of the power prediction model. Therefore, how to obtain the edge devices of the target cluster and how to evaluate the power prediction model are both urgent problems to be solved. Summary of the invention
[0004] The embodiments of the present application provide a federated learning method, apparatus, server, and medium based on edge devices to solve the above-mentioned technical problems of how to determine the edge devices of the target cluster and how to evaluate the power prediction model.
[0005] In a first aspect, an embodiment of the present application provides a federated learning method based on an edge device, which is applied to a central server of a federated learning system, wherein the central server is connected to a plurality of edge devices, and the central server stores a first global model of the federated learning system, and the federated learning method includes:
[0006] Obtain the hot coding vector uploaded by the edge device, divide the multiple edge devices into different clusters according to different hot coding vectors, and generate the total power consumption corresponding to the cluster according to the selected number of edge devices in the cluster, computing power consumption, transmission power consumption and a preset total power consumption generation model;
[0007] Marking the cluster corresponding to the minimum total power consumption as a target cluster;
[0008] Sending an upload instruction to the plurality of edge devices of the target cluster;
[0009] Acquire local model parameters returned by the edge device based on the upload instruction, aggregate multiple local model parameters to obtain update parameters, modify initial parameters of the first global model to the update parameters, and set the first global model using the update parameters as the second global model;
[0010] Obtaining preset impact features of the target cluster, forming a group of sample data with the preset impact features and the preset power corresponding to the preset impact features, and dividing the multiple groups of sample data into a training set and a test set of the second global model;
[0011] Inputting the preset influencing feature of the training set into the second global model, obtaining the predicted power output by the second global model based on the preset influencing feature, determining whether the loss value between the preset power and the predicted power is less than a preset value, and determining whether the number of training rounds is greater than a preset number of rounds;
[0012] When the loss value is less than the preset value or the number of training rounds is greater than the preset number of rounds, the second global model is set as the power prediction model of the target cluster, the evaluation data of the power prediction model on the test set is obtained, and a model is generated according to the evaluation data and the preset overall evaluation value to generate an overall evaluation value of the power prediction model.
[0013] Exemplarily, the selected number is the number of devices of the edge devices participating in the federated learning training of the federated learning system.
[0014] Exemplarily, the total power consumption generation model includes:
[0015] ;
[0016] Said is the total power consumption corresponding to the cluster, is the selected number of the edge devices in the cluster, is the serial number of the edge device in the cluster, For the The computing power consumption of the edge devices per hour, For the The transmission power consumption of the edge devices per hour, Indicates whether the edge device is selected. Indicates that it is not selected. Indicates selected.
[0017] Exemplarily, the total power consumption generation model is a generation model of the total power consumption.
[0018] Exemplarily, the higher the total power consumption corresponding to the cluster, the higher the overall power consumption of the edge devices in the cluster; the lower the total power consumption corresponding to the cluster, the lower the overall power consumption of the second global model after training.
[0019] Exemplarily, the overall evaluation value generation model is a generation model of the overall evaluation value, the overall evaluation value is a current overall evaluation value, and the preset evaluation value is a preset overall evaluation value.
[0020] Exemplarily, the overall evaluation value is positively correlated with the overall performance of the second global model after training. A higher overall evaluation value indicates a higher overall performance of the second global model after training; a lower overall evaluation value indicates a lower overall performance of the second global model after training.
[0021] Exemplarily, the overall evaluation value generation model includes:
[0022] S=w1×S1+w2×S2+w3×S3+w4×S4;
[0023] Among them, S is the overall evaluation value, w1 is the weight coefficient of S1, w2 is the weight coefficient of S2, w3 is the weight coefficient of S3, w4 is the weight coefficient of S4, S1 is the ratio of the current value of the accuracy to the preset value of the accuracy, S2 is the ratio of the current value of the determination coefficient to the preset value of the determination coefficient, S3 is the ratio of the preset value of the mean absolute error to the current value of the mean absolute error, and S4 is the ratio of the preset value of the root mean square difference to the current value of the root mean square difference.
[0024] In a possible implementation manner of the first aspect, marking the cluster corresponding to the minimum total power consumption as a target cluster includes:
[0025] sorting the total power consumption corresponding to each of the clusters, and obtaining the statistical number of the clusters corresponding to the minimum total power consumption;
[0026] When the statistical quantity is one, marking the cluster corresponding to the minimum total power consumption as the target cluster;
[0027] When the statistical quantity is multiple, the cluster corresponding to the smallest total power consumption and the largest selected number is marked as the target cluster.
[0028] In a possible implementation manner of the first aspect, when the statistical quantity is multiple, marking the cluster corresponding to the smallest total power consumption and the largest selected number as the target cluster includes:
[0029] When the statistical quantity is multiple, determining whether the cluster corresponding to the minimum total power consumption includes cluster A and cluster B;
[0030] When the cluster corresponding to the minimum total power consumption includes cluster A and cluster B, obtaining a first number of cluster A, and obtaining a second number of cluster B, the first number being the selected number of edge devices of cluster A, and the second number being the selected number of edge devices of cluster B;
[0031] When the first number is greater than the second number, marking cluster A as the target cluster;
[0032] When the second number is greater than the first number, marking cluster B as the target cluster;
[0033] When the first number is equal to the second number, cluster A or cluster B is marked as the target cluster.
[0034] In a possible implementation manner of the first aspect, the sending an upload instruction to the multiple edge devices of the target cluster includes:
[0035] The upload instruction is sent to the multiple edge devices of the target cluster through a preset network, and the preset network includes one or a combination of a 4G network, a 5G network, a WIFI network, and an Ethernet network.
[0036] In a possible implementation manner of the first aspect, when the loss value is less than the preset value or the number of training rounds is greater than the preset number of rounds, setting the second global model as the power prediction model of the target cluster, obtaining evaluation data of the power prediction model on the test set, generating a model according to the evaluation data and a preset overall evaluation value, and generating an overall evaluation value of the power prediction model, including:
[0037] When the loss value is less than the preset value or the number of training rounds is greater than the preset number of rounds, the second global model is set as the power prediction model of the target cluster;
[0038] Obtain evaluation data of the power prediction model on the test set, and obtain accuracy, determination coefficient, mean absolute error, and root mean square error in the evaluation data;
[0039] A model is generated according to the accuracy, the determination coefficient, the mean absolute error, the root mean square error and a preset overall evaluation value to generate an overall evaluation value of the trained power prediction model.
[0040] In a possible implementation manner of the first aspect, when the loss value is less than the preset value or the number of training rounds is greater than the preset number of rounds, setting the second global model as the power prediction model of the target cluster, obtaining evaluation data of the power prediction model on the test set, generating a model according to the evaluation data and a preset overall evaluation value, and generating the overall evaluation value of the power prediction model, the federated learning method further includes:
[0041] Obtain a preset evaluation, and determine whether the overall evaluation value is greater than the preset evaluation value;
[0042] When the overall evaluation value is greater than a preset evaluation value, the power prediction model is saved.
[0043] In a possible implementation of the first aspect, the preset impact characteristics include one or a combination of preset time characteristics and preset weather characteristics, the preset time characteristics include one or a combination of a preset time period, a preset month, and a preset season, and the preset weather characteristics include one or a combination of a preset temperature, a preset humidity, a preset wind speed, and a preset rainfall.
[0044] In a second aspect, an embodiment of the present application provides a federated learning device based on an edge device, which is applied to a central server of a federated learning system, wherein the central server is connected to a plurality of edge devices, and the central server stores a first global model of the federated learning system, including:
[0045] An acquisition module is used to acquire the hot coding vector uploaded by the edge device, divide the multiple edge devices into different clusters according to different hot coding vectors, and generate the total power consumption corresponding to the cluster according to the selected number of edge devices in the cluster, the calculation power consumption, the transmission power consumption and the preset total power consumption generation model;
[0046] A marking module, used for marking the cluster corresponding to the minimum total power consumption as a target cluster;
[0047] A sending module, used for sending an upload instruction to the plurality of edge devices of the target cluster;
[0048] An updating module, configured to obtain local model parameters returned by the edge device based on the upload instruction, aggregate multiple local model parameters to obtain update parameters, modify initial parameters of the first global model to the update parameters, and set the first global model using the update parameters as the second global model;
[0049] a partitioning module, configured to obtain preset influencing features of the target cluster, form a group of sample data with the preset influencing features and the preset power corresponding to the preset influencing features, and partition the multiple groups of sample data into a training set and a test set of the second global model;
[0050] an input module, configured to input the preset influencing features of the training set into the second global model, obtain the predicted power output by the second global model based on the preset influencing features, determine whether the loss value between the preset power and the predicted power is less than a preset value, and determine whether the number of training rounds is greater than a preset number of rounds;
[0051] An evaluation module is used to set the second global model as the power prediction model of the target cluster when the loss value is less than the preset value or the number of training rounds is greater than the preset number of rounds, obtain the evaluation data of the power prediction model on the test set, generate a model according to the evaluation data and a preset overall evaluation value, and generate an overall evaluation value of the power prediction model.
[0052] In a third aspect, an embodiment of the present application provides a central server, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the federated learning method of any one of the first aspects described above is implemented.
[0053] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the federated learning method of any one of the above-mentioned first aspects is implemented.
[0054] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on a central server, enables the central server to execute the federated learning method described in any one of the above-mentioned first aspects.
[0055] The beneficial effects of the embodiments of the present application lie in two aspects. On the one hand, the cluster corresponding to the smallest total power consumption is marked as the target cluster, and an upload instruction is sent to the multiple edge devices of the target cluster, so that the edge devices of the target cluster can be determined. Since the edge devices outside the target cluster will not receive the upload instruction, the edge devices outside the target cluster do not need to participate in the federated learning training. Therefore, the overall number of edge devices participating in the federated learning training is reduced, which is beneficial to reducing the overall energy consumption of the edge devices during the training process. On the other hand, since the model is generated according to the evaluation data and the preset overall evaluation value, the overall evaluation value of the power prediction model is generated, thereby simplifying the evaluation process of the power prediction model, which is beneficial to improving the evaluation efficiency of the power prediction model. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0057] Figure 1 An application scenario diagram of the federated learning method provided in the embodiment of the present application;
[0058] Figure 2 is a flowchart of the federated learning method provided in the embodiment of the present application;
[0059] Figure 3 A flow chart of a power reserve prediction model provided in an embodiment of the present application;
[0060] Figure 4 A schematic block diagram of a federated learning device provided in an embodiment of the present application;
[0061] Figure 5 A schematic diagram of the structure of the central server provided in an embodiment of the present application. DETAILED DESCRIPTION
[0062] In order to make the purpose, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0063] The technical solutions between the various embodiments can be combined with each other, but they must be based on the fact that they can be implemented by ordinary technicians in the field. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.
[0064] The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may also be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.
[0065] The federated learning method provided in the embodiment of the present application can be applied to a central server, and the embodiment of the present application does not impose any restrictions on the specific type of the central server.
[0066] See also Figure 1 , Figure 1The application scenario diagram of the federated learning method provided in the embodiment of the present application is described in detail as follows:
[0067] The central server is connected to multiple edge devices, and the central server stores the first global model of the federated learning system.
[0068] Among them, the edge device downloads the global model parameters issued by the central server, performs local training on different global model parameters based on the local power load data set, compares the loss function values of multiple local models after local training, and saves the local model whose loss function value is less than the preset loss value.
[0069] For ease of explanation, the multiple edge devices are taken as four edge devices as an example, and the details are as follows:
[0070] The four edge devices include edge device A, edge device B, edge device C, and edge device D. The central server is connected to edge device A, edge device B, edge device C, and edge device D respectively, and obtains computing power consumption and transmission power consumption of edge device A, edge device B, edge device C, and edge device D from edge device A, edge device B, edge device C, and edge device D.
[0071] In an embodiment of the present application, the central server can be connected to different edge devices at the same time to obtain computing power consumption and transmission power consumption from different edge devices.
[0072] See also Figure 2 , Figure 2 It is a flow chart of the federated learning method provided in an embodiment of the present application. The method can be applied to a central server of a federated learning system, wherein the central server is connected to multiple edge devices and stores a first global model of the federated learning system.
[0073] like Figure 2 As shown, the federated learning method provided in the embodiment of the present application includes the following steps, which are described in detail as follows:
[0074] S201, obtaining a hot coding vector uploaded by the edge device, dividing multiple edge devices into different clusters by using different hot coding vectors, and generating a total power consumption corresponding to the cluster according to the selected number of edge devices in the cluster, computing power consumption, transmission power consumption, and a preset total power consumption generation model;
[0075] Among them, each edge device generates a hot coding vector to represent the cluster to which it belongs, and uploads the hot coding vector to the central server. The central server divides multiple edge devices into different clusters through the hot coding vector. In this way, the edge devices in the cluster can be managed uniformly, which is conducive to improving the management efficiency of the edge devices in the cluster.
[0076] Each of the hot encoding vectors corresponds to one cluster, and different hot encoding vectors correspond to different clusters.
[0077] For the sake of illustration, an example is given below:
[0078] For example, there are four clusters, named Cluster A, Cluster B, Cluster C, and Cluster D. These four clusters can be represented by the following hot encoding vectors:
[0079] Cluster A: [1, 0, 0, 0], this vector indicates that cluster A is selected, and clusters B, C, and D are not selected.
[0080] Cluster B: [0, 1, 0, 0], this vector indicates that cluster B is selected, and cluster A, cluster C, and cluster D are not selected.
[0081] Cluster C: [0, 0, 1, 0], this vector indicates that cluster C is selected, and clusters A, B, and D are not selected.
[0082] Cluster D: [0, 0, 0, 1], this vector indicates that cluster D is selected, and cluster A, cluster B, and cluster C are not selected.
[0083] Exemplarily, the total power consumption generation model includes:
[0084] ;
[0085] Said is the total power consumption corresponding to the cluster, is the selected number of the edge devices in the cluster, is the serial number of the edge device in the cluster, For the The computing power consumption of the edge devices per hour, For the The transmission power consumption of the edge devices per hour, Indicates whether the edge device is selected. Indicates that it is not selected. Indicates selected.
[0086] Exemplarily, the total power consumption generation model is a generation model of the total power consumption.
[0087] Exemplarily, the higher the total power consumption corresponding to the cluster, the higher the overall power consumption of the edge devices in the cluster; the lower the total power consumption corresponding to the cluster, the lower the overall power consumption of the second global model after training.
[0088] M is set by the user or by the system default and is not restricted here.
[0089] For the sake of illustration, an example is given below:
[0090] M is 4, the unit of computing power consumption and transmission power consumption is expressed in watts, and the cluster includes edge device A, edge device B, edge device C, and edge device D;
[0091] The computing power consumption of edge device A per hour is 100 watts, and the transmission power consumption per hour is 100 watts. Therefore, the sum of the computing power consumption and the transmission power consumption of edge device A per hour is 200 watts.
[0092] The computing power consumption of edge device B per hour is 200 watts, and the transmission power consumption per hour is 100 watts. Therefore, the sum of the computing power consumption and the transmission power consumption of edge device B per hour is 300 watts.
[0093] The computing power consumption of edge device C per hour is 200 watts, and the transmission power consumption per hour is 200 watts. Therefore, the sum of the computing power consumption and the transmission power consumption of edge device C per hour is 400 watts.
[0094] The computing power consumption of edge device D per hour is 300 watts, and the transmission power consumption per hour is 200 watts. Therefore, the sum of the computing power consumption and the transmission power consumption of edge device D per hour is 500 watts.
[0095] Edge device A is selected, edge device B is not selected, edge device C is selected, and edge device D is selected. At this time, the total power consumption generation model is:
[0096] P=200×1+300×0+400×1+500×1=200+0+400+500=1100.
[0097] For the sake of illustration, an example is given below:
[0098] M is 5, the unit of computing power consumption and transmission power consumption is expressed in watts, and the cluster includes edge device A, edge device B, edge device C, edge device D, and edge device E;
[0099] The computing power consumption of edge device A per hour is 100 watts, and the transmission power consumption per hour is 100 watts. Therefore, the sum of the computing power consumption and the transmission power consumption of edge device A per hour is 200 watts.
[0100] The computing power consumption of edge device B per hour is 200 watts, and the transmission power consumption per hour is 100 watts. Therefore, the sum of the computing power consumption and the transmission power consumption of edge device B per hour is 300 watts.
[0101] The computing power consumption of edge device C per hour is 200 watts, and the transmission power consumption per hour is 200 watts. Therefore, the sum of the computing power consumption and the transmission power consumption of edge device C per hour is 400 watts.
[0102] The computing power consumption of edge device D per hour is 300 watts, and the transmission power consumption per hour is 200 watts. Therefore, the sum of the computing power consumption and the transmission power consumption of edge device D per hour is 500 watts.
[0103] The computing power consumption of edge device E is 400 watts per hour, and the transmission power consumption is 300 watts per hour. Therefore, the sum of the computing power consumption and the transmission power consumption of edge device D is 700 watts per hour.
[0104] Edge device A is selected, edge device B is not selected, edge device C is selected, edge device D is selected, and edge device E is selected. At this time, the total power consumption generation model is:
[0105] P=200×1+300×0+400×1+500×1+700×1=1800.
[0106] S202, marking the cluster corresponding to the minimum total power consumption as a target cluster;
[0107] The step of marking the cluster corresponding to the minimum total power consumption as a target cluster includes:
[0108] sorting the total power consumption corresponding to each of the clusters, and obtaining the statistical number of the clusters corresponding to the minimum total power consumption;
[0109] When the statistical quantity is one, marking the cluster corresponding to the minimum total power consumption as the target cluster;
[0110] When the statistical quantity is multiple, the cluster corresponding to the smallest total power consumption and the largest selected number is marked as the target cluster.
[0111] Among them, the federated learning system allows model training to be performed in parallel on multiple edge devices, which can speed up training and improve training efficiency. When the number of edge devices in the target cluster increases, the federated learning system can complete the model training process faster.
[0112] Wherein, when the statistical quantity is multiple, marking the cluster corresponding to the smallest total power consumption and the largest selected number as the target cluster includes:
[0113] When the statistical quantity is multiple, determine whether the cluster corresponding to the minimum total power consumption includes cluster A and cluster B; when the cluster corresponding to the minimum total power consumption includes cluster A and cluster B, obtain a first quantity of cluster A, and obtain a second quantity of cluster B, the first quantity is the selected number of the edge devices of cluster A, and the second quantity is the selected number of the edge devices of cluster B;
[0114] When the first number is greater than the second number, marking cluster A as the target cluster;
[0115] When the second number is greater than the first number, marking cluster B as the target cluster;
[0116] When the first number is equal to the second number, cluster A or cluster B is marked as the target cluster.
[0117] The number of clusters is set by the user or by system default and is not limited here.
[0118] For the sake of illustration, an example is given below:
[0119] For example, there are cluster 1, cluster 2, cluster 3, cluster 4, and cluster 5;
[0120] The total power consumption of cluster 1 is 2000 watts per hour; the total power consumption of cluster 2 is 3000 watts per hour;
[0121] The total power consumption of cluster 3 is 4000 watts per hour; the total power consumption of cluster 4 is 5000 watts per hour;
[0122] The total power consumption of cluster 5 is 1100 watts per hour.
[0123] Therefore, the minimum total power consumption is in cluster 5, and cluster 5 is marked as the target cluster.
[0124] For the sake of illustration, an example is given below:
[0125] For example, there are cluster 1, cluster 2, cluster 3, cluster 4, cluster 5, and cluster 6;
[0126] The total power consumption per hour for cluster 1 is 3000 watts; the total power consumption per hour for cluster 2 is 6000 watts;
[0127] The total power consumption of cluster 3 is 4000 watts per hour; the total power consumption of cluster 4 is 5000 watts per hour;
[0128] The total power consumption of cluster 5 is 3000 watts per hour, and the total power consumption of cluster 6 is 3000 watts per hour.
[0129] Therefore, the number of edge devices selected for cluster 1 is 6, the number of edge devices selected for cluster 5 is 3, the number of edge devices selected for cluster 6 is 7, and cluster 6 is marked as the target cluster.
[0130] S203, sending an upload instruction to the plurality of edge devices of the target cluster;
[0131] Among them, since the power prediction model is based on federated learning training, during the training process of the power prediction model, by sending upload instructions to multiple edge devices of the target cluster, the overall number of edge devices participating in the federated learning training can be reduced, which is beneficial to reducing the energy consumption of the training process of the power prediction model.
[0132] The sending of the upload instruction to the plurality of edge devices of the target cluster includes:
[0133] The upload instruction is sent to the multiple edge devices of the target cluster through a preset network, and the preset network includes one or a combination of a 4G network, a 5G network, a WIFI network, and an Ethernet network.
[0134] S204, obtaining local model parameters returned by the edge device based on the upload instruction, aggregating multiple local model parameters to obtain update parameters, modifying initial parameters of the first global model to the update parameters, and setting the first global model using the update parameters as the second global model;
[0135] S205, obtaining preset influencing features of the target cluster, forming a group of sample data with the preset influencing features and the preset power corresponding to the preset influencing features, and dividing the multiple groups of sample data into a training set and a test set of the second global model;
[0136] Among them, the preset power amount is the preset power consumption.
[0137] S206, inputting the preset influencing feature of the training set into the second global model, obtaining the predicted power output by the second global model based on the preset influencing feature, determining whether the loss value between the preset power and the predicted power is less than a preset value, and determining whether the number of training rounds is greater than a preset number of rounds;
[0138] Wherein, the loss value between the preset power and the predicted power is obtained through the loss function.
[0139] Among them, the preset influencing characteristics include one or a combination of preset time characteristics and preset weather characteristics, the preset time characteristics include one or a combination of preset time period, preset month, preset season, and the preset weather characteristics include one or a combination of preset temperature, preset humidity, preset wind speed, and preset rainfall.
[0140] For the sake of illustration, an example is given below:
[0141] Preset time period:
[0142] Daily working hours: 9:00 AM to 5:00 PM.
[0143] Lunch time: 12:00 PM to 1:00 PM.
[0144] Peak traffic hours: 7:30 AM to 9:00 AM in the morning and 5:00 PM to 7:00 PM in the afternoon.
[0145] Nighttime rest time: 10:00 PM to 7:00 AM.
[0146] School hours: 8:00 AM to 12:00 PM, 1:30 PM to 4:30 PM.
[0147] Default Month: Month of the year, January to December.
[0148] Preset seasons: Spring, Summer, Autumn, Winter.
[0149] Preset weather characteristics:
[0150] Preset temperature: The preset maximum or average temperature, expressed in degrees Celsius.
[0151] Preset humidity: Preset relative humidity, expressed as a percentage.
[0152] Preset wind speed: The preset average wind speed, expressed in meters per second or kilometers per hour.
[0153] Preset rainfall: The preset rainfall can be expressed in millimeters or a binary value indicating whether it is raining.
[0154] S207, when the loss value is less than the preset value or the number of training rounds is greater than the preset number of rounds, the second global model is set as the power prediction model of the target cluster, the evaluation data of the power prediction model on the test set is obtained, and a model is generated according to the evaluation data and a preset overall evaluation value to generate an overall evaluation value of the power prediction model.
[0155] Among them, when the loss value is not less than the preset value or the number of training rounds is not greater than the preset number of rounds, return to execute S206, iteratively train the second global model until the loss value is less than the preset value or the number of training rounds is greater than the preset number of rounds, then stop training the second global model, set the second global model as the power prediction model of the target cluster, obtain the evaluation data of the power prediction model on the test set, generate a model according to the evaluation data and the preset overall evaluation value, and generate an overall evaluation value of the power prediction model.
[0156] Among them, setting the second global model as the power prediction model of the target cluster can meet the power prediction demand of the target cluster, which is conducive to improving the accuracy of power prediction.
[0157] Wherein, when the loss value is less than the preset value or the number of training rounds is greater than the preset number of rounds, the second global model is set as the power prediction model of the target cluster, the evaluation data of the power prediction model on the test set is obtained, and a model is generated according to the evaluation data and a preset overall evaluation value to generate an overall evaluation value of the power prediction model, including:
[0158] When the loss value is less than the preset value or the number of training rounds is greater than the preset number of rounds, the second global model is set as the power prediction model of the target cluster;
[0159] Obtain evaluation data of the power prediction model on the test set, and obtain accuracy, determination coefficient, mean absolute error, and root mean square error in the evaluation data;
[0160] A model is generated according to the accuracy, the determination coefficient, the mean absolute error, the root mean square error and a preset overall evaluation value to generate an overall evaluation value of the trained power prediction model.
[0161] Exemplarily, the overall evaluation value generation model is a generation model of the overall evaluation value, the overall evaluation value is a current overall evaluation value, and the preset evaluation value is a preset overall evaluation value.
[0162] Exemplarily, the overall evaluation value is positively correlated with the overall performance of the second global model after training. A higher overall evaluation value indicates a higher overall performance of the second global model after training; a lower overall evaluation value indicates a lower overall performance of the second global model after training.
[0163] Exemplarily, the overall evaluation value generation model includes:
[0164] S=w1×S1+w2×S2+w3×S3+w4×S4;
[0165] Among them, S is the overall evaluation value, w1 is the weight coefficient of S1, w2 is the weight coefficient of S2, w3 is the weight coefficient of S3, w4 is the weight coefficient of S4, S1 is the ratio of the current value of the accuracy to the preset value of the accuracy, S2 is the ratio of the current value of the determination coefficient to the preset value of the determination coefficient, S3 is the ratio of the preset value of the mean absolute error to the current value of the mean absolute error, and S4 is the ratio of the preset value of the root mean square difference to the current value of the root mean square difference.
[0166] Among them, the preset value of the mean absolute error is a fixed value. The smaller the current value of the mean absolute error, the larger the S3 and the larger the overall evaluation value; the larger the current value of the mean absolute error, the smaller the S3 and the smaller the overall evaluation value.
[0167] Among them, the preset value of the root mean square difference is a fixed value. The smaller the current value of the root mean square difference is, the larger the S4 is, and the larger the overall evaluation value is; the larger the current value of the root mean square difference is, the smaller the S4 is, and the smaller the overall evaluation value is.
[0168] Among them, the sum of w1, w2, w3, and w4 is 1.
[0169] For the sake of illustration, an example is given below:
[0170] For example, when w1 is 0.2, w2 is 0.2, w3 is 0.3, and w4 is 0.3, the overall evaluation value generation model is: S=0.2×S1+0.2×S2+0.3×S3+0.3×S4;
[0171] For example, when w1 is 0.25, w2 is 0.25, w3 is 0.2, and w4 is 0.3, the overall evaluation value generation model is: S=0.25×S1+0.25×S2+0.2×S3+0.3×S4;
[0172] For example, when w1 is 0.25, w2 is 0.25, w3 is 0.25, and w4 is 0.25, the overall evaluation value generation model is: S=0.25×S1+0.25×S2+0.25×S3+0.25×S4;
[0173] Among them, w1, w2, w3, and w4 are set by the user or by the system by default and are not restricted here.
[0174] The beneficial effects of the embodiments of the present application lie in two aspects. On the one hand, the cluster corresponding to the smallest total power consumption is marked as the target cluster, and an upload instruction is sent to the multiple edge devices of the target cluster, so that the edge devices of the target cluster can be determined. Since the edge devices outside the target cluster will not receive the upload instruction, the edge devices outside the target cluster do not need to participate in the federated learning training. Therefore, the overall number of edge devices participating in the federated learning training is reduced, which is beneficial to reducing the overall energy consumption of the edge devices during the training process. On the other hand, since the model is generated according to the evaluation data and the preset overall evaluation value, the overall evaluation value of the power prediction model is generated, thereby simplifying the evaluation process of the power prediction model, which is beneficial to improving the evaluation efficiency of the power prediction model.
[0175] See also Figure 3 , Figure 3 The flowchart of the power reserve prediction model provided in the embodiment of the present application is described in detail as follows:
[0176] S301, obtaining a preset evaluation value, and determining whether the overall evaluation value is greater than the preset evaluation value;
[0177] The preset evaluation value is set by the user or by the system by default, and is not limited here.
[0178] S302: When the overall evaluation value is greater than a preset evaluation value, the power prediction model is saved.
[0179] When the overall evaluation value is greater than a preset evaluation value, the power prediction model is saved in a preset storage area, and an access interface to the storage area is established to facilitate subsequent calling of the power prediction model through the access interface.
[0180] Wherein, when the overall evaluation value is greater than the preset evaluation value, after saving the power prediction model, the federated learning method further includes:
[0181] The parameter information of the power prediction model is sent to the edge device of the target cluster, so that the edge device of the target cluster deploys the power prediction model according to the parameter information.
[0182] In the embodiment of the present application, when the overall evaluation value is greater than the preset evaluation value, the power prediction model is saved, so that the required power prediction model can be saved.
[0183] For the federated learning method described in the above embodiment, please refer to Figure 4 , Figure 4 A schematic block diagram of a federated learning device provided in an embodiment of the present application, Figure 4 The federated learning apparatus 400 shown can be applied to Figure 1The central server in the application scenario diagram shown in the figure is taken as an example below. Figure 4 The federated learning device 400 shown is described in detail. The federated learning device 400 may include an acquisition module 401, a marking module 402, a sending module 403, an updating module 404, a division module 405, an input module 406, and an evaluation module 407.
[0184] An acquisition module 401 is used to acquire a hot coding vector uploaded by the edge device, divide multiple edge devices into different clusters according to different hot coding vectors, and generate a total power consumption corresponding to the cluster according to the selected number of edge devices in the cluster, computing power consumption, transmission power consumption, and a preset total power consumption generation model;
[0185] A marking module 402, configured to mark the cluster corresponding to the minimum total power consumption as a target cluster;
[0186] A sending module 403 is used to send an upload instruction to the plurality of edge devices of the target cluster;
[0187] An updating module 404 is used to obtain local model parameters returned by the edge device based on the upload instruction, aggregate multiple local model parameters to obtain update parameters, modify initial parameters of the first global model to the update parameters, and set the first global model using the update parameters as the second global model;
[0188] A partitioning module 405 is used to obtain preset influencing features of the target cluster, form a group of sample data with the preset influencing features and the preset power corresponding to the preset influencing features, and divide the multiple groups of sample data into a training set and a test set of the second global model;
[0189] An input module 406 is used to input the preset influencing feature of the training set into the second global model, obtain the predicted power output by the second global model based on the preset influencing feature, determine whether the loss value between the preset power and the predicted power is less than a preset value, and determine whether the number of training rounds is greater than a preset number of rounds;
[0190] Evaluation module 407 is used to set the second global model as the power prediction model of the target cluster when the loss value is less than the preset value or the number of training rounds is greater than the preset number of rounds, obtain the evaluation data of the power prediction model on the test set, generate a model according to the evaluation data and the preset overall evaluation value, and generate an overall evaluation value of the power prediction model.
[0191] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0192] The beneficial effects of the embodiments of the present application lie in two aspects. On the one hand, the cluster corresponding to the smallest total power consumption is marked as the target cluster, and an upload instruction is sent to the multiple edge devices of the target cluster, so that the edge devices of the target cluster can be determined. Since the edge devices outside the target cluster will not receive the upload instruction, the edge devices outside the target cluster do not need to participate in the federated learning training. Therefore, the overall number of edge devices participating in the federated learning training is reduced, which is beneficial to reducing the overall energy consumption of the edge devices during the training process. On the other hand, since the model is generated according to the evaluation data and the preset overall evaluation value, the overall evaluation value of the power prediction model is generated, thereby simplifying the evaluation process of the power prediction model, which is beneficial to improving the evaluation efficiency of the power prediction model.
[0193] See also Figure 5 , Figure 5 A schematic diagram of the structure of the central server provided in an embodiment of the present application.
[0194] like Figure 5 As shown, Figure 5 The central server 2 includes: at least one processor 20, a memory 21, and a computer program 22 stored in the memory 21 and executable on the at least one processor 20, and when the processor 20 executes the computer program 22, the steps in any of the above-mentioned method embodiments are implemented.
[0195] The central server 2 may include, but is not limited to, a processor 20 and a memory 21. Those skilled in the art will appreciate that Figure 5 It is only an example of the central server 2 and does not constitute a limitation on the central server 2. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components, for example, it may also include input and output devices, network access devices, etc.
[0196] The processor 20 is used to run the computer program 22 stored in the memory 21, and implement the following steps when executing the computer program 22:
[0197] Obtain the hot coding vector uploaded by the edge device, divide the multiple edge devices into different clusters according to different hot coding vectors, and generate the total power consumption corresponding to the cluster according to the selected number of edge devices in the cluster, computing power consumption, transmission power consumption and a preset total power consumption generation model;
[0198] Marking the cluster corresponding to the minimum total power consumption as a target cluster;
[0199] Sending an upload instruction to the plurality of edge devices of the target cluster;
[0200] Acquire local model parameters returned by the edge device based on the upload instruction, aggregate multiple local model parameters to obtain update parameters, modify initial parameters of the first global model to the update parameters, and set the first global model using the update parameters as the second global model;
[0201] Obtaining preset impact features of the target cluster, forming a group of sample data with the preset impact features and the preset power corresponding to the preset impact features, and dividing the multiple groups of sample data into a training set and a test set of the second global model;
[0202] Inputting the preset influencing feature of the training set into the second global model, obtaining the predicted power output by the second global model based on the preset influencing feature, determining whether the loss value between the preset power and the predicted power is less than a preset value, and determining whether the number of training rounds is greater than a preset number of rounds;
[0203] When the loss value is less than the preset value or the number of training rounds is greater than the preset number of rounds, the second global model is set as the power prediction model of the target cluster, the evaluation data of the power prediction model on the test set is obtained, and a model is generated according to the evaluation data and the preset overall evaluation value to generate an overall evaluation value of the power prediction model.
[0204] In some embodiments, the processor 20 is configured to implement:
[0205] sorting the total power consumption corresponding to each of the clusters, and obtaining the statistical number of the clusters corresponding to the minimum total power consumption;
[0206] When the statistical quantity is one, marking the cluster corresponding to the minimum total power consumption as the target cluster;
[0207] When the statistical quantity is multiple, the cluster corresponding to the smallest total power consumption and the largest selected number is marked as the target cluster.
[0208] In some embodiments, the processor 20 is configured to implement:
[0209] When the statistical quantity is multiple, determine whether the cluster corresponding to the minimum total power consumption includes cluster A and cluster B; when the cluster corresponding to the minimum total power consumption includes cluster A and cluster B, obtain a first quantity of cluster A, and obtain a second quantity of cluster B, the first quantity is the selected number of the edge devices of cluster A, and the second quantity is the selected number of the edge devices of cluster B;
[0210] When the first number is greater than the second number, marking cluster A as the target cluster;
[0211] When the second number is greater than the first number, marking cluster B as the target cluster;
[0212] When the first number is equal to the second number, cluster A or cluster B is marked as the target cluster.
[0213] In some embodiments, the processor 20 is configured to implement:
[0214] The upload instruction is sent to the multiple edge devices of the target cluster through a preset network, and the preset network includes one or a combination of a 4G network, a 5G network, a WIFI network, and an Ethernet network.
[0215] In some embodiments, the processor 20 is configured to implement:
[0216] When the loss value is less than the preset value or the number of training rounds is greater than the preset number of rounds, the second global model is set as the power prediction model of the target cluster;
[0217] Obtain evaluation data of the power prediction model on the test set, and obtain accuracy, determination coefficient, mean absolute error, and root mean square error in the evaluation data;
[0218] A model is generated according to the accuracy, the determination coefficient, the mean absolute error, the root mean square error and a preset overall evaluation value to generate an overall evaluation value of the trained power prediction model.
[0219] In some embodiments, the processor 20 is configured to implement:
[0220] Obtain a preset evaluation, and determine whether the overall evaluation value is greater than the preset evaluation value;
[0221] When the overall evaluation value is greater than a preset evaluation value, the power prediction model is saved.
[0222] The processor 20 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0223] In some embodiments, the memory 21 may be an internal storage unit of the central server 2, such as a hard disk or memory of the central server 2. In other embodiments, the memory 21 may also be an external storage device of the central server 2, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the central server 2. Further, the memory 21 may also include both an internal storage unit of the central server 2 and an external storage device. The memory 21 is used to store an operating system, an application program, a boot loader (Boot Loader), data, and other programs, such as the program code of the computer program, etc. The memory 21 may also be used to temporarily store data that has been output or is to be output.
[0224] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0225] An embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0226] The computer-readable storage medium stores program code, which can be called by a processor to execute the federated learning method described in the above method embodiment.
[0227] The computer-readable storage medium has a storage space for program codes.
[0228] The program code includes the code of any step in the federated learning method described in the above method embodiment.
[0229] For example, the program code is called by the processor and can execute the following steps:
[0230] Obtain the hot coding vector uploaded by the edge device, divide the multiple edge devices into different clusters according to different hot coding vectors, and generate the total power consumption corresponding to the cluster according to the selected number of edge devices in the cluster, computing power consumption, transmission power consumption and a preset total power consumption generation model;
[0231] Marking the cluster corresponding to the minimum total power consumption as a target cluster;
[0232] Sending an upload instruction to the plurality of edge devices of the target cluster;
[0233] Acquire local model parameters returned by the edge device based on the upload instruction, aggregate multiple local model parameters to obtain update parameters, modify initial parameters of the first global model to the update parameters, and set the first global model using the update parameters as the second global model;
[0234] Obtaining preset impact features of the target cluster, forming a group of sample data with the preset impact features and the preset power corresponding to the preset impact features, and dividing the multiple groups of sample data into a training set and a test set of the second global model;
[0235] Inputting the preset influencing feature of the training set into the second global model, obtaining the predicted power output by the second global model based on the preset influencing feature, determining whether the loss value between the preset power and the predicted power is less than a preset value, and determining whether the number of training rounds is greater than a preset number of rounds;
[0236] When the loss value is less than the preset value or the number of training rounds is greater than the preset number of rounds, the second global model is set as the power prediction model of the target cluster, the evaluation data of the power prediction model on the test set is obtained, and a model is generated according to the evaluation data and the preset overall evaluation value to generate an overall evaluation value of the power prediction model.
[0237] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0238] The computer-readable storage medium may also be an external storage device of the federated learning device or the central server, for example, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), a non-transitory computer-readable storage medium (non-transitory computer-readable storage medium), etc., equipped on the federated learning device or the central server.
[0239] Since the computer program stored in the computer-readable storage medium can execute any one of the edge device-based federated learning methods provided in the embodiments of the present application, the computer-readable storage medium can achieve the beneficial effects that can be achieved by any one of the edge device-based federated learning methods provided in the embodiments of the present application. Please refer to the previous embodiments for details and will not be repeated here.
[0240] An embodiment of the present application provides a computer program product. When the computer program product runs on a central server, the central server executes the above-mentioned federated learning method.
[0241] The computer program product is loaded by the central server and can execute the following steps:
[0242] Obtain the hot coding vector uploaded by the edge device, divide the multiple edge devices into different clusters according to different hot coding vectors, and generate the total power consumption corresponding to the cluster according to the selected number of edge devices in the cluster, computing power consumption, transmission power consumption and a preset total power consumption generation model;
[0243] Marking the cluster corresponding to the minimum total power consumption as a target cluster;
[0244] Sending an upload instruction to the plurality of edge devices of the target cluster;
[0245] Acquire local model parameters returned by the edge device based on the upload instruction, aggregate multiple local model parameters to obtain update parameters, modify initial parameters of the first global model to the update parameters, and set the first global model using the update parameters as the second global model;
[0246] Obtaining preset impact features of the target cluster, forming a group of sample data with the preset impact features and the preset power corresponding to the preset impact features, and dividing the multiple groups of sample data into a training set and a test set of the second global model;
[0247] Inputting the preset influencing feature of the training set into the second global model, obtaining the predicted power output by the second global model based on the preset influencing feature, determining whether the loss value between the preset power and the predicted power is less than a preset value, and determining whether the number of training rounds is greater than a preset number of rounds;
[0248] When the loss value is less than the preset value or the number of training rounds is greater than the preset number of rounds, the second global model is set as the power prediction model of the target cluster, the evaluation data of the power prediction model on the test set is obtained, and a model is generated according to the evaluation data and the preset overall evaluation value to generate an overall evaluation value of the power prediction model.
[0249] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium.
[0250] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0251] Based on such understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of each of the above-mentioned method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device capable of carrying the computer program code to the central server, a recording medium, a computer memory, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), an electric carrier signal, a telecommunication signal and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0252] In the above embodiments, the description of each embodiment has its own emphasis. For the part that is not described or recorded in detail in a certain embodiment, please refer to the relevant description of other embodiments. The above are only preferred embodiments of the present application, and the patent scope of the present application is not limited thereto. Any equivalent structure or equivalent process transformation made by using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A federated learning method based on edge devices, It is characterized in that A central server applied to a federated learning system, the central server connected to a plurality of edge devices, the central server storing a first global model of the federated learning system, the federated learning method comprising: Obtain the hot coding vector uploaded by the edge device, divide the multiple edge devices into different clusters according to different hot coding vectors, and generate the total power consumption corresponding to the cluster according to the selected number of edge devices in the cluster, computing power consumption, transmission power consumption and a preset total power consumption generation model; Marking the cluster corresponding to the minimum total power consumption as a target cluster; Sending an upload instruction to the plurality of edge devices of the target cluster; Acquire local model parameters returned by the edge device based on the upload instruction, aggregate multiple local model parameters to obtain update parameters, modify initial parameters of the first global model to the update parameters, and set the first global model using the update parameters as the second global model; Obtaining preset impact features of the target cluster, forming a group of sample data with the preset impact features and the preset power corresponding to the preset impact features, and dividing the multiple groups of sample data into a training set and a test set of the second global model; Input the preset influencing features of the training set into the second global model, obtain the predicted power output by the second global model based on the preset influencing features, judge whether the loss value between the preset power and the predicted power is less than the preset value, and judge whether the number of training rounds is greater than the preset number of rounds; when the loss value is less than the preset value or the number of training rounds is greater than the preset number of rounds, set the second global model as the power prediction model of the target cluster, obtain the evaluation data of the power prediction model on the test set, generate a model according to the evaluation data and the preset overall evaluation value, and generate an overall evaluation value of the power prediction model; Among them, the preset influencing characteristics include one or a combination of preset time characteristics and preset weather characteristics, the preset time characteristics include one or a combination of preset time period, preset month, preset season, and the preset weather characteristics include one or a combination of preset temperature, preset humidity, preset wind speed, and preset rainfall.
2. The federated learning method according to claim 1, It is characterized in that The marking the cluster corresponding to the minimum total power consumption as a target cluster includes: sorting the total power consumption corresponding to each of the clusters, and obtaining the statistical number of the clusters corresponding to the minimum total power consumption; When the statistical quantity is one, marking the cluster corresponding to the minimum total power consumption as the target cluster; When the statistical quantity is multiple, the cluster corresponding to the smallest total power consumption and the largest selected number is marked as the target cluster.
3. The federated learning method according to claim 2, It is characterized in that When the statistical quantity is multiple, marking the cluster corresponding to the smallest total power consumption and the largest selected number as the target cluster includes: When the statistical quantity is multiple, determining whether the cluster corresponding to the minimum total power consumption includes cluster A and cluster B; When the cluster corresponding to the minimum total power consumption includes cluster A and cluster B, obtaining a first number of cluster A, and obtaining a second number of cluster B, the first number being the selected number of edge devices of cluster A, and the second number being the selected number of edge devices of cluster B; When the first number is greater than the second number, marking cluster A as the target cluster; When the second number is greater than the first number, marking cluster B as the target cluster; When the first number is equal to the second number, cluster A or cluster B is marked as the target cluster.
4. The federated learning method according to claim 1, It is characterized in that The sending an upload instruction to the plurality of edge devices of the target cluster includes: The upload instruction is sent to the multiple edge devices of the target cluster through a preset network, and the preset network includes one or a combination of a 4G network, a 5G network, a WIFI network, and an Ethernet network.
5. The federated learning method according to claim 1, It is characterized in that When the loss value is less than the preset value or the number of training rounds is greater than the preset number of rounds, setting the second global model as the power prediction model of the target cluster, obtaining evaluation data of the power prediction model on the test set, generating a model according to the evaluation data and a preset overall evaluation value, and generating an overall evaluation value of the power prediction model, including: When the loss value is less than the preset value or the number of training rounds is greater than the preset number of rounds, the second global model is set as the power prediction model of the target cluster; Obtain evaluation data of the power prediction model on the test set, and obtain accuracy, determination coefficient, mean absolute error, and root mean square error in the evaluation data; A model is generated according to the accuracy, the determination coefficient, the mean absolute error, the root mean square error and a preset overall evaluation value to generate an overall evaluation value of the trained power prediction model.
6. The federated learning method according to claim 1, It is characterized in that When the loss value is less than the preset value or the number of training rounds is greater than the preset number of rounds, setting the second global model as the power prediction model of the target cluster, obtaining evaluation data of the power prediction model on the test set, generating a model according to the evaluation data and a preset overall evaluation value, and generating the overall evaluation value of the power prediction model, the federated learning method further includes: Obtaining a preset evaluation value, and determining whether the overall evaluation value is greater than the preset evaluation value; When the overall evaluation value is greater than a preset evaluation value, the power prediction model is saved.
7. A federated learning device based on edge devices, It is characterized in that A central server applied to a federated learning system, the central server connected to a plurality of edge devices, the central server storing a first global model of the federated learning system, comprising: An acquisition module is used to acquire the hot coding vector uploaded by the edge device, divide the multiple edge devices into different clusters according to different hot coding vectors, and generate the total power consumption corresponding to the cluster according to the selected number of edge devices in the cluster, the calculation power consumption, the transmission power consumption and the preset total power consumption generation model; A marking module, used for marking the cluster corresponding to the minimum total power consumption as a target cluster; A sending module, used for sending an upload instruction to the plurality of edge devices of the target cluster; An updating module, configured to obtain local model parameters returned by the edge device based on the upload instruction, aggregate multiple local model parameters to obtain update parameters, modify initial parameters of the first global model to the update parameters, and set the first global model using the update parameters as the second global model; a partitioning module, configured to obtain preset influencing features of the target cluster, form a group of sample data with the preset influencing features and the preset power corresponding to the preset influencing features, and partition the multiple groups of sample data into a training set and a test set of the second global model; an input module, configured to input the preset influencing features of the training set into the second global model, obtain the predicted power output by the second global model based on the preset influencing features, determine whether the loss value between the preset power and the predicted power is less than a preset value, and determine whether the number of training rounds is greater than a preset number of rounds; An evaluation module, configured to, when the loss value is less than the preset value or the number of training rounds is greater than the preset number of rounds, set the second global model as the power prediction model of the target cluster, obtain evaluation data of the power prediction model on the test set, generate a model according to the evaluation data and a preset overall evaluation value, and generate an overall evaluation value of the power prediction model; Among them, the preset influencing characteristics include one or a combination of preset time characteristics and preset weather characteristics, the preset time characteristics include one or a combination of preset time period, preset month, preset season, and the preset weather characteristics include one or a combination of preset temperature, preset humidity, preset wind speed, and preset rainfall.
8. A central server comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the computer program, the federated learning method according to any one of claims 1 to 6 is implemented.
9. A computer-readable storage medium storing a computer program. It is characterized in that When the computer program is executed by a processor, the federated learning method according to any one of claims 1 to 6 is implemented.
