Federal learning-based monthly time-sharing electric quantity prediction method
By adopting a combination method of federated learning and long-term memory networks in power prediction, the shortcomings of traditional power prediction methods under complex nonlinear relationships and high-dimensional data are solved, achieving higher prediction accuracy and real-time performance, while reducing the risk of privacy leakage.
Patent Information
- Application Number
- CN202411569601.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-05
- Publication Date
- 2025-03-04
AI Technical Summary
Traditional power prediction methods are difficult to achieve real-time and accuracy when facing complex nonlinear relationships and high-dimensional power big data, and there is a risk of user privacy leakage.
The monthly time-sharing power prediction method based on federated learning is adopted, and the user's monthly time-sharing power data is collected and preprocessed, and the initial global power prediction model is constructed based on the long and short-term memory network, and the federated learning is carried out through the federated acceptance averaging algorithm to obtain the final global power prediction model.
Improves the accuracy and real-timeness of power prediction, reduces the risk of user privacy leakage, and accelerates the convergence speed of the model through FedAAVG federated learning.
Smart Images

Figure CN119561008A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a monthly time-sharing electricity forecasting method based on federated learning, and belongs to the technical field of electricity forecasting. Background Art
[0002] Power load forecasting is an important part of power system operation. Accurate power forecasting can help power companies optimize power generation plans, dispatch power resources, reduce operating costs, and ensure the stability and reliability of the power system. Traditional power forecasting methods include time series models (such as ARIMA, SARIMA, etc.) and statistical models based on regression analysis. These methods can predict future power demand to a certain extent, but their performance is often affected by the periodicity and randomness of the data, and they have limitations in dealing with complex nonlinear relationships. As the dimension of data becomes higher and higher, traditional forecasting methods face huge challenges in real-time and accuracy in the current power big data environment, and considering that using data training models will leak user privacy and security issues. Summary of the invention
[0003] In order to solve the above problems existing in the prior art, the present invention proposes a monthly time-sharing electricity consumption prediction method based on federated learning.
[0004] The technical solution of the present invention is as follows:
[0005] On the one hand, the present invention provides a monthly time-sharing electricity forecasting method based on federated learning, comprising the following steps:
[0006] Collect users' monthly time-of-use electricity data and pre-process the users' monthly time-of-use electricity data;
[0007] Construct an initial global electricity forecasting model based on long short-term memory network, and use the preprocessed user monthly time-of-use electricity data as the input of the initial global electricity forecasting model;
[0008] Based on the pre-processed monthly time-of-use electricity data of users, the initial global electricity forecasting model is federated learned through the federated accepted average algorithm to obtain the final global electricity forecasting model;
[0009] The final global power consumption prediction model is used to predict the user's monthly time-of-use power consumption.
[0010] As a preferred implementation manner of the present invention, the user's monthly time-sharing electricity data includes spring and autumn weekday electricity data, spring and autumn holiday electricity data, summer weekday electricity data and summer holiday electricity data.
[0011] As a preferred embodiment of the present invention, the initial global power prediction model based on the long short-term memory network is composed of a plurality of long short-term memory units, each of which includes a memory unit, a forget gate, an input gate, and an output gate;
[0012] Let x t is the input of the long short-term memory unit at time t, h t is the hidden state of the long-short memory unit at time t, C t is the memory unit of the long and short-term memory unit at time t;
[0013] The forget gate output f of the long short-term memory unit at time t is expressed by the following formula: t :
[0014] f t =σ(W f ·[h t-1 , x t ]+b f )
[0015] Where: W f represents the weight matrix of the forget gate; b f represents the bias term of the forget gate; h t-1 represents the hidden state of the long short-term memory unit at the t-1th moment; σ represents the Sigmoid activation function;
[0016] The input gate output i of the long short-term memory unit at time t is expressed by the following formula: t :
[0017] i t =σ(W i ·[h t-1 , x t ]+b i )
[0018] Where: W i represents the weight matrix of the input gate; b i represents the bias term of the input gate;
[0019] According to the output f of the forget gate t and the output i of the input gate t , update the memory unit C at the current moment t , as shown in the following formula:
[0020] C t =f t ·C t-1 +i t tanh(W C ·[h t-1 , x t ]+b c)
[0021] Where: C t-1 The memory unit representing the long short-term memory unit at the t-1th moment; W C represents the weight matrix of the memory unit; b c Represents the bias term of the memory unit;
[0022] The output gate output o of the long short-term memory unit at time t is expressed by the following formula t :
[0023] o t =σ(W o ·[h t-1 , x t ]+b o )
[0024] Where: W o represents the weight matrix of the output gate; b o represents the bias term of the output gate;
[0025] Based on the output gate output o t For h t Update as shown below:
[0026] h t =o t tanh(C t )
[0027] Then h t As the input of the long short-term memory unit at the next moment.
[0028] As a preferred embodiment of the present invention, the specific steps of performing federated learning on the initial global power prediction model by using the federated accepted average algorithm are:
[0029] Initializing initial global power prediction model parameters in a server, wherein the server is connected to a plurality of clients;
[0030] The server sends the initial global power prediction model to all clients. Each client trains its local initial global power prediction model with the pre-processed monthly time-of-use power data of the user saved locally, and returns the trained local power prediction model to the central server.
[0031] The server performs weighted average aggregation of the received models to obtain a new global power prediction model;
[0032] The server sends the new global power forecast model to all clients, and each client trains its local new global power forecast model using the pre-processed monthly time-of-use power data of users saved locally;
[0033] The client compares the performance of the two global power prediction models. If the performance difference between the two global power prediction models is within the preset tolerance, the client sends the trained new global power prediction model to the server, otherwise it does not send it.
[0034] The server again performs weighted average aggregation on the received models to obtain a new global power prediction model, and then sends the new global power prediction model to all clients for training;
[0035] Repeat the above steps until the target conditions are met, complete the federated learning, and obtain the final global power prediction model.
[0036] As a preferred embodiment of the present invention, the target condition is as shown in the following formula:
[0037]
[0038] f i (w) = l(x i ,y i ; w, b)
[0039] Where: f(w) is the objective function of federated learning; F k (w) is the loss of the kth client; f i (w) is the sample (x i ,y i ) loss; w, b are model parameters; P k represents the training data set stored in client k; n k Indicates P k The size of n represents the total size of all client training data sets;
[0040] When f(w) reaches the preset threshold, it is judged that the target condition is met.
[0041] As a preferred implementation of the present invention, if the performance of the previous global power prediction model is greater than the performance of the next global power prediction model, the preset tolerance is adjusted, as shown in the following formula:
[0042]
[0043] Where: β represents the preset tolerance; r represents the total number of communications between the current server and all clients; R represents the preset upper limit of the number of communications of the current server.
[0044] On the other hand, the present invention also provides a monthly time-sharing electricity forecasting system based on federated learning, including a data acquisition module, an electricity forecasting model building module, a federated learning module and an electricity forecasting module;
[0045] The data collection module is used to collect the user's monthly time-sharing electricity data and pre-process the user's monthly time-sharing electricity data;
[0046] The power forecasting model building module is used to build an initial global power forecasting model based on a long short-term memory network, and use the preprocessed user monthly time-sharing power data as the input of the initial global power forecasting model;
[0047] The federated learning module is used to perform federated learning on the initial global power prediction model through a federated accepted average algorithm based on the pre-processed user monthly time-sharing power data to obtain a final global power prediction model;
[0048] The power forecasting module is used to forecast the user's monthly time-sharing power consumption through the final global power forecasting model.
[0049] As a preferred implementation manner of the present invention, the user's monthly time-sharing electricity data includes spring and autumn weekday electricity data, spring and autumn holiday electricity data, summer weekday electricity data and summer holiday electricity data.
[0050] As a preferred embodiment of the present invention, the initial global power prediction model based on the long short-term memory network is composed of a plurality of long short-term memory units, each of which includes a memory unit, a forget gate, an input gate, and an output gate;
[0051] Let x t is the input of the long short-term memory unit at time t, h t is the hidden state of the long-short memory unit at time t, C t is the memory unit of the long and short-term memory unit at time t;
[0052] The forget gate output f of the long short-term memory unit at time t is expressed by the following formula: t :
[0053] f t =σ(W f ·[h t-1 , x t ]+b f )
[0054] Where: W f represents the weight matrix of the forget gate; b f represents the bias term of the forget gate; h t-1 represents the hidden state of the long short-term memory unit at the t-1th moment; σ represents the Sigmoid activation function;
[0055] The input gate output i of the long short-term memory unit at time t is expressed by the following formula: t :
[0056] i t =σ(W i ·[h t-1 , x t ]+b i )
[0057] Where: W i represents the weight matrix of the input gate; b i represents the bias term of the input gate;
[0058] According to the output f of the forget gate t and the output i of the input gate t , update the memory unit C at the current moment t , as shown in the following formula:
[0059] C t =f t ·C t-1 +i t tanh(W C ·[h t-1 , x t ]+b c )
[0060] Where: C t-1 The memory unit representing the long short-term memory unit at the t-1th moment; W C represents the weight matrix of the memory unit; b c Represents the bias term of the memory unit;
[0061] The output gate output o of the long short-term memory unit at time t is expressed by the following formula t :
[0062] o t =σ(W o ·[h t-1 , x t ]+b o )
[0063] Where: W o represents the weight matrix of the output gate; b o represents the bias term of the output gate;
[0064] Based on the output gate output o t For h t Update as shown below:
[0065] h t =o t tanh(C t )
[0066] Then h t As the input of the long short-term memory unit at the next moment.
[0067] As a preferred embodiment of the present invention, the specific steps of performing federated learning on the initial global power prediction model by using the federated accepted average algorithm are:
[0068] Initializing initial global power prediction model parameters in a server, wherein the server is connected to a plurality of clients;
[0069] The server sends the initial global power prediction model to all clients. Each client trains its local initial global power prediction model with the pre-processed monthly time-of-use power data of the user saved locally, and returns the trained local power prediction model to the central server.
[0070] The server performs weighted average aggregation of the received models to obtain a new global power prediction model;
[0071] The server sends the new global power forecast model to all clients, and each client trains its local new global power forecast model using the pre-processed monthly time-of-use power data of users saved locally;
[0072] The client compares the performance of the two global power prediction models. If the performance difference between the two global power prediction models is within the preset tolerance, the client sends the trained new global power prediction model to the server, otherwise it does not send it.
[0073] The server again performs weighted average aggregation on the received models to obtain a new global power prediction model, and then sends the new global power prediction model to all clients for training;
[0074] Repeat the above steps until the target conditions are met, complete the federated learning, and obtain the final global power prediction model.
[0075] As a preferred embodiment of the present invention, the target condition is as shown in the following formula:
[0076]
[0077] f i (w) = l(x i ,y i ; w, b)
[0078] Where: f(w) is the objective function of federated learning; F k (w) is the loss of the kth client; f i (w) is the sample (x i ,y i ) loss; w, b are model parameters; P k represents the training data set stored in client k; nk Indicates P k The size of n represents the total size of all client training data sets;
[0079] When f(w) reaches the preset threshold, it is judged that the target condition is met.
[0080] As a preferred implementation of the present invention, if the performance of the previous global power prediction model is greater than the performance of the next global power prediction model, the preset tolerance is adjusted, as shown in the following formula:
[0081]
[0082] Where: β represents the preset tolerance; r represents the total number of communications between the current server and all clients; R represents the preset upper limit of the number of communications of the current server.
[0083] On the other hand, the present invention further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in any embodiment of the present invention when executing the program.
[0084] In yet another aspect, the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in any embodiment of the present invention.
[0085] The present invention has the following beneficial effects:
[0086] 1. The present invention divides the data into different scenarios before prediction, and conducts monthly time-sharing electricity forecast for each type of electricity consumption scenario in a targeted manner, effectively improving the prediction accuracy.
[0087] 2. The FedAAVG federated learning adopted by the present invention trains a local model on the client and performs self-evaluation to determine whether to send the model to the server, which can improve the convergence speed and prediction performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0088] Figure 1 The figure is a flow chart of the method of the present invention. DETAILED DESCRIPTION
[0089] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0090] It should be understood that the step numbers used in this document are only for convenience of description and are not intended to limit the order in which the steps are executed.
[0091] It should be understood that the terms used in the present specification are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the present specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0092] The terms “include” and “comprising” indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0093] The term "and / or" means and includes any and all possible combinations of one or more of the associated listed items.
[0094] Embodiment 1:
[0095] See also Figure 1 , a monthly time-of-use electricity forecasting method based on federated learning, comprising the following steps:
[0096] Collect users' monthly time-of-use electricity data and pre-process the users' monthly time-of-use electricity data;
[0097] Construct an initial global electricity forecasting model based on long short-term memory network, and use the preprocessed user monthly time-of-use electricity data as the input of the initial global electricity forecasting model;
[0098] Based on the pre-processed monthly time-of-use electricity data of users, the initial global electricity forecasting model is federated learned through the federated accepted average algorithm to obtain the final global electricity forecasting model;
[0099] The final global power consumption prediction model is used to predict the user's monthly time-of-use power consumption.
[0100] As a preferred implementation of this embodiment, the user's monthly time-sharing electricity data includes spring and autumn weekday electricity data, spring and autumn holiday electricity data, summer weekday electricity data and summer holiday electricity data.
[0101] As a preferred implementation of this embodiment, the initial global power prediction model based on the long short-term memory network is composed of multiple long short-term memory units, each of which includes a memory unit, a forget gate, an input gate, and an output gate;
[0102] Let x t is the input of the long short-term memory unit at time t, ht is the hidden state of the long-short memory unit at time t, C t is the memory unit of the long and short-term memory unit at time t;
[0103] The forget gate output f of the long short-term memory unit at time t is expressed by the following formula: t :
[0104] f t =σ(W f ·[h t-1 , x t ]+b f )
[0105] Where: W f represents the weight matrix of the forget gate; b f represents the bias term of the forget gate; h t-1 represents the hidden state of the long short-term memory unit at the t-1th moment; σ represents the Sigmoid activation function;
[0106] The input gate output i of the long short-term memory unit at time t is expressed by the following formula: t :
[0107] i t =σ(W i ·[h t-1 , x t ]+b i )
[0108] Where: W i represents the weight matrix of the input gate; b i represents the bias term of the input gate;
[0109] According to the output f of the forget gate t and the output i of the input gate t , update the memory unit C at the current moment t , as shown in the following formula:
[0110] C t =f t ·C t-1 +i t tanh(W C ·[h t-1 , x t ]+b c )
[0111] Where: C t-1 The memory unit representing the long short-term memory unit at the t-1th moment; W C represents the weight matrix of the memory unit; b c Represents the bias term of the memory unit;
[0112] The output gate output o of the long short-term memory unit at time t is expressed by the following formula t :
[0113] o t =σ(W o ·[h t-1 , x t ]+b o )
[0114] Where: W o represents the weight matrix of the output gate; b o represents the bias term of the output gate;
[0115] Based on the output gate output o t For h t Update as shown below:
[0116] h t =o t tanh(C t )
[0117] Then h t As the input of the long short-term memory unit at the next moment.
[0118] As a preferred implementation of this embodiment, the specific steps of performing federated learning on the initial global power prediction model by using the federated accepted average algorithm are:
[0119] Initializing initial global power prediction model parameters in a server, wherein the server is connected to a plurality of clients;
[0120] The server sends the initial global power prediction model to all clients. Each client trains its local initial global power prediction model with the pre-processed monthly time-of-use power data of the user saved locally, and returns the trained local power prediction model to the central server.
[0121] The server performs weighted average aggregation of the received models to obtain a new global power prediction model;
[0122] The server sends the new global power forecast model to all clients, and each client trains its local new global power forecast model using the pre-processed monthly time-of-use power data of users saved locally;
[0123] The client compares the performance of the two global power prediction models. If the performance difference between the two global power prediction models is within the preset tolerance, the client sends the trained new global power prediction model to the server, otherwise it does not send it.
[0124] The server again performs weighted average aggregation on the received models to obtain a new global power prediction model, and then sends the new global power prediction model to all clients for training;
[0125] Repeat the above steps until the target conditions are met, complete the federated learning, and obtain the final global power prediction model.
[0126] As a preferred implementation of this embodiment, the target condition is as follows:
[0127]
[0128] f i (w) = l(x i ,y i ; w, b)
[0129] Where: f(w) is the objective function of federated learning; F k (w) is the loss of the kth client; f i (w) is the sample (x i ,y i ) loss; w, b are model parameters; P k represents the training data set stored in client k; n k Indicates P k The size of n represents the total size of all client training data sets;
[0130] When f(w) reaches the preset threshold, it is judged that the target condition is met.
[0131] As a preferred implementation of this embodiment, if the performance of the previous global power prediction model is greater than the performance of the next global power prediction model, the preset tolerance is adjusted, as shown in the following formula:
[0132]
[0133] Wherein: β represents the preset tolerance; r represents the total number of communications between the current server and all clients; R represents the preset upper limit of the number of communications of the current server. In this embodiment, the maximum number of communications is set to 1000.
[0134] Embodiment 2:
[0135] A monthly time-sharing electricity forecasting system based on federated learning, comprising a data acquisition module, an electricity forecasting model building module, a federated learning module and an electricity forecasting module;
[0136] The data collection module is used to collect the user's monthly time-sharing electricity data and pre-process the user's monthly time-sharing electricity data;
[0137] The power forecasting model building module is used to build an initial global power forecasting model based on a long short-term memory network, and use the preprocessed user monthly time-sharing power data as the input of the initial global power forecasting model;
[0138] The federated learning module is used to perform federated learning on the initial global power prediction model through a federated accepted average algorithm based on the pre-processed user monthly time-sharing power data to obtain a final global power prediction model;
[0139] The power forecasting module is used to forecast the user's monthly time-sharing power consumption through the final global power forecasting model.
[0140] As a preferred implementation of this embodiment, the user's monthly time-sharing electricity data includes spring and autumn weekday electricity data, spring and autumn holiday electricity data, summer weekday electricity data and summer holiday electricity data.
[0141] As a preferred implementation of this embodiment, the initial global power prediction model based on the long short-term memory network is composed of multiple long short-term memory units, each of which includes a memory unit, a forget gate, an input gate, and an output gate;
[0142] Let x t is the input of the long short-term memory unit at time t, h t is the hidden state of the long-short memory unit at time t, C t is the memory unit of the long and short-term memory unit at time t;
[0143] The forget gate output f of the long short-term memory unit at time t is expressed by the following formula: t :
[0144] f t =σ(W f ·[h t-1 , x t ]+b f )
[0145] Where: W f represents the weight matrix of the forget gate; b f represents the bias term of the forget gate; h t-1 represents the hidden state of the long short-term memory unit at the t-1th moment; σ represents the Sigmoid activation function;
[0146] The input gate output i of the long short-term memory unit at time t is expressed by the following formula: t :
[0147] i t =σ(W i ·[h t-1 , x t]+b i )
[0148] Where: W i represents the weight matrix of the input gate; b i represents the bias term of the input gate;
[0149] According to the output f of the forget gate t and the output i of the input gate t , update the memory unit C at the current moment t , as shown in the following formula:
[0150] C t =f t ·C t-1 +i t tanh(W C ·[h t-1 , x t ]+b c )
[0151] Where: C t-1 The memory unit representing the long short-term memory unit at the t-1th moment; W C represents the weight matrix of the memory unit; b c Represents the bias term of the memory unit;
[0152] The output gate output o of the long short-term memory unit at time t is expressed by the following formula t :
[0153] o t =σ(W o ·[h t-1 , x t ]+b o )
[0154] Where: W o represents the weight matrix of the output gate; b o represents the bias term of the output gate;
[0155] Based on the output gate output o t For h t Update as shown below:
[0156] h t =o t tanh(C t )
[0157] Then h t As the input of the long short-term memory unit at the next moment.
[0158] As a preferred implementation of this embodiment, the specific steps of performing federated learning on the initial global power prediction model by using the federated accepted average algorithm are:
[0159] Initializing initial global power prediction model parameters in a server, wherein the server is connected to a plurality of clients;
[0160] The server sends the initial global power prediction model to all clients. Each client trains its local initial global power prediction model with the pre-processed monthly time-of-use power data of the user saved locally, and returns the trained local power prediction model to the central server.
[0161] The server performs weighted average aggregation of the received models to obtain a new global power prediction model;
[0162] The server sends the new global power forecast model to all clients, and each client trains its local new global power forecast model using the pre-processed monthly time-of-use power data of users saved locally;
[0163] The client compares the performance of the two global power prediction models. If the performance difference between the two global power prediction models is within the preset tolerance, the client sends the trained new global power prediction model to the server, otherwise it does not send it.
[0164] The server again performs weighted average aggregation on the received models to obtain a new global power prediction model, and then sends the new global power prediction model to all clients for training;
[0165] Repeat the above steps until the target conditions are met, complete the federated learning, and obtain the final global power prediction model.
[0166] As a preferred implementation of this embodiment, the target condition is as follows:
[0167]
[0168] f i (w) = l(x i ,y i ; w, b)
[0169] Where: f(w) is the objective function of federated learning; F k (w) is the loss of the kth client; f i (w) is the sample (x i ,y i ) loss; w, b are model parameters; P k represents the training data set stored in client k; n k Indicates Pk The size of n represents the total size of all client training data sets;
[0170] When f(w) reaches the preset threshold, it is judged that the target condition is met.
[0171] As a preferred implementation of this embodiment, if the performance of the previous global power prediction model is greater than the performance of the next global power prediction model, the preset tolerance is adjusted, as shown in the following formula:
[0172]
[0173] Where: β represents the preset tolerance; r represents the total number of communications between the current server and all clients; R represents the preset upper limit of the number of communications of the current server.
[0174] Embodiment three:
[0175] This embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in any embodiment of the present invention when executing the program.
[0176] Embodiment 4:
[0177] This embodiment provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the method described in any embodiment of the present invention is implemented.
[0178] In the embodiments of the present application, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent the existence of A alone, the existence of A and B at the same time, and the existence of B alone. Among them, A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" and similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b and c can be represented by: a, b, c, a and b, a and c, b and c, or a and b and c, where a, b, c can be single or multiple.
[0179] Those of ordinary skill in the art will appreciate that the various units and algorithm steps described in the embodiments disclosed herein can be implemented in a combination of electronic hardware, computer software, and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0180] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0181] In several embodiments provided in the present application, if any function 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. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory; hereinafter referred to as: ROM), random access memory (Random Access Memory; hereinafter referred to as: RAM), disk or optical disk, and other media that can store program codes.
[0182] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A monthly time-of-use electricity forecasting method based on federated learning, characterized in that: The following steps are involved: Collect users' monthly time-of-use electricity data and pre-process the users' monthly time-of-use electricity data; Construct an initial global electricity forecasting model based on long short-term memory network, and use the preprocessed user monthly time-of-use electricity data as the input of the initial global electricity forecasting model; Based on the pre-processed monthly time-of-use electricity data of users, the initial global electricity forecasting model is federated learned through the federated accepted average algorithm to obtain the final global electricity forecasting model; The final global power consumption prediction model is used to predict the user's monthly time-of-use power consumption.
2. According to the method of monthly time-sharing electricity consumption prediction based on federated learning in claim 1, it is characterized in that: The user's monthly time-sharing electricity data includes spring and autumn working day electricity data, spring and autumn holiday electricity data, summer working day electricity data and summer holiday electricity data.
3. According to the method of monthly time-sharing electricity consumption prediction based on federated learning in claim 1, it is characterized in that: The initial global power prediction model based on the long short-term memory network is composed of a plurality of long short-term memory units, each of which includes a memory unit, a forget gate, an input gate, and an output gate; Let x t is the input of the long short-term memory unit at time t, h t is the hidden state of the long-short memory unit at time t, C t is the memory unit of the long and short-term memory unit at time t; The forget gate output f of the long short-term memory unit at time t is expressed by the following formula: t : f t =σ(W f ·[h t-1 ,x t ]+b f ) Where: W f represents the weight matrix of the forget gate; b f represents the bias term of the forget gate; h t-1 represents the hidden state of the long short-term memory unit at the t-1th moment; σ represents the Sigmoid activation function; The input gate output i of the long short-term memory unit at time t is expressed by the following formula: t : i t =σ(W i ·[h t-1 ,x t ]+b i ) Where: W i represents the weight matrix of the input gate; b i represents the bias term of the input gate; According to the output f of the forget gate t and the output i of the input gate t , update the memory unit C at the current moment t , as shown in the following formula: C t =f t ·C t-1 +i t ·tanh(W C ·[h t-1 ,x t ]+b c ) Where: C t-1 The memory unit representing the long short-term memory unit at the t-1th moment; W C represents the weight matrix of the memory unit; b c Represents the bias term of the memory unit; The output gate output o of the long short-term memory unit at time t is expressed by the following formula t : the t =σ(W o ·[h t-1 ,x t ]+b o ) Where: W o represents the weight matrix of the output gate; b o Represents the bias term of the output gate; Based on the output gate output o t For h t Update as shown below: h t =o t ·tanh(C t ) Then h t As the input of the long short-term memory unit at the next moment.
4. According to the method of monthly time-sharing electricity consumption prediction based on federated learning in claim 1, it is characterized in that: The specific steps of performing federated learning on the initial global power prediction model through the federated accepted average algorithm are as follows: Initializing initial global power prediction model parameters in a server, wherein the server is connected to a plurality of clients; The server sends the initial global power prediction model to all clients. Each client trains its local initial global power prediction model with the pre-processed monthly time-of-use power data of the user saved locally, and returns the trained local power prediction model to the central server. The server performs weighted average aggregation of the received models to obtain a new global power prediction model; The server sends the new global power forecast model to all clients, and each client trains its local new global power forecast model using the pre-processed monthly time-of-use power data of users saved locally; The client compares the performance of the two global power prediction models. If the performance difference between the two global power prediction models is within the preset tolerance, the client sends the trained new global power prediction model to the server, otherwise it does not send it. The server again performs weighted average aggregation on the received models to obtain a new global power prediction model, and then sends the new global power prediction model to all clients for training; Repeat the above steps until the target conditions are met, complete the federated learning, and obtain the final global power prediction model.
5. A monthly time-sharing electricity forecasting method based on federated learning according to claim 4, characterized in that: The target condition is as follows: f i (w)=l(x i ,y i ;w,b) Where: f(w) is the objective function of federated learning; F k (w) is the loss of the kth client; f i (w) is the sample (x i ,y i ) loss; w, b are model parameters; P k represents the training data set stored in client k; n k Indicates P k The size of n represents the total size of all client training data sets; When f(w) reaches the preset threshold, it is judged that the target condition is met.
6. A monthly time-sharing electricity forecasting method based on federated learning according to claim 4, characterized in that: If the performance of the previous global power forecast model is greater than that of the next global power forecast model, the preset tolerance is adjusted, as shown in the following formula: Where: β represents the preset tolerance; r represents the total number of communications between the current server and all clients; R represents the preset upper limit of the number of communications of the current server.
7. A monthly time-of-use electricity forecasting system based on federated learning, characterized in that: It includes data collection module, power forecasting model building module, federated learning module and power forecasting module; The data collection module is used to collect the user's monthly time-sharing electricity data and pre-process the user's monthly time-sharing electricity data; The power forecasting model building module is used to build an initial global power forecasting model based on a long short-term memory network, and use the preprocessed user monthly time-sharing power data as the input of the initial global power forecasting model; The federated learning module is used to perform federated learning on the initial global power prediction model through a federated accepted average algorithm based on the pre-processed user monthly time-sharing power data to obtain a final global power prediction model; The power forecasting module is used to forecast the user's monthly time-sharing power consumption through the final global power forecasting model.
8. A monthly time-sharing electricity forecasting system based on federated learning according to claim 7, characterized in that: The user's monthly time-sharing electricity data includes spring and autumn working day electricity data, spring and autumn holiday electricity data, summer working day electricity data and summer holiday electricity data.
9. The monthly time-sharing electricity forecasting system based on federated learning according to claim 7, characterized in that: The initial global power prediction model based on the long short-term memory network is composed of a plurality of long short-term memory units, each of which includes a memory unit, a forget gate, an input gate, and an output gate; Let x t is the input of the long short-term memory unit at time t, h t is the hidden state of the long-short memory unit at time t, C t is the memory unit of the long and short-term memory unit at time t; The forget gate output f of the long short-term memory unit at time t is expressed by the following formula: t : f t =σ(W f ·[h t-1 ,x t ]+b f ) Where: W f represents the weight matrix of the forget gate; b f represents the bias term of the forget gate; h t-1 represents the hidden state of the long short-term memory unit at the t-1th moment; σ represents the Sigmoid activation function; The input gate output i of the long short-term memory unit at time t is expressed by the following formula: t : i t =σ(W i ·[h t-1 ,x t ]+b i ) Where: W i represents the weight matrix of the input gate; b i represents the bias term of the input gate; According to the output f of the forget gate t and the output i of the input gate t , update the memory unit C at the current moment t , as shown in the following formula: C t =f t ·C t-1 +i t ·tanh(W C ·[h t-1 ,x t ]+b c ) Where: C t-1 The memory unit representing the long short-term memory unit at the t-1th moment; W C represents the weight matrix of the memory unit; b c Represents the bias term of the memory unit; The output gate output o of the long short-term memory unit at time t is expressed by the following formula t : the t =σ(W o ·[h t-1 ,x t ]+b o ) Where: W o represents the weight matrix of the output gate; b o Represents the bias term of the output gate; Based on the output gate output o t For h t Update as shown below: h t =o t ·tanh(C t ) Then h t As the input of the long short-term memory unit at the next moment.
10. A monthly time-sharing electricity forecasting system based on federated learning according to claim 7, characterized in that: The specific steps of performing federated learning on the initial global power prediction model through the federated accepted average algorithm are as follows: Initializing initial global power prediction model parameters in a server, wherein the server is connected to a plurality of clients; The server sends the initial global power prediction model to all clients. Each client trains its local initial global power prediction model with the pre-processed monthly time-of-use power data of the user saved locally, and returns the trained local power prediction model to the central server. The server performs weighted average aggregation of the received models to obtain a new global power prediction model; The server sends the new global power forecast model to all clients, and each client trains its local new global power forecast model using the pre-processed monthly time-of-use power data of users saved locally; The client compares the performance of the two global power prediction models. If the performance difference between the two global power prediction models is within the preset tolerance, the client sends the trained new global power prediction model to the server, otherwise it does not send it. The server again performs weighted average aggregation on the received models to obtain a new global power prediction model, and then sends the new global power prediction model to all clients for training; Repeat the above steps until the target conditions are met, complete the federated learning, and obtain the final global power prediction model.
11. A monthly time-sharing electricity forecasting system based on federated learning according to claim 10, characterized in that: The target condition is as follows: f i (w)=l(x i ,y i ;w,b) Where: f(w) is the objective function of federated learning; F k (w) is the loss of the kth client; f i (w) is the sample (x i ,y i ) loss; w, b are model parameters; P k represents the training data set stored in client k; n k Indicates P k The size of n represents the total size of all client training data sets; When f(w) reaches the preset threshold, it is judged that the target condition is met.
12. A monthly time-sharing electricity forecasting system based on federated learning according to claim 10, characterized in that: If the performance of the previous global power forecast model is greater than that of the next global power forecast model, the preset tolerance is adjusted, as shown in the following formula: Where: β represents the preset tolerance; r represents the total number of communications between the current server and all clients; R represents the preset upper limit of the number of communications of the current server.
13. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 6 is implemented.
14. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Cited By
AI-based dynamic allocation method and system for electricity quantity declaration of electricity selling enterprise
CN120875951A
AI-based power selling enterprise power declaration dynamic allocation method and system
CN120875951B