Non-intrusive load monitoring method based on reinforcement learning and attention mechanism
By combining reinforcement learning and attention mechanisms in household load monitoring, using a combined model of convolutional neural networks and attention mechanism layers, the problem of low accuracy of deep learning networks at small parameter scales is solved, and multi-state High-precision disaggregation of appliances and efficient training of models.
Patent Information
- Application Number
- CN202410789045.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-19
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2044-06-19
AI Technical Summary
Existing deep learning networks cannot guarantee accuracy in household load monitoring scenarios containing multi-state appliances at small parameter scales, and it is difficult to deploy large parameter scale models.
A non-intrusive load monitoring method based on reinforcement learning and attention mechanism is adopted, combining one-dimensional convolutional network, attention mechanism layer and fully connected network, using deep deterministic policy gradient training model, and optimizing model parameters through pruning technology. A learning model consisting of convolutional neural network and attention mechanism layers is formed.
It ensures high-precision deaggregation of multi-state electrical appliances under a smaller parameter scale, improves the accuracy of home load monitoring and the training efficiency of the model, and is suitable for home non-intrusive load monitoring scenarios.
Smart Images

Figure CN118364866B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of power load monitoring, and in particular to a non-intrusive load monitoring method based on reinforcement learning and attention mechanism. Background Art
[0002] With the continuous development of the economy and society, the amount of electricity consumed by residents has increased year by year, which has put forward higher requirements for the dispatching and distribution of electricity. In addition, the purpose of energy conservation can be achieved by rationally dispatching and distributing this part of electricity. The rational dispatching and distribution of electric energy depends on accurate power monitoring methods. At the same time, monitoring of abnormal electricity behavior of residents can troubleshoot the failure of equipment in residents' homes and take protective measures in advance to ensure the safety of residents' lives and property. Therefore, improving the monitoring ability of residents' electricity behavior is of great significance to energy security and sustainable development.
[0003] Common monitoring methods in the field of load monitoring are divided into intrusive load monitoring methods and non-intrusive load monitoring methods. The former deploys load monitoring equipment at all electrical appliances connected to the bus, and each monitoring device works independently of each other. This type of method has high monitoring accuracy, but there is a problem of complex equipment deployment process, which makes it difficult to apply it to home power monitoring scenarios on a large scale. The latter only deploys load monitoring equipment at the bus and uses recognition algorithms to analyze the characteristics of aggregated power data on the bus to identify the status of electrical appliances on the bus. This type of method is simple to deploy and low-cost, and is suitable for deployment in home scenarios. However, the monitoring accuracy of this type of method depends on the performance of the recognition algorithm. The current mainstream algorithms are divided into two categories: recognition algorithms based on machine learning and recognition algorithms based on deep learning. Based on traditional machine learning methods, decision trees, K-means clustering algorithms, support vector machines, hidden Markov chains and other models are used to continuously train the model to establish the corresponding relationship between the current bus data differential change or probability distribution state and the type of electrical appliances. At the same time, in order to improve the accuracy of the model, a large number of scholars have improved and combined decision trees, support vector machines and K-means clustering algorithms in traditional machine learning algorithms, and produced a variety of high-precision algorithms.
[0004] At present, the non-intrusive load data recognition algorithm designed based on traditional machine learning has good performance when the number of electrical appliance categories is small, but the accuracy decreases as the number of electrical appliances increases. The deep learning network uses data to train a nonlinear model, and uses the trained model to disaggregate the non-intrusive load monitoring data to obtain the working status of the electrical appliances on the bus at the current moment. Compared with the former, the deep learning network performs better in scenarios with complex types of electrical equipment and has better application prospects. However, in the non-intrusive load monitoring scenario of a household containing multi-state electrical appliances, the accuracy of the existing deep learning network to disaggregate multi-state electrical appliances depends on the parameter scale of the model. Under a small parameter scale, the model's disaggregation accuracy for multi-state electrical appliances is not high. However, it is difficult to deploy a model with a large parameter scale in the actual household load monitoring scenario, which makes the existing deep learning model difficult to deploy.
[0005] In summary, existing deep learning networks cannot guarantee their accuracy in household load monitoring scenarios containing multi-state appliances at a small parameter scale. Summary of the invention
[0006] The present invention solves the problem that the existing deep learning network cannot guarantee its accuracy in a household load monitoring scenario containing multi-state electrical appliances at a small parameter scale.
[0007] The non-intrusive load monitoring method based on reinforcement learning and attention mechanism of the present invention comprises the following steps:
[0008] Step S1, initializing the evaluation actor network, the evaluation comment network, the target actor network, the target comment network, multiple parameters and the environment respectively;
[0009] Step S2, evaluating the interaction between the actor network and the environment, and storing the interaction results in a cache area;
[0010] Step S3, batch sampling the data in the buffer area, and sending the sampled data to the evaluation actor network, the evaluation comment network, the target actor network and the target comment network respectively to obtain the results;
[0011] Step S4, calculating the loss according to the result obtained in step S3, optimizing the evaluation-critic network according to the loss, using the optimized evaluation-critic network to calculate the loss of the evaluation-actor network, and updating the evaluation-actor network;
[0012] Step S5, soft-update the target comment network based on the evaluation comment network, and soft-update the target actor network based on the evaluation actor network;
[0013] Step S6, determining whether the evaluation actor network, evaluation comment network, target actor network and target comment network obtained in step S5 meet the termination training conditions, if so, executing step S7, if not, executing steps S2 to S6;
[0014] Step S7, performing pruning operations on the evaluation actor network, the evaluation comment network, the target actor network, and the target comment network respectively;
[0015] The evaluation actor network and target actor network include:
[0016] Several layers of one-dimensional convolutional networks, several units consisting of attention mechanism layers and fully connected networks, and fully connected networks.
[0017] Further, in one embodiment of the present invention, in step S1, the evaluation actor network, the evaluation comment network, the target actor network, the target comment network, the multiple parameters and the environment are respectively initialized, including the following steps:
[0018] Step S101, designing an evaluation actor network, an evaluation comment network, a target actor network and a target comment network based on multiple data and initializing them;
[0019] Step S102, initializing the environment based on multiple data.
[0020] Furthermore, in one embodiment of the present invention, the multiple data include sliding window length, total data length, each type of electrical appliance, all electrical appliances, aggregated power data and single appliance power data.
[0021] Further, in one embodiment of the present invention, in step S2, the evaluation actor network interacts with the environment and stores the interaction result in a cache area, including the following steps:
[0022] Step S201, the environment gives a random state or a specified state, and the actor network is evaluated to give an action;
[0023] Step S202: The environment gives feedback based on the input action. The state of the moment;
[0024] Step S203: random state, action, feedback and The status at each moment is stored in the cache area;
[0025] Step S204, determine whether the buffer area stores a specified number of data groups. If yes, execute step S3. If not, execute step S4. The state at the moment is that the environment gives a specified state and repeats steps S201 to S204.
[0026] Further, in one embodiment of the present invention, in the step S6, it is determined whether the model obtained in the step S5 meets the termination training condition. If so, step S7 is executed; if not, steps S2 to S6 are executed, including the following steps:
[0027] Step S601, respectively determine whether the training trajectories of the evaluation actor network, the evaluation comment network, the target actor network and the target comment network are completed. If so, execute step S602. If not, set the environment The state of the moment is given as the environment to execute steps S2 to S5 in the specified state;
[0028] Step S602, determine whether the model obtained in step S601 has reached the maximum training rounds, if so, execute step S7, if not, execute steps S2 to S6.
[0029] Further, in one embodiment of the present invention, in step S7, the pruning operation is performed on the evaluation actor network, the evaluation comment network, the target actor network and the target comment network respectively, including the following steps:
[0030] Step S701, performing pruning and fine-tuning operations on the evaluation actor network, evaluation comment network, target actor network and target comment network of different electrical appliances respectively;
[0031] Step S702, testing the evaluation actor network, the evaluation comment network, the target actor network, and the target comment network respectively and observing their performance, retaining a certain proportion of parameters, and starting to train the evaluation actor network, the evaluation comment network, the target actor network, and the target comment network respectively;
[0032] Step S703, after training for multiple rounds, testing is performed again, a certain proportion of parameters are removed, and the evaluation actor network, the evaluation comment network, the target actor network, and the target comment network are trained again;
[0033] Step S704, repeating step S3 until the parameter is lower than a certain ratio;
[0034] Step S705, observing the performance of the evaluation actor network, the evaluation comment network, the target actor network and the target comment network on different appliances, and selecting the strategy with the best average performance;
[0035] Step S706, observe the optimal strategy of step S705, compare the curves of different electrical appliance performances changing with parameter scales, select the parameter scale corresponding to the inflection point on the curve, and use the largest parameter scale as the pruning parameter of the evaluation actor network, the evaluation comment network, the target actor network, and the target comment network;
[0036] Step S707, fine-tune the evaluation actor network, the evaluation comment network, the target actor network, and the target comment network using the optimal strategy of step S705 and the parameter scale of step S706 respectively until the accuracy no longer changes.
[0037] The non-intrusive load monitoring system based on reinforcement learning and attention mechanism of the present invention comprises the following modules:
[0038] The data module initializes the evaluation actor network, evaluation comment network, target actor network, target comment network, multiple parameters and environment respectively;
[0039] The interaction module evaluates the interaction between the actor network and the environment and stores the interaction results in the cache;
[0040] The sampling module performs batch sampling on the data in the buffer area and sends the sampled data to the evaluation actor network, the evaluation comment network, the target actor network and the target comment network to obtain the results;
[0041] The optimization module calculates the loss based on the results obtained by the sampling module, optimizes the evaluation-critic network based on the loss, uses the optimized evaluation-critic network to calculate the loss of the evaluation-actor network, and updates the evaluation-actor network;
[0042] The update module soft-updates the target comment network based on the evaluation comment network and the target actor network based on the evaluation actor network;
[0043] A judgment module determines whether the evaluation actor network, evaluation comment network, target actor network and target comment network obtained by the update module meet the termination training conditions. If so, the pruning module is executed; if not, the interaction module to the judgment module are executed;
[0044] The pruning module performs pruning operations on the evaluation actor network, evaluation comment network, target actor network and target comment network respectively.
[0045] An electronic device described in the present invention comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0046] Memory, used to store computer programs;
[0047] The processor is used to implement the above method steps when executing the program stored in the memory.
[0048] The computer-readable storage medium of the present invention stores a computer program, and the computer program implements the above method steps when executed by a processor.
[0049] The present invention solves the problem that the existing deep learning network cannot guarantee its accuracy in a household load monitoring scenario containing multi-state electrical appliances at a small parameter scale. Specific beneficial effects include:
[0050] 1. The non-intrusive load monitoring method based on reinforcement learning and attention mechanism described in the present invention, the accuracy of the existing deep learning network to deaggregate multi-state appliances depends on the parameter scale of the model. At a small parameter scale, the accuracy of the model to deaggregate multi-state appliances is not high. However, it is difficult to deploy models with large parameter scales in actual household load monitoring scenarios, which makes it difficult to deploy existing deep learning models. In order to solve the above technical problems, the present invention combines the attention mechanism model, convolutional neural network and deep deterministic policy gradient, a reinforcement learning method, so that the finally generated model can ensure its accuracy in household load monitoring scenarios containing multi-state appliances at a smaller parameter scale;
[0051] 2. The non-intrusive load monitoring method based on reinforcement learning and attention mechanism described in the present invention, the existing attention mechanism model cannot be directly used in the field of load monitoring. In order to solve the above technical problems, the present invention uses convolutional neural networks to perform feature extraction to replace the data processing methods in the field of large language models, thereby forming a learning model composed of a convolutional layer, an attention mechanism layer and a fully connected layer, and uses a deep deterministic policy gradient training model to effectively solve the problem that the existing attention mechanism model cannot be directly used in the field of load monitoring;
[0052] 3. The non-intrusive load monitoring method based on reinforcement learning and attention mechanism described in the present invention, the deep deterministic policy gradient training method uses the evaluation actor network, the evaluation comment network, the target actor network and the target comment network for interactive training, which improves the training efficiency of the model;
[0053] The non-intrusive load monitoring method based on reinforcement learning and attention mechanism described in the present invention can realize high-precision disaggregation of load monitoring data, especially multi-state electrical appliances. Simulation experiments show that the present invention has good performance for both switch states and multi-state electrical appliances in household non-intrusive load monitoring scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] The above and / or additional aspects and advantages of the present invention will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0055] Figure 1 It is the overall design diagram described in the first embodiment;
[0056] Figure 2 The attention mechanism model and convolutional neural network design diagram described in Implementation Method 1;
[0057] Figure 3 It is a test result diagram of the UK-DALE data set (non-intrusive load decomposition data set) and the REDD data set (non-intrusive load decomposition data set) described in the fifth implementation mode under the SAE index;
[0058] Figure 4 This is a test result chart of the UK-DALE dataset and the REDD dataset described in Implementation Mode 5 under the MAE indicator. DETAILED DESCRIPTION
[0059] The following will clearly and completely describe various embodiments of the present invention in conjunction with the accompanying drawings. The embodiments described with reference to the accompanying drawings are exemplary and intended to be used to explain the present invention, but should not be understood as limiting the present invention.
[0060] Implementation method 1: The non-intrusive load monitoring method based on reinforcement learning and attention mechanism described in this implementation method comprises the following steps:
[0061] Step S1, initializing the evaluation actor network, the evaluation comment network, the target actor network, the target comment network, multiple parameters and the environment respectively;
[0062] Step S2, evaluating the interaction between the actor network and the environment, and storing the interaction results in a cache area;
[0063] Step S3, batch sampling the data in the buffer area, and sending the sampled data to the evaluation actor network, the evaluation comment network, the target actor network and the target comment network respectively to obtain the results;
[0064] Step S4, calculating the loss according to the result obtained in step S3, optimizing the evaluation-critic network according to the loss, using the optimized evaluation-critic network to calculate the loss of the evaluation-actor network, and updating the evaluation-actor network;
[0065] Step S5, soft-update the target comment network based on the evaluation comment network, and soft-update the target actor network based on the evaluation actor network;
[0066] Step S6, determining whether the evaluation actor network, evaluation comment network, target actor network and target comment network obtained in step S5 meet the termination training conditions, if so, executing step S7, if not, executing steps S2 to S6;
[0067] Step S7, pruning operations are performed on the evaluation actor network, the evaluation comment network, the target actor network and the target comment network respectively.
[0068] The accuracy of existing deep learning networks in disaggregating multi-state appliances depends on the parameter scale of the model. When the parameter scale is small, the accuracy of the model in disaggregating multi-state appliances is not high. However, it is difficult to deploy models with large parameter scales in actual household load monitoring scenarios, which makes it difficult to deploy existing deep learning networks.
[0069] In order to solve the above technical problems, this embodiment designs a method of combining an attention mechanism model with a convolutional neural network. Although the attention mechanism model has been widely used in large language models and has achieved good results, the data processing method in the large language model is not suitable for the field of load disaggregation, resulting in the attention mechanism model cannot be directly used in the field of load monitoring.
[0070] Therefore, if Figure 1 As shown, the model used by the evaluation actor network and the target actor network is a combination of an attention mechanism model and a convolutional neural network, and the model used by the evaluation critic network and the target critic network is a convolutional neural network.
[0071] Evaluate the interaction between the actor network and the environment and store the interaction results in a cache;
[0072] Perform small batch sampling on the data in the buffer area, and send the current state of the sampled data to the evaluation actor network and the evaluation comment network, and the next state to the target actor network and the target comment network to obtain the result;
[0073] Calculate the loss based on the obtained results, optimize the evaluation-critic network based on the loss, use the optimized evaluation-critic network to calculate the loss of the evaluation-actor network, and update the evaluation-actor network;
[0074] The target comment network is soft-updated based on the evaluation comment network, and the target actor network is soft-updated based on the evaluation actor network;
[0075] Pruning operations are performed on the evaluation actor network, evaluation comment network, target actor network, and target comment network respectively.
[0076] Therefore, in this training process, the convolutional neural network solves the problem that the attention mechanism model cannot be directly applied to the load monitoring field by performing convolution operations on the original data. At the same time, the model trained by this method has the problem of redundant parameters. For this reason, the pruning method is used to remove the redundant parameters of the model and reduce the storage cost of the model.
[0077] Moreover, the use of a model that combines an attention mechanism model and a convolutional neural network and training with deep deterministic policy gradients improves the accuracy of load monitoring and solves the problem that existing deep learning networks cannot guarantee their accuracy in household load monitoring scenarios containing multi-state appliances at a small parameter scale.
[0078] In this embodiment, the evaluation actor network and the target actor network include:
[0079] Several layers of one-dimensional convolutional networks, several units consisting of attention mechanism layers and fully connected networks, and fully connected networks.
[0080] In this embodiment, if Figure 2 As described above, the structure of the combination of the attention mechanism model and the convolutional neural network includes m layers of one-dimensional convolutional networks, n layers of attention mechanism layers and fully connected networks, and fully connected networks.
[0081] The specific process of processing load data in the structure of the combination of attention mechanism model and convolutional neural network is as follows:
[0082] Step S1001, load data and After m layers of one-dimensional convolutional network, the convolution data is obtained , where the convolution kernel parameters and the number of layers can be adjusted according to the data characteristics. For example, for the REDD and UK-DALE load data, three layers of one-dimensional convolution are used, with convolution kernel sizes of 9, 7, and 5, and the number of channels of 24, 48, and 48 respectively;
[0083] Step S1002: The load data passes through two layers of modules consisting of an attention mechanism and a fully connected network. In this module, the attention mechanism layer convolves the data Multiply by the matrix in the attention mechanism module respectively , and get , and ,Right now:
[0084] ;
[0085] ;
[0086] ;
[0087] in, is the transpose of the convolution data, is the query matrix, is the keyword matrix, is the value matrix;
[0088] Step S1003, the attention mechanism layer uses the formula:
[0089] ;
[0090] in, is the output result, d is the hyperparameter, is the transpose of the query matrix. The hyperparameter d can be adjusted according to the actual situation of the parameter. For example, for relevant data, the hyperparameter Set to 48;
[0091] The Softmax function (normalized exponential function) is defined as:
[0092] ;
[0093] ;
[0094] in, is the input vector, for The number of elements in
[0095] Step S1004, the module Send it to the fully connected network for processing and get Right now:
[0096] ;
[0097] in, is the output after processing by the fully connected network;
[0098] Its mathematical expression is as follows:
[0099] ;
[0100] in, For input data, are the bias matrices of the first and second layer fully connected networks, respectively. They are the parameter matrices of the first and second layer fully connected networks respectively.
[0101] The ReLU function is the activation function, and its expression is: , For input data;
[0102] Step S1005: the data processed by the previous two modules Send to the last layer of fully connected network (same as the FCN function processing flow described in step S1004 but with different parameters);
[0103] That is, this embodiment adds a convolutional neural network to the attention mechanism module and uses the convolutional neural network for feature extraction to replace the data processing method in the field related to the large language model, thereby forming a learning model composed of a convolutional layer, an attention mechanism layer and a fully connected layer.
[0104] Implementation method 2: This implementation method further limits the non-intrusive load monitoring method based on reinforcement learning and attention mechanism described in implementation method 1. In step S1, the evaluation actor network, the evaluation comment network, the target actor network, the target comment network, the multiple parameters and the environment are initialized respectively, including the following steps:
[0105] Step S101, designing an evaluation actor network, an evaluation comment network, a target actor network and a target comment network based on multiple data and initializing them;
[0106] Step S102, initializing the environment based on multiple data.
[0107] In this implementation manner, the multiple data include sliding window length, total data length, each type of electrical appliance, all electrical appliances, aggregated power data and single appliance power data.
[0108] In this implementation, the following steps are included:
[0109] Step S101: The user inputs the sliding window length , total data length , each appliance is defined as , all electrical appliances are defined as , aggregate power data And individual electrical power data ;
[0110] Step S102, the user determines the structures of the design evaluation actor network, the evaluation comment network, the target actor network and the target comment network according to the multiple parameters described in step S101 and initializes the parameters therein;
[0111] Step S103, the evaluation review network and the target review network are multi-layer fully convolutional networks. This embodiment uses a 6-layer fully convolutional network, an evaluation actor network, and a target actor network as a mode combining a convolutional neural network with an attention mechanism;
[0112] Step S104, initializing the environment according to the multiple data in step S101, wherein the environment is responsible for outputting the state , which accepts the action input from the actor network ( t ) and send feedback Specifically, the environment is a function, and the state is first output in each iteration. and target results (t), state is input into the evaluation actor network, and then the environment gets the estimated value of the evaluation actor network , reuse and Get feedback based on the formula The three are defined as:
[0113] ;
[0114] state Represents any time ( +1) to Power data over time, where It is an odd number, and the length is 65 in the present invention.
[0115] ;
[0116] action (t) represents the output of the actor network Electrical appliances The decomposition result of the moment.
[0117] ;
[0118] feedback Represents the environment's evaluation of the action output by the network.
[0119] Implementation method 3: This implementation method is a further limitation of the non-intrusive load monitoring method based on reinforcement learning and attention mechanism described in implementation method 1. In step S2, the evaluation actor network interacts with the environment and stores the interaction results in a cache area, including the following steps:
[0120] Step S201, the environment gives a random state or a specified state, and the actor network is evaluated to give an action;
[0121] Step S202: The environment gives feedback based on the input action. The state of the moment;
[0122] Step S203: random state, action, feedback and The status at each moment is stored in the cache area;
[0123] Step S204, determine whether the buffer area stores a specified number of data groups. If yes, execute step S3. If not, execute step S4. The state at the moment is that the environment gives a specified state and repeats steps S201 to S204.
[0124] In this implementation, the following steps are included:
[0125] Step S201: The environment gives a random state ;
[0126] Step S202: Evaluate the action given by the actor network ;
[0127] Step S203: The environment responds to the action according to the feedback function defined in step S104. Give Feedback ;
[0128] Step S204, the environment is given Status of the moment ;
[0129] Step S205: Store in the cache;
[0130] Step S206, determine whether the buffer area stores a specified number of data groups, if so, execute step S3, if not, Execute steps S202 to S206 for the initial state.
[0131] The step S3 comprises the following steps:
[0132] Step S301, taking out K sequences from the buffer to form a data sequence;
[0133] Step S302: Send it to the evaluation actor network and the evaluation comment network, Send it to the target actor network and target comment network for processing, and get the output results of the relevant networks;
[0134] Step S303, using steps S031 and S302 to process all data in the data sequence.
[0135] The step S4 comprises the following steps:
[0136] Step S401, in the evaluation and comment network, firstly, the TD (temporal difference) value is calculated using the target actor network and the target evaluation network according to the following formula:
[0137] ;
[0138] in, is the discount parameter, which is set to 0.99 in the present invention. is the target comment network model, and the input is the target actor network action , Load data at the next moment , the output is feedback, is the target actor network model, and the input is the load sequence at the next moment Output Action , are the target actor network parameters, To identify and evaluate the actor network;
[0139] Step S402, calculate TD-error (temporal difference-loss):
[0140] ;
[0141] in, To evaluate the review network parameters, is the sequence length, To evaluate the network model, is the kth sequence in the data, The load data of the kth sequence in the data is sent to the actor network for processing and then outputs the action. is the value calculated in step S401 for the kth sequence in the data;
[0142] Step S403, update the evaluation comment network parameters using the formula:
[0143] ;
[0144] in, To evaluate the network learning rate, the present invention is set to ;
[0145] Step S404, after updating the evaluation and comment network parameters, the evaluation and comment network is used to calculate the evaluation actor network, namely:
[0146] ;
[0147] in, are the target actor network parameters, is the alphabetic representation of the target actor network, For the current moment, is the data length, For the target review network, For status, For time, is the right-hand subcode;
[0148] Step S405, the actor evaluation network optimizes the network according to the evaluation value of the comment evaluation network, that is, solves the problem:
[0149] ;
[0150] The gradient method is used to solve this problem, namely:
[0151] ;
[0152] in, is the learning rate of the target actor network, which is set to .
[0153] The step S5 comprises the following steps:
[0154] Step S501, soft update the target actor network;
[0155] ;
[0156] in, are the target actor network parameters, To update the parameters, the present invention sets it to 0.005, is the alphabetical representation of the target actor network;
[0157] Step S502: soft update the target comment network:
[0158] ;
[0159] in, The parameters of the target review network, To update the parameters, the present invention sets it to 0.005, To evaluate the review network parameters, The target comment network letter representation is Alphabetical representation of the review network for evaluation.
[0160] Implementation method 4: This implementation method is a further limitation of the non-intrusive load monitoring method based on reinforcement learning and attention mechanism described in implementation method 1. In step S6, it is determined whether the trained evaluation actor network, evaluation comment network, target actor network and target comment network meet the training conditions. If so, step S7 is executed. If not, steps S2 to S6 are executed, including the following steps:
[0161] Step S601, respectively determine whether the training trajectories of the evaluation actor network, the evaluation comment network, the target actor network and the target comment network are completed. If so, execute step S602. If not, set the environment The state at that moment is executed as the initial state in steps S2 to S5;
[0162] Step S602, determine whether the model obtained in step S601 has reached the maximum training rounds, if so, execute step S7, if not, execute steps S2 to S6.
[0163] In this implementation manner, the step S6 includes the following steps:
[0164] Step S601, the program determines whether the training trajectory is completed. If so, step S601 is executed. If not, Execute steps S202 to S502 as an initial state;
[0165] Step S602, determine whether the maximum number of training rounds has been reached, if so, execute step S7, if not, execute steps S2 to S6.
[0166] Embodiment 5: This embodiment further limits the non-intrusive load monitoring method based on reinforcement learning and attention mechanism described in embodiment 1. In step S7, the evaluation actor network, the evaluation comment network, the target actor network and the target comment network are pruned respectively, including the following steps:
[0167] Step S701, performing pruning and fine-tuning operations on the evaluation actor network, evaluation comment network, target actor network and target comment network of different electrical appliances respectively;
[0168] Step S702, testing the evaluation actor network, the evaluation comment network, the target actor network, and the target comment network respectively and observing their performance, retaining a certain proportion of parameters, and starting to train the evaluation actor network, the evaluation comment network, the target actor network, and the target comment network respectively;
[0169] Step S703, after training for multiple rounds, testing is performed again, a certain proportion of parameters are removed, and the evaluation actor network, the evaluation comment network, the target actor network, and the target comment network are trained again;
[0170] Step S704, repeating step S3 until the parameter is lower than a certain ratio;
[0171] Step S705, observing the performance of the evaluation actor network, the evaluation comment network, the target actor network and the target comment network on different appliances, and selecting the strategy with the best average performance;
[0172] Step S706, observe the optimal strategy of step S705, compare the curves of different electrical appliance performances changing with parameter scales, select the parameter scale corresponding to the inflection point on the curve, and use the largest parameter scale as the pruning parameter of the evaluation actor network, the evaluation comment network, the target actor network, and the target comment network;
[0173] Step S707, fine-tune the evaluation actor network, the evaluation comment network, the target actor network, and the target comment network using the optimal strategy of step S705 and the parameter scale of step S706 respectively until the accuracy no longer changes.
[0174] In this implementation manner, the step S7 includes the following steps:
[0175] Step S701, using 1-norm, 2-norm and Taylor expansion as pruning strategies for the evaluation actor network, evaluation comment network, target actor network and target comment network, respectively, and performing pruning and fine-tuning operations on the evaluation actor network, evaluation comment network, target actor network and target comment network of different electrical appliances. Among them, the 1-norm and 2-norm strategy methods retain the corresponding parameters with larger norms in the evaluation actor network, evaluation comment network, target actor network and target comment network, and the Taylor strategy retains the corresponding parameters with larger values after the first-order Taylor expansion in the evaluation actor network, evaluation comment network, target actor network and target comment network, thereby reducing the storage consumption of the evaluation actor network, evaluation comment network, target actor network and target comment network;
[0176] Step S702, first test the evaluation actor network, the evaluation comment network, the target actor network and the target comment network to observe their performance, then retain a certain proportion of parameters, such as 95%, and start training the evaluation actor network, the evaluation comment network, the target actor network and the target comment network.
[0177] Step S703, after a certain number of training rounds, for example, 1000 rounds, the test is performed again, and then a certain proportion of parameters, for example, 5%, are removed, and the training of the evaluation actor network, the evaluation comment network, the target actor network, and the target comment network is started again;
[0178] Step S704, repeating step S703 until the parameters of the evaluation actor network, the evaluation comment network, the target actor network, and the target comment network are lower than a certain ratio, such as 50%;
[0179] Step S705, observing the performance of different strategies on different appliances, and selecting the strategy with the best average performance;
[0180] Step S706, observing the optimal strategy in step S705, comparing the curves of different electrical appliance performances changing with parameter scales, selecting the parameter scale corresponding to the inflection point on the curve, and using the largest parameter scale as the pruning parameter of the evaluation actor network, the evaluation comment network, the target actor network, and the target comment network;
[0181] Step S707, fine-tune the evaluation actor network, the evaluation comment network, the target actor network, and the target comment network using the optimal strategy in step S705 and the parameter scale in step S706 until the accuracy does not change significantly.
[0182] In order to better illustrate the non-intrusive load monitoring method based on reinforcement learning and attention mechanism described in the above embodiment, it is described in detail through the following examples:
[0183] The software used in the simulation experiment is PyCharm (integrated development environment) software and PyTorch (open source machine learning framework) framework.
[0184] This paper uses two datasets, UK-DALE and REDD, for testing. The UK-DALE dataset is a dataset created by British scientist Kelly (surname) for research identification, which contains bus data and load monitoring data from five houses for two years. It contains 16kHz high-frequency sampling data of total power in the room and 1 / 6Hz low-frequency data of each electrical appliance. The REDD data set is a dataset for non-intrusive load deaggregation created by Kolter (surname) et al. of MIT, which contains high-frequency data on the 15kHz bus of two families and low-frequency data of six family buses and independent appliances. Since the aggregated data in the UK-DALE and REDD datasets contain a variety of electrical appliances, among which there are many types of redundant electrical appliances, it is inconvenient to analyze. In order to facilitate research, this implementation selects the data of four electrical appliances, namely washing machines, dishwashers, microwave ovens and refrigerators, for fusion and testing, and uses MAE and SAE methods to evaluate the model performance.
[0185] The calculation method of MAE is:
[0186] ,in, is the mean absolute error, is the i-th electrical appliance, is the length of time, is the power of the i-th type electrical appliance, is the current time, is an estimate of the power of the i-th type of electrical appliance, which is used to measure the model's influence on the electrical appliance over a period of time. The average absolute error between the estimated value and the actual measured value reflects the accuracy of the single disaggregation result of the model.
[0187] SAE is calculated as:
[0188] ,in, Signal deaggregation error, used to measure the model's performance over a period of time. The quotient of the sum of the absolute values of the differences between the estimated value and the actual measured value and the sum of the actual measured values reflects the accuracy of the model disaggregation results over a period of time.
[0189] Test results such as Figure 3 and Figure 4As shown in the figure, 1 is the split everything model, 2 is the deep deterministic policy gradient, and 3 is the model described in this embodiment. It can be seen that, whether under the MAE or SAE evaluation criteria, the value obtained by sampling the model described in this embodiment is lower than other methods, indicating that its performance is better than the split everything model and the deep deterministic policy gradient, that is, it shows that the comprehensive performance of this model is better than the traditional method. In addition, this embodiment extracts the test data and divides them into the mean values of switch state appliances (microwave ovens, refrigerators) and multi-state appliances (washing machines, dishwashers) for comparison. The results are shown in Tables 1 and 2:
[0190] Table 1
[0191]
[0192] Table 2
[0193]
[0194] The experimental results show that the SAE and MAE values of this implementation under two different data sets are lower than those of the segmentation model and deep deterministic policy gradient, proving that its performance in identifying multi-state electrical appliances and switch-state electrical appliances is better than that of traditional models.
[0195] Then, step S7 is used for pruning. After pruning, the model scale is similar to the comparison model parameter scale, and no significant performance degradation is observed. For example, switch state appliances such as refrigerators and microwave ovens still maintain high accuracy after pruning about 30% of their parameters, and multi-state appliances also maintain high accuracy after pruning 20% of their parameters.
[0196] In summary, the above results show that the method proposed in this embodiment can have a good household non-intrusive load deaggregation capability under a certain parameter scale.
[0197] Embodiment 6: The non-intrusive load monitoring system based on reinforcement learning and attention mechanism described in this embodiment includes the following modules:
[0198] The data module initializes the evaluation actor network, evaluation comment network, target actor network, target comment network, multiple parameters and environment respectively;
[0199] The interaction module evaluates the interaction between the actor network and the environment and stores the interaction results in the cache;
[0200] The sampling module performs batch sampling on the data in the buffer area and sends the sampled data to the evaluation actor network, the evaluation comment network, the target actor network and the target comment network to obtain the results;
[0201] The optimization module calculates the loss based on the results obtained by the sampling module, optimizes the evaluation-critic network based on the loss, uses the optimized evaluation-critic network to calculate the loss of the evaluation-actor network, and updates the evaluation-actor network;
[0202] The update module soft-updates the target comment network based on the evaluation comment network and the target actor network based on the evaluation actor network;
[0203] A judgment module determines whether the evaluation actor network, evaluation comment network, target actor network and target comment network obtained by the update module meet the termination training conditions. If so, the pruning module is executed; if not, the interaction module to the judgment module are executed;
[0204] The pruning module performs pruning operations on the evaluation actor network, evaluation comment network, target actor network and target comment network respectively.
[0205] Embodiment 7: An electronic device described in this embodiment includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus;
[0206] Memory, used to store computer programs;
[0207] The processor is used to implement the method steps described in any one of implementation modes 1 to 5 when executing the program stored in the memory.
[0208] Implementation method eight: A computer-readable storage medium described in this implementation method stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of implementation methods one to six are implemented.
[0209] The above is a detailed introduction to the non-intrusive load monitoring method based on reinforcement learning and attention mechanism proposed in the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A non-intrusive load monitoring method based on reinforcement learning and attention mechanism, characterized in that: The following steps are involved: Step S1, initializing the evaluation actor network, the evaluation comment network, the target actor network, the target comment network, multiple parameters and the environment respectively; Step S2, evaluating the interaction between the actor network and the environment, and storing the interaction results in a cache area; Step S3, batch sampling the data in the buffer area, and sending the sampled data to the evaluation actor network, the evaluation comment network, the target actor network and the target comment network respectively to obtain the results; Step S4, calculating the loss according to the result obtained in step S3, optimizing the evaluation-critic network according to the loss, using the optimized evaluation-critic network to calculate the loss of the evaluation-actor network, and updating the evaluation-actor network; Step S5, soft-update the target comment network based on the evaluation comment network, and soft-update the target actor network based on the evaluation actor network; Step S6, determining whether the evaluation actor network, evaluation comment network, target actor network and target comment network obtained in step S5 meet the termination training conditions, if so, executing step S7, if not, executing steps S2 to S6; Step S7, performing pruning operations on the evaluation actor network, the evaluation comment network, the target actor network, and the target comment network respectively; The evaluation actor network and target actor network include: Several layers of 1D convolutional networks, several units consisting of attention layers and fully connected networks, and fully connected networks; The specific process of processing load data in the structure of the combination of attention mechanism model and convolutional neural network is as follows: Step S1001, the load data, i.e., s(t) and s(t+1), are passed through an m-layer one-dimensional convolutional network to obtain convolution data D, wherein the convolution kernel parameters and the number of layers can be adjusted according to the data characteristics; Step S1002: The load data passes through two layers of modules consisting of an attention mechanism and a fully connected network; in this module, the attention mechanism layer multiplies the convolution data D by the matrix M in the attention mechanism module. q 、M k and M v Get Q, K and V, that is: Q=D T M q ; K=D T M k ; V=D T M v ; Among them, D T is the transpose of the convolution data, Q is the query matrix, K is the keyword matrix, and V is the value matrix; Step S1003, the attention mechanism layer uses the formula: Among them, C is the output result, d is the hyperparameter, Q T is the transpose of the query matrix, where the hyperparameter d can be adjusted according to the actual parameter situation; The Softmax function is defined as: Where x is the input vector and N is the number of elements in x; Step S1004, the module sends C to the fully connected network for processing to obtain C′, namely: C′=FCN(C); Among them, C′ is the output after processing by the fully connected network; Its mathematical expression is as follows: FCN(C)=ReLU(CW1+b1)W2+b2; Among them, C is the input data, b1 and b2 are the bias matrices of the first and second layers of the fully connected network, respectively, and W1 and W2 are the parameter matrices of the first and second layers of the fully connected network, respectively; The ReLU function is an activation function, and its expression is: ReLU(x)=max(0,x), where x is the input data; Step S1005, the data C′ processed by the previous two modules is sent to the last layer of the fully connected network.
2. The non-intrusive load monitoring method based on reinforcement learning and attention mechanism according to claim 1 is characterized in that: In the step S1, the evaluation actor network, the evaluation comment network, the target actor network, the target comment network, the multiple parameters and the environment are respectively initialized, including the following steps: Step S101, designing an evaluation actor network, an evaluation comment network, a target actor network and a target comment network based on multiple data and initializing them; Step S102, initializing the environment based on multiple data.
3. The non-intrusive load monitoring method based on reinforcement learning and attention mechanism according to claim 2 is characterized in that: The multiple data include sliding window length, total data length, each type of electrical appliance, all electrical appliances, aggregated power data and single appliance power data.
4. The non-intrusive load monitoring method based on reinforcement learning and attention mechanism according to claim 1 is characterized in that: In step S2, the evaluation actor network interacts with the environment and stores the interaction results in a cache, including the following steps: Step S201, the environment gives a random state or a specified state, and the actor network is evaluated to give an action; Step S202: The environment gives feedback based on the input action, and the environment gives the state at time t+1; Step S203, storing the random state, action, feedback and the state at time t+1 into a buffer respectively; Step S204, determine whether the buffer area stores a specified number of data groups. If so, execute step S3. If not, repeat steps S201 to S204 with the state at time t+1 as the environment and specifying the state.
5. The non-intrusive load monitoring method based on reinforcement learning and attention mechanism according to claim 1 is characterized in that: In the step S6, it is determined whether the model obtained in the step S5 meets the termination training condition. If so, step S7 is executed. If not, steps S2 to S6 are executed, including the following steps: Step S601, respectively determine whether the training trajectories of the evaluation actor network, the evaluation comment network, the target actor network and the target comment network are completed. If so, execute step S602. If not, take the state of the environment at time t+1 as the environment and give the specified state to execute steps S2 to S5. Step S602, determine whether the model obtained in step S601 has reached the maximum training rounds, if so, execute step S7, if not, execute steps S2 to S6.
6. The non-intrusive load monitoring method based on reinforcement learning and attention mechanism according to claim 1 is characterized in that: In the step S7, the pruning operation is performed on the evaluation actor network, the evaluation comment network, the target actor network and the target comment network respectively, including the following steps: Step S701, performing pruning and fine-tuning operations on the evaluation actor network, evaluation comment network, target actor network and target comment network of different electrical appliances respectively; Step S702, testing the evaluation actor network, the evaluation comment network, the target actor network, and the target comment network respectively and observing their performance, retaining a certain proportion of parameters, and starting to train the evaluation actor network, the evaluation comment network, the target actor network, and the target comment network respectively; Step S703, after training for multiple rounds, testing is performed again, a certain proportion of parameters are removed, and the evaluation actor network, the evaluation comment network, the target actor network, and the target comment network are trained again; Step S704, repeating step S3 until the parameter is lower than a certain ratio; Step S705, observing the performance of the evaluation actor network, the evaluation comment network, the target actor network and the target comment network on different appliances, and selecting the strategy with the best average performance; Step S706, observe the optimal strategy of step S705, compare the curves of different electrical appliance performances changing with parameter scales, select the parameter scale corresponding to the inflection point on the curve, and use the largest parameter scale as the pruning parameter of the evaluation actor network, the evaluation comment network, the target actor network, and the target comment network; Step S707, fine-tune the evaluation actor network, the evaluation comment network, the target actor network, and the target comment network using the optimal strategy of step S705 and the parameter scale of step S706 respectively until the accuracy no longer changes.
7. A non-intrusive load monitoring system based on reinforcement learning and attention mechanism, characterized in that: Includes the following modules: The data module initializes the evaluation actor network, evaluation comment network, target actor network, target comment network, multiple parameters and environment respectively; The interaction module evaluates the interaction between the actor network and the environment and stores the interaction results in the cache; The sampling module performs batch sampling on the data in the buffer area and sends the sampled data to the evaluation actor network, the evaluation comment network, the target actor network and the target comment network to obtain the results; The optimization module calculates the loss based on the results obtained by the sampling module, optimizes the evaluation-critic network based on the loss, uses the optimized evaluation-critic network to calculate the loss of the evaluation-actor network, and updates the evaluation-actor network; The update module soft-updates the target comment network based on the evaluation comment network and the target actor network based on the evaluation actor network; A judgment module determines whether the evaluation actor network, evaluation comment network, target actor network and target comment network obtained by the update module meet the termination training conditions. If yes, the pruning module is executed; if not, the interaction module is executed to the judgment module; The pruning module prunes the evaluation actor network, evaluation comment network, target actor network, and target comment network respectively; The evaluation actor network and target actor network include: Several layers of 1D convolutional networks, several units consisting of attention layers and fully connected networks, and fully connected networks; The specific process of processing load data in the structure of the combination of attention mechanism model and convolutional neural network is as follows: Module S1001, the load data, i.e., s(t) and s(t+1), are passed through an m-layer one-dimensional convolutional network to obtain convolution data D, wherein the convolution kernel parameters and the number of layers can be adjusted according to the data characteristics; Module S1002, the load data passes through two layers of modules consisting of an attention mechanism and a fully connected network; in this module, the attention mechanism layer multiplies the convolution data D by the matrix M in the attention mechanism module q 、M k and M v Get Q, K and V, that is: Q=D T M q ; K=D T M k ; V=D T M v ; Among them, D T is the transpose of the convolution data, Q is the query matrix, K is the keyword matrix, and V is the value matrix; Module S1003, the attention mechanism layer uses the formula: Among them, C is the output result, d is the hyperparameter, Q T is the transpose of the query matrix, where the hyperparameter d can be adjusted according to the actual parameter situation; The Softmax function is defined as: Where x is the input vector and N is the number of elements in x; Module S1004, this module sends C to the fully connected network for processing, and obtains C′, namely: C′=FCN(C); Among them, C′ is the output after processing by the fully connected network; Its mathematical expression is as follows: FCN(C)=ReLU(CW1+b1)W2+b2; Among them, C is the input data, b1 and b2 are the bias matrices of the first and second layers of the fully connected network, respectively, and W1 and W2 are the parameter matrices of the first and second layers of the fully connected network, respectively; The ReLU function is an activation function, and its expression is: ReLU(x)=max(0,x), where x is the input data; Module S1005 sends the data C′ processed by the previous two modules to the last layer of the fully connected network.
8. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 6 when executing a program stored in a memory.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 6 are implemented.
Citation Information
Cited By
Agent training method and device, equipment, storage medium and program product
CN120317320B
