Non-intrusive load detection method based on comparative learning and twin network
By comparing learning with the non-invasive load detection method of twin networks, using sliding windows and self-supervised learning, combining mean drift clustering and data enhancement technology, the problems of poor load monitoring accuracy and low efficiency in the existing technology are solved, and the problem of poor load monitoring accuracy and low efficiency is realized. High accuracy and efficient load state detection.
Patent Information
- Application Number
- CN202410966891.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-18
- Publication Date
- 2024-11-12
AI Technical Summary
The existing non-invasive load monitoring technology has problems of poor accuracy and low efficiency, making it difficult to effectively identify and monitor the types and operation of individual loads in the load cluster.
Using a non-invasive load detection method based on contrast learning and twin networks, by obtaining the total power signal and the power data of each target appliance, using sliding windows and self-supervised contrast learning methods to build positive and negative sample pairs, train the twin neural network, and combine it with Mean drift clustering and data enhancement technology to achieve accurate detection of load state.
It improves the accuracy and generalization ability of load detection, and can achieve better detection results in non-invasive mode. It is especially suitable for places where intrusive detection is difficult, improving detection efficiency and accuracy.
Smart Images

Figure CN118940619A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of non-invasive load detection methods, and in particular to a non-invasive load detection method based on contrastive learning and twin networks. Background Art
[0002] Traditional load monitoring methods often require the installation of sensor equipment at the user end, which not only increases the burden on users, but also increases the complexity and cost of monitoring. In order to solve this problem, an innovative method based on non-intrusive load monitoring (NILM) technology is proposed. This method captures and analyzes signals such as voltage and current by installing intelligent monitoring equipment at the power entrance, thereby identifying and monitoring the type and operation status of individual loads in the load cluster. However, the current NILM technology still has some challenges, one of the most important of which is how to improve the accuracy and efficiency of load monitoring.
[0003] As an emerging branch of machine learning, deep learning has shown great potential and achievements in image recognition, natural language processing and other fields. Its core goal is to endow machines with human-like analytical learning capabilities by learning the inherent laws and representation levels of sample data, so that they can effectively process and recognize various data forms such as text, images, and sounds. This powerful learning method has brought new solutions to the field of load monitoring and provided strong support for improving the accuracy and efficiency of load monitoring. How to use advanced deep learning technology to improve the NILM method has become one of the current research hotspots. Summary of the invention
[0004] The present invention provides a non-intrusive load detection method based on contrastive learning and twin networks to solve the problems of poor accuracy and low efficiency in the prior art NILM technology.
[0005] In order to achieve the above object, the technical solution adopted by the present invention is:
[0006] The non-intrusive load detection method based on contrastive learning and twin networks includes the following steps:
[0007] Step 1: Obtain the total power signal input to all target electrical appliances during a period of time, as well as the power data of each target electrical appliance during the period of time; and obtain all possible usage states of each target electrical appliance during the period of time according to the power data of each target electrical appliance during the period of time;
[0008] Step 2: Process the total power signal using a sliding window method to divide the total power signal into a plurality of windows of the same length; obtain a positive sample pair and a negative sample pair of the usage status of each target electrical appliance in each window through a self-supervised comparative learning method;
[0009] Step 3: Construct a training set with positive sample pairs and negative sample pairs of the usage status of each target appliance in all windows, and generate a twin neural network. Train the twin neural network with the training set, and use the trained twin neural network to determine the current usage status of the corresponding target appliance under the total power signal in each time window.
[0010] Furthermore, in step 1, a mean shift clustering algorithm is used to obtain multiple usage states of each target electrical appliance.
[0011] Furthermore, the process of step 2 self-supervised contrastive learning method is as follows:
[0012] Based on the conventional event detection method, active body detection is performed on the usage status of each target appliance according to the window to obtain several active bodies corresponding to each target appliance in each window. Then, the several active bodies of each target appliance in each window are sorted and data jittered to obtain multiple active bodies with strong correlation for each target appliance in each window as positive sample pairs and negative sample pairs of the usage status of the target appliance in each window.
[0013] The present invention utilizes a contrastive learning data enhancement method based on event detection to construct positive and negative sample pairs for the usage status of each target electrical appliance (i.e., load), and further models and trains the positive and negative samples respectively through a twin neural network structure. Finally, the outputs of the two branches are integrated through a fusion layer to obtain the detection results of each target electrical appliance.
[0014] The beneficial effects of the technical solution provided by the present invention are:
[0015] 1. Through this data enhancement method based on contrastive learning, the present invention can use rich event data to train the model, thereby improving the accuracy and generalization ability of load detection and having high application value.
[0016] 2. In some places where invasive detection is difficult to carry out (for example, places involving privacy, highly complex and high-risk places, etc.), the present invention can provide a solution and achieve better detection results in a non-invasive manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 It is a flowchart of a method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0018] The present invention is further described below in conjunction with the accompanying drawings and embodiments.
[0019] This embodiment discloses a non-invasive load detection method based on contrastive learning and twin networks. The goal of non-invasive load detection is to accurately measure the state and power consumption of specific electrical appliances. This embodiment regards this problem as a multi-label classification problem. This embodiment analyzes and utilizes the total power of the venue obtained by non-invasive collection over a period of time, identifies the usage of multiple target electrical appliances in the venue (i.e., the load in the venue), and predicts the power curve of each target electrical appliance through the classification results, thereby achieving the purpose of detecting target electrical appliances in a non-invasive manner.
[0020] In the non-intrusive load detection task, feature learning and extraction have always been the most basic core issues. For example, for a specific target appliance, different locations, different brands, and different usage methods may have different feature representations. Therefore, how to learn more effective and more generalized feature representations is an urgent problem to be solved in the non-intrusive load detection task.
[0021] In order to solve the feature learning bottleneck faced by current technologies in non-invasive load detection, this embodiment uses contrastive learning to pair positive and negative samples for different usage states of each target appliance, and uses data enhancement methods to enable the model to learn more robust feature representations through a larger amount of training data. Then, the different positive and negative sample state pairs of each target appliance are input into different branches of the twin neural network model, and more general feature representations are learned in a semi-supervised learning manner for different downstream tasks, such as state determination of each target appliance and prediction of power curves. Experiments on the actual collected non-invasive load detection data set show that the method designed in this embodiment is effective and superior to other methods.
[0022] like Figure 1 As shown, the process of this embodiment is as follows:
[0023] Step 1: Obtain the total power signal input to all target electrical appliances during a period of time, as well as the power data of each target electrical appliance during the period of time; and obtain all possible usage states of each target electrical appliance during the period of time based on the power data of each target electrical appliance during the period of time.
[0024] In the non-intrusive load detection problem, this embodiment trains a twin neural network model for each target electrical appliance i∈[N]. In this embodiment, a data set is first obtained, which consists of the total power signal X input to all target electrical appliances over a period of time and the power data Y of each target electrical appliance. i Composition, among which Y i is the power data of the i-th target appliance.
[0025] Based on Y i , the corresponding target appliance (i.e., the ith target appliance) is extracted through the mean shift clustering algorithm and the M fixed in this period of time i A usage state refers to all possible usage states of the corresponding target appliance during this period of time.
[0026] The mean shift clustering algorithm is a density-based clustering algorithm that can automatically discover clustering structures in data. The core idea of the algorithm is to continuously move the center position of data points so that data points gather in the area with the highest density. Its calculation process can be expressed as formula (1):
[0027]
[0028] Where y is the power data Y input to the i-th target appliance within a period of time i One of the samples of y i represents the data at the i-th position in the input data y, K(·) is the kernel function, and in this embodiment, a radially symmetric kernel is used. d is the d-dimensional window bandwidth parameter. n is the length of the input data y.
[0029] Step 2: Process the total power signal using a sliding window method to divide the total power signal into a number of windows of the same length; obtain positive sample pairs and negative sample pairs of the usage status of each target appliance in each window through a self-supervised comparative learning method.
[0030] Contrastive learning is a machine learning method that aims to learn the representation of data by comparing the similarities and differences between different samples. In contrastive learning, the model is trained to distinguish between samples within the same category and samples between different categories, thereby learning meaningful representations of the data. This learning method does not rely on explicit label information, but instead optimizes model parameters by combining data samples into positive and negative sample pairs and using the similarity measure between them.
[0031] The core idea of contrastive learning is to learn the discriminative representation of data by maximizing the similarity between positive sample pairs and minimizing the similarity between negative sample pairs. Contrastive learning can not only improve the performance and generalization ability of the model, but also effectively process unlabeled data, thus expanding the application scope of machine learning.
[0032] For the original input total power signal data X, this embodiment uses a sliding window method to process it. A subsequence centered on the midpoint of the window is output in sequence through a sliding window, and the total power signal data X is divided into several (overlapping) windows b of length w. Window b is a standard unit. The data of each window will be enhanced and then input into the two branches of the twin neural network. First, define the state sequence using in, All possible usage states of the i-th target appliance are represented as a sequence. Represents the usage state sequence The value range of is a positive real number and is a real vector of dimension w. w is the length of the time window b. The input of this usage state sequence is a w-dimensional non-negative real number vector, which represents the power data within a time window of length w. Indicates the use of state sequence The value range of M is 0 to 1 i The closed interval output value of ×τ dimension, that is, the value stored in the sequence, is a matrix of length Mi xq, where the element value is between 0 and 1. τ is the τth time point in window b. Mi is the number of all usage states of the i-th target appliance. q is the number of all time points in the time window of length w.
[0033] In this task, the occurrence of an event will trigger a change in the current usage state of the target appliance. By adding event detection, the model can be effectively assisted to better detect changes in usage state. Conventional event detection methods usually use a first-order function based on differences to detect sudden changes in a combined load x. This first-order difference function is df t =x t+1 -x t , where t represents time and df represents load difference. The discrimination process can be expressed as formula (2):
[0034]
[0035] Where E indicates whether the event occurs or not. t , x t+1 ) indicates whether an event occurs within the time from t to t+1. The occurrence of an event will cause a change in the current usage state of the target appliance. By adding event detection, the model can be effectively assisted to better detect the change in usage state. x is the input data, and η represents the threshold of load change. If df t >η,E(x t , x t+1) indicates a sudden positive turn; conversely, it indicates a sudden negative turn. The positive direction indicates a normal change along the trend of the current power curve, while the negative direction indicates a change against the trend.
[0036] On this basis, this embodiment proposes to detect active bodies within the time window. When a target appliance is in the on state, its contribution to the combined load must be greater than the threshold, otherwise it must be 0. From this, this embodiment derives that an active body usually includes two event states, which are simply positive turning points and negative turning points, summarized as formula (3):
[0037] P(t, t+τ)=[x t , ..., x t+τ ]
[0038] st
[0039] E(x t-1 , x t )=1 and E(x t+τ , x t+τ+1 )=-1
[0040]
[0041] Where P represents the active body, P(t, t+τ) refers to the active body detected in τ time nodes starting from the current time t. t is any time point in the current time window. x is the input data as mentioned above, and changes according to time t. E is defined in the above formula, indicating whether the event occurs or not, E(x t-1 , x t )=1 means from the data point x t-1 To data point x t The event occurs when . The same goes for the subsequent ones. The active body can be found by combining the positive turning point with the nearest negative turning point.
[0042] The data enhancement method proposed in the present invention first detects the events occurring in the current time window through active body detection, and then expands and enhances the original data by transforming the active body. The transformation method selected in this embodiment includes active body re-ranking and data jittering. This embodiment translates one or more detected active bodies along the timeline, so that the transformed combined load and the original combined load maintain a strong correlation with each other under completely different circumstances. The result of active body re-ranking can be expressed as formula (4):
[0043]
[0044] On this basis, this embodiment continues to perform data jitter operation on the reordered active bodies. This operation can be expressed as formula (5):
[0045]
[0046] When two data samples (X i , X j ), this embodiment uses the above data enhancement method to obtain their enhanced data pairs respectively. and At the same time, they follow the distribution A(·|X i ) and A(·|X j ). At this time, this embodiment will Treat as X i Positive sample pairs, so all other sample pairs, including All are considered as X i The goal of the φ supervised contrastive learning in this embodiment is to shorten the distance between all positive sample pairs and expand the distance between all negative sample pairs, so as to obtain an extremely robust feature representation.
[0047] Through the above data enhancement method, the amount of original data X is effectively increased, especially not limited to training samples that are very similar to the original samples. The method proposed in this embodiment provides more effective data for the model to enhance the feature representation learning ability of the model.
[0048] Step 3: Construct a training set with positive sample pairs and negative sample pairs of the usage status of each target appliance in all windows, and generate a twin neural network. Train the twin neural network with the training set, and use the trained twin neural network to determine the current usage status of the corresponding target appliance under the total power signal in each time window.
[0049] This embodiment further designs a twin neural network structure suitable for self-supervised contrastive learning for the large amount of augmented data obtained using the above data enhancement method.
[0050] The twin network is a special neural network structure that consists of two parallel branches of the same structure. Each branch accepts different input data and processes it independently. In the subsequent part of the network, the outputs of the two branches undergo certain fusion or integration operations to produce the final output. This design enables the twin network to process multiple input data or perform multiple tasks at the same time, thereby improving the performance and adaptability of the model. The uniqueness of the twin network is that it can learn the similarities and differences between input data without explicitly defining the similarity measure. Through independent learning and fusion operations on the two branches, the similarities and differences between the input data are effectively learned, the similarity measure is simplified, and the performance and adaptability of the model are improved.
[0051] In this embodiment, after the data enhancement method in step 2, two original usage status samples (X i , X j ) After the expansion, each positive and negative sample pair enters the model from the two branches of the twin neural network for training. The two branch heads of the model use an encoder f(·) to extract the representation vector for each sample pair. The process can be expressed as formula (6):
[0052]
[0053] In one branch, xi is a positive sample of the usage status obtained in step 2; in another branch, xi is a negative sample pair of the usage status obtained in step 2.
[0054] Following the encoder f(), this embodiment further uses a multi-layer perceptron (MLP) g() with one hidden layer to map the representation vector learned by the encoder f() to the space where the contrast loss function is located. This process can be expressed as formula (7):
[0055] z i =g(h i ) (7)
[0056] Therefore, the twin network structure of this embodiment includes two branches, which act on the positive and negative samples after the data enhancement operation on the original usage status samples. The structures of the two branches are also roughly the same, both consisting of an encoder f(·) and a multi-layer perceptron (MLP) with one hidden layer. The mapping results obtained by the two branches will be further fed into the final contrast loss function.
[0057] Loss calculation is mainly used in the training process of deep learning models. By calculating the loss, the model uses back propagation to update parameters and eventually converges to an optimal state.
[0058] According to the above model design process, this embodiment uses the contrast loss function as the final loss function of the model training. and its corresponding positive sample pair The negative sample pair corresponding to this positive sample pair This embodiment thus introduces the InfoNCE contrast loss function tailored for contrastive learning, which is expressed by formula (8):
[0059]
[0060] Where v is a temperature hyperparameter that is used to smooth the output distribution.
[0061] After calculating the loss function, the parameters of the twin network are adjusted according to the loss function calculation results. Until the loss function is in a certain situation, the parameters of the twin network are adjusted to the optimal state. The optimal twin network output result is used as the real state of the target appliance.
[0062] The following is an experimental verification example of this embodiment
[0063] This experiment uses NVIDIA GTX 4090 GPU, and the model code is built based on Python and Pytorch toolbox. The Adam optimizer is used in the experiment.
[0064] (1) This experiment will evaluate the model's capabilities on the public dataset REDD
[0065] REDD consists of power readings from six homes, where aggregate power and individual appliance power are recorded every 1 second and 3 seconds, respectively. Four appliances (microwave, washing machine, dishwasher, refrigerator) in houses 1, 2, and 3 are selected for evaluation. This experiment uses three evaluation metrics, namely MAE as shown in formula (9), SAE as shown in formula (10), and SAE δ As shown in formula (11):
[0066]
[0067]
[0068]
[0069] Where δ represents a time period, T δ Represents splitting the original sequence into T δ time period. δ is the length of δ. Y is the true value, is the predicted value of the model. y is the true value within the corresponding δ, is the predicted value of the model within the corresponding δ.
[0070] (2) Experimental performance comparison
[0071] In this section, the model proposed in this example is evaluated. The related studies compared include: FHMM, LSTM, S2P, BERT4NILM, SGN.
[0072] Table 1 shows the evaluation results of the six prediction models on the REDD dataset, with the best results shown in bold.
[0073] Table 1 Comparative experimental results of six methods
[0074]
[0075]
[0076] As shown in Table 1, the experimental results show that this embodiment achieves the best results under the four target electrical appliances, which proves the practicality of the present invention.
[0077] The preferred embodiments of the present invention are described in detail above in conjunction with the accompanying drawings. The embodiments described in the present invention are merely descriptions of the preferred embodiments of the present invention, and do not limit the concept and scope of the present invention. The various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction, and such combinations should also be regarded as the contents disclosed in the present disclosure as long as they do not violate the concept of the present invention. In order to avoid unnecessary repetition, the present invention will not further describe various possible combinations.
[0078] The present invention is not limited to the specific details of the above-mentioned embodiments. Within the scope of the technical concept of the present invention and without departing from the design concept of the present invention, various modifications and improvements made to the technical solution of the present invention by technical personnel in this field should fall within the protection scope of the present invention. The technical contents for which protection is sought in the present invention have been fully recorded in the claims.
Claims
1. A non-intrusive load detection method based on contrastive learning and twin networks, characterized in that: The following steps are involved: Step 1: Obtain the total power signal input to all target electrical appliances during a period of time, as well as the power data of each target electrical appliance during the period of time; and obtain all possible usage states of each target electrical appliance during the period of time according to the power data of each target electrical appliance during the period of time; Step 2: Process the total power signal using a sliding window method to divide the total power signal into a plurality of windows of the same length; obtain a positive sample pair and a negative sample pair of the usage status of each target electrical appliance in each window through a self-supervised comparative learning method; Step 3: Construct a training set with positive sample pairs and negative sample pairs of the usage status of each target appliance in all windows, and generate a twin neural network. Train the twin neural network with the training set, and use the trained twin neural network to determine the current usage status of the corresponding target appliance under the total power signal in each time window.
2. The non-intrusive load detection method based on contrastive learning and twin networks according to claim 1 is characterized in that: In step 1, a mean shift clustering algorithm is used to obtain multiple usage states of each target appliance.
3. The non-intrusive load detection method based on contrastive learning and twin networks according to claim 1 is characterized in that: Step 2 The process of self-supervised contrastive learning method is as follows: Based on the conventional event detection method, active body detection is performed on the usage status of each target appliance according to the window to obtain several active bodies corresponding to each target appliance in each window. Then, the several active bodies of each target appliance in each window are sorted and data jittered to obtain multiple active bodies with strong correlation for each target appliance in each window as positive sample pairs and negative sample pairs of the usage status of the target appliance in each window.
