Non-intrusive load monitoring method and device based on Transformer model and transfer learning
Through the non-intrusive load monitoring method based on the Transformer model and transfer learning, the problems of low load monitoring accuracy and weak generalization ability in the existing technology are solved, and more efficient load data analysis and the ability to adapt to new environments are achieved, which is applicable in the fields of smart home and energy management.
Patent Information
- Application Number
- CN202411161987.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-23
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2044-08-23
AI Technical Summary
Existing non-intrusive load monitoring technologies have limitations in capturing complex nonlinear relationships in load data. They have low accuracy and weak generalization capabilities. They rely on a large amount of annotated data and are difficult to adapt to new environments and different load types.
A non-intrusive load monitoring method based on the Transformer model and transfer learning is adopted. Through data preprocessing and feature extraction, combined with the multi-head attention mechanism and transfer learning technology, the prediction performance of the model is optimized in different regions and load types, and the need for labeled data is reduced. dependence.
It improves the accuracy and reliability of load monitoring, can obtain a generalizable model with less data, quickly adapts to new power systems and environments, and reduces retraining and data requirements.
Smart Images

Figure CN118673966B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of power system and load monitoring, and in particular to non-intrusive load monitoring. Background Art
[0002] At present, load monitoring has important application value in the fields of smart meters, energy management and smart grid. Load monitoring can help power companies and energy management understand power consumption, optimize energy supply, improve energy efficiency and reduce environmental pollution by collecting and analyzing load information in the power system.
[0003] Traditional intrusive load monitoring (ILM) methods usually require the installation of sensors or monitoring equipment on each load in the power system, which not only increases the cost and complexity of deployment, but may also interfere with the normal operation of the equipment in the system. Therefore, it is of great practical application value to study a non-intrusive load monitoring (NILM) method that can accurately monitor and analyze load information without the need for additional sensors or monitoring equipment. Figure 1 shown.
[0004] Currently, non-intrusive load monitoring technology still faces challenges in dealing with long-term dependencies in time series and dynamic adaptation of load working conditions, and the generalization ability and data dependency of the model in different environments have not been effectively solved. In addition, training neural network models requires a large amount of labeled data, and these intrusive data are often difficult to obtain. How to use less data to obtain a generalizable model is a key issue in current research.
[0005] In summary, the prior art has the following problems:
[0006] 1) The current NILM deep learning method still has some limitations in capturing the complex nonlinear relationships in load data, and the accuracy of load monitoring needs to be further improved.
[0007] 2) Existing methods rely on a large amount of labeled data. Especially when facing new environments or different loads, the model often needs to be trained from scratch, which is both time-consuming and resource-consuming, limiting the practical application scope of the model. Therefore, there is an urgent need for a method to use less data to obtain a generalizable model. Summary of the invention
[0008] The purpose of the present invention is to solve the problems of low prediction accuracy and weak generalization ability of existing non-intrusive load monitoring technology, and to provide a non-intrusive load monitoring method and device based on Transformer model and transfer learning.
[0009] The present invention is implemented by the following technical solutions. On the one hand, the present invention provides a non-intrusive load monitoring method based on a Transformer model and transfer learning, the method comprising:
[0010] Step 1: preprocess the collected power signal;
[0011] Step 2: Establish a Transformer-based NILM model, and use the Transformer-based NILM model to predict the power of a certain load;
[0012] The input of the Transformer-based NILM model is the bus power series , the goal is to predict the power of a certain load at the center point of the sequence, including convolutional layers, pooling layers, position encoding layers, position embedding layers, Transformer encoders, flattening layers, and fully connected layers;
[0013] The bus power sequence It sequentially enters the one-dimensional convolution layer for preliminary feature extraction, then enters the maximum pooling layer for preliminary key feature extraction, then further extracts features through the one-dimensional convolution layer, and finally enters the maximum pooling layer to complete the feature extraction process;
[0014] The position encoding layer uses sine and cosine functions to perform position encoding and generates a unique encoding vector for each position;
[0015] The Transformer encoder includes a multi-head attention mechanism, which performs multiple attention functions in parallel, each time using a different linear transformation to obtain the query ,key ,value To improve the expressiveness of the model;
[0016] The fully connected layer performs feature transformation and nonlinear mapping on the flattened one-dimensional tensor through a combination of a linear layer and a tanh activation function to learn complex feature representations, and finally obtains the NILM prediction result;
[0017] Step 3: Use transfer learning technology to optimize the prediction performance of the Transformer-based NILM model on tasks in different regions or load types to obtain non-intrusive load monitoring results.
[0018] Furthermore, in step 2, the multi-head attention mechanism executes the attention function multiple times in parallel, each time using a different linear transformation to obtain the query ,key ,value To improve the expressiveness of the model, specifically:
[0019] ,
[0020] in, , , , and is the parameter matrix of model learning, is the number of heads.
[0021] Furthermore, in step 2, the fully connected layer performs feature transformation and nonlinear mapping on the flattened one-dimensional tensor through a combination of a linear layer and a tanh activation function to learn complex feature representations, and finally obtains the NILM prediction result, specifically:
[0022] ,
[0023] in, Indicates load At the midpoint of the input sequence The corresponding power value.
[0024] Furthermore, in step 3, the use of transfer learning technology to optimize the prediction performance of the Transformer-based NILM model on tasks of different regions or load types includes source task selection, specifically:
[0025] Calculate load Throughout the observation sequence Average number of active channels in ,The workload with the highest average number of active channels is selected as the source task.
[0026] Furthermore, the source task selection also includes determining the source task in combination with the power load characteristics, periodicity and stages of the load.
[0027] Furthermore, in step 3, the use of transfer learning technology to optimize the prediction performance of the Transformer-based NILM model on tasks in different regions or load types includes a migration fine-tuning strategy, specifically:
[0028] In the pre-training phase, in the source region Pre-train the model for the source task.
[0029] ,
[0030] in, Indicates the region The source task dataset on are the initialization model parameters of the convolutional layer and other layers of the model, are the model parameters of the convolutional layers and other layers saved in pre-training, For load The loss function of
[0031] The pre-trained model parameters Migrate to the target region Target load On, and make fine adjustments:
[0032] ,
[0033] in, Target area Datasets, To use the target region Load The model parameters of other layers except the convolutional layers after fine-tuning.
[0034] Furthermore, step 1 specifically includes:
[0035] Visualize the power of the bus and each household load to check whether the data is complete; observe the power waveform and delete the missing data lasting more than half an hour. For the missing data of only a few seconds or minutes, keep it as noise to regularize the model;
[0036] The sampling rate of bus data and the power of each household load is unified to achieve time step alignment;
[0037] Data standardization, including:
[0038] Time Bus power It is expressed as:
[0039] ,
[0040] in, is the total number of load types, Indicates load At the point in time The power, is the noise term;
[0041] After data synchronization, the power data is standardized and used for model training, verification, and testing;
[0042] Normalized bus power It can be calculated using the following formula:
[0043] ,
[0044] in, represents the mean value of power, Represents the standard deviation of power.
[0045] In a second aspect, the present invention provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, and when the processor runs the computer program stored in the memory, the steps of a non-intrusive load monitoring method based on a Transformer model and transfer learning as described above are executed.
[0046] In a third aspect, the present invention provides a computer-readable storage medium, in which a plurality of computer instructions are stored, and the plurality of computer instructions are used to enable a computer to execute a non-intrusive load monitoring method based on a Transformer model and transfer learning as described above.
[0047] In a fourth aspect, the present invention provides an electronic device, comprising:
[0048] at least one processor; and,
[0049] a memory communicatively connected to the at least one processor; wherein,
[0050] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute a non-intrusive load monitoring method based on a Transformer model and transfer learning as described above.
[0051] Beneficial effects of the present invention:
[0052] In order to solve the problems existing in the background technology, the present invention provides a non-intrusive load monitoring method based on Transformer model and transfer learning. The method can better capture the complex nonlinear relationship in the load data and improve the accuracy and reliability of load monitoring. In addition, the method uses transfer learning technology to enable the model to adapt more quickly when applied to a new power system or environment, reducing the need for retraining and a large amount of data support.
[0053] The present invention proposes and optimizes the NILM model structure based on the Transformer model: an improved Transformer model structure is proposed, which is optimized for NILM tasks. This model can more effectively process long time series data, adapt to complex load pattern changes and long-period data dependence, thereby improving the accuracy of energy monitoring.
[0054] How to use less data to get a generalizable model is a key issue in current research. This paper explores the transferability of the Transformer model and the strategy for implementing transfer learning. The ideal NILM transfer learning is to train the model on some household and load data, and then make predictions on any other invisible households and loads. For example, it is hoped that NILM will be trained on the loads of British households, and then the trained model of British household loads will be deployed in the United States; or the washing machine model will be trained, and then the trained washing machine model will be deployed to the electric kettle. The present invention proposes a transfer learning strategy: developing a transfer learning method to enhance the generalization ability of the model in new environments and different load types. This strategy reduces the reliance on large-scale labeled data sets, enables the model to quickly adapt to new monitoring environments, and improves the training efficiency and application breadth of the model.
[0055] The invented method utilizes the Transformer structure and transfer learning technology to improve the load monitoring of the power system, and provides a technical means for more effectively and accurately monitoring and predicting load demand. The non-intrusive load monitoring method based on the Transformer model and transfer learning proposed in the present invention can be widely used in smart home systems, industrial production monitoring, energy management and other fields. By monitoring the power consumption of the load in real time, users can realize intelligent load management and improve energy utilization efficiency.
[0056] The present invention can be widely used in scenarios where load power consumption and usage status are monitored and evaluated in the fields of smart meters, energy management, smart grids, etc. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] In order to more clearly illustrate the technical solution of the present application, the drawings required for use in the embodiments are briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0058] Figure 1 It is a schematic diagram of non-intrusive load monitoring;
[0059] Figure 2 This is the Transformer-based NILM model architecture of the present invention. DETAILED DESCRIPTION
[0060] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present invention, and should not be construed as limiting the present invention.
[0061] Embodiment 1: A non-intrusive load monitoring method based on a Transformer model and transfer learning, the method comprising:
[0062] Step 1: preprocess the collected power signal;
[0063] Step 2: Establish a Transformer-based NILM model, and use the Transformer-based NILM model to predict the power of a certain load;
[0064] The input of the Transformer-based NILM model is the bus power series , the goal is to predict the power of a certain load at the center point of the sequence, including convolutional layers, pooling layers, position encoding layers, position embedding layers, Transformer encoders, flattening layers, and fully connected layers;
[0065] The bus power sequence It sequentially enters the one-dimensional convolution layer for preliminary feature extraction, then enters the maximum pooling layer for preliminary key feature extraction, then further extracts features through the one-dimensional convolution layer, and finally enters the maximum pooling layer to complete the feature extraction process;
[0066] The position encoding layer uses sine and cosine functions to perform position encoding and generates a unique encoding vector for each position;
[0067] The Transformer encoder includes a multi-head attention mechanism, which performs multiple attention functions in parallel, each time using a different linear transformation to obtain the query ,key ,value To improve the expressiveness of the model;
[0068] The fully connected layer is composed of a linear layer and The activation function combination performs feature transformation and nonlinear mapping on the flattened one-dimensional tensor to learn complex feature representations and finally obtain the NILM prediction result;
[0069] Step 3: Use transfer learning technology to optimize the prediction performance of the Transformer-based NILM model on tasks in different regions or load types to obtain non-intrusive load monitoring results.
[0070] In this implementation, a NILM model structure based on the Transformer model is proposed and optimized: an improved Transformer model structure is proposed and optimized for the NILM task. This model can more effectively process long time series data, adapt to complex load pattern changes and long-period data dependencies, thereby improving the accuracy of energy monitoring.
[0071] Specifically, the structure of the NILM model based on the Transformer model was first optimized, especially by adding position information to the general features through sine and cosine position encoding. At the same time, this encoding method is a learning-free method, which reduces the complexity of model training. In addition, a four-head three-layer head attention mechanism is designed to capture the long-distance dependency of the power sequence, which helps the model understand the relationship between different time points and the load working mode, thereby improving the monitoring accuracy of the NILM model. Furthermore, the optimized Transformer-based NILM model is used to migrate and fine-tune the model parameters to ensure that the learned features can be effectively migrated to NILM tasks of other loads.
[0072] Implementation method 2: This implementation method is a further limitation of the non-intrusive load monitoring method based on Transformer model and transfer learning described in implementation method 1. In this implementation method, in step 2, the multi-head attention mechanism executes multiple attention functions in parallel, each time using a different linear transformation to obtain the query ,key ,value To improve the expressiveness of the model, further limitations have been made, including:
[0073] In step 2, the multi-head attention mechanism executes the attention function multiple times in parallel, each time using a different linear transformation to obtain the query ,key ,value To improve the expressiveness of the model, specifically:
[0074] ,
[0075] in, , , , and is the parameter matrix of model learning, is the number of heads.
[0076] The Transformer encoder in this implementation is a four-head three-layer encoder structure. The multi-head attention mechanism is one of the core components of the Transformer model, which enables the model to capture information from different representation subspaces simultaneously. In the multi-head attention mechanism, in each encoder layer, the input sequence is mapped into a query ,key Sum Then, by calculating the query and key The dot product of is then normalized by softmax to obtain the attention weight of each position to all positions. Finally, the attention weight is multiplied by the value vector , and perform weighted summation to obtain the final attention output The multi-head attention mechanism performs multiple attention functions in parallel, each time using a different linear transformation to obtain , , To improve the expressiveness of the model.
[0077] Implementation method 3: This implementation method further limits the non-intrusive load monitoring method based on Transformer model and transfer learning described in implementation method 1. In this implementation method, in step 2, the fully connected layer is connected through a linear layer and The activation function combination performs feature transformation and nonlinear mapping on the flattened one-dimensional tensor to learn complex feature representations, and finally obtains the NILM prediction result, which is further limited, including:
[0078] In step 2, the fully connected layer is connected through the linear layer and The activation function combination performs feature transformation and nonlinear mapping on the flattened one-dimensional tensor to learn complex feature representations, and finally obtains the NILM prediction result, which is as follows:
[0079] ,
[0080] in, Indicates load At the midpoint of the input sequence The corresponding power value.
[0081] This implementation constructs a three-layer fully connected network and The structure consists of three layers of fully connected networks composed of activation functions. The three-layer fully connected network in this structure can integrate the features passed through the Transformer encoder to further learn complex feature representations, where each layer further abstracts and combines features based on the previous layer. In addition, The activation function normalizes the output values to between -1 and 1, which helps the model handle inputs that vary in different ranges and also avoids the vanishing gradient problem during training.
[0082] Implementation method 4: This implementation method further limits the non-intrusive load monitoring method based on the Transformer model and transfer learning described in implementation method 1. In this implementation method, in step 3, the use of transfer learning technology to optimize the prediction performance of the Transformer-based NILM model in different regions or load type tasks is further limited, specifically including:
[0083] In step 3, the use of transfer learning technology to optimize the prediction performance of the Transformer-based NILM model on tasks in different regions or load types includes source task selection, specifically:
[0084] Calculate load Throughout the observation sequence Average number of active channels in ,The workload with the highest average number of active channels is selected as the source task.
[0085] The source task selection also includes determining the source task in combination with the power load characteristics, periodicity and phase characteristics of the load.
[0086] This implementation introduces transfer learning, and selects the most appropriate source task by analyzing the average number of activated channels of the convolutional layer and the working characteristics and usage characteristics of the load, such as selecting a washing machine as a suitable source task.
[0087] In transfer learning, choosing the right source task It is crucial. The choice is based on the data of the source task The richness and representativeness of Similarities between. Ideal It should contain enough variables and complexity to ensure that the learned features can be effectively transferred to other tasks. For the NILM problem, this implementation adopts two methods to determine the appropriate The average number of active channels in the convolution layer and the working and usage characteristics of the load. Reflects how often the model is activated when processing load data.
[0088] Implementation mode 5: This implementation mode further limits the non-intrusive load monitoring method based on the Transformer model and transfer learning described in Implementation mode 4. In this implementation mode, in step 3, the use of transfer learning technology to optimize the prediction performance of the Transformer-based NILM model in different regions or load type tasks is further limited, specifically including:
[0089] In step 3, the use of transfer learning technology to optimize the prediction performance of the Transformer-based NILM model on tasks in different regions or load types includes a migration fine-tuning strategy, specifically:
[0090] In the pre-training phase, in the source region Pre-train the model for the source task.
[0091] ,
[0092] in, Indicates the region The source task dataset on are the initialization model parameters of the convolutional layer and other layers of the model, are the model parameters of the convolutional layers and other layers saved in pre-training, For load The loss function of
[0093] The pre-trained model parameters Migrate to the target region Target load On and make fine adjustments:
[0094] ,
[0095] in, Target area Datasets, To use the target region Load The model parameters of other layers except the convolutional layers after fine-tuning.
[0096] This implementation method trains the Transformer model on a pre-trained task such as a source task model such as a washing machine model, and then migrates it to NILM tasks of other loads. The convolutional layer parameters based on the Transformer model are frozen to retain the high-level features learned in the pre-training task, while fine-tuning other layers to adapt to the target load NILM task. The pre-trained model is used to accelerate the learning process of the target task, reduce the amount of labeled data required, improve the efficiency of model training, and achieve a performance level comparable to or exceeding that of training from scratch, especially on target tasks with less data.
[0097] Implementation method 6: This implementation method further limits the non-intrusive load monitoring method based on the Transformer model and transfer learning described in implementation method 1. In this implementation method, step 1 is further limited, specifically including:
[0098] Step 1 specifically includes:
[0099] Visualize the power of the bus and each household load to check whether the data is complete; observe the power waveform and delete the missing data lasting more than half an hour. For the missing data of only a few seconds or minutes, keep it as noise to regularize the model;
[0100] The sampling rate of bus data and the power of each household load is unified to achieve time step alignment;
[0101] Data standardization, including:
[0102] Time Bus power It is expressed as:
[0103] ,
[0104] in, is the total number of load types, Indicates load At the point in time The power, is the noise term;
[0105] After data synchronization, the power data is standardized and used for model training, verification, and testing;
[0106] Normalized bus power It can be calculated using the following formula:
[0107] ,
[0108] in, represents the mean value of power, Represents the standard deviation of power.
[0109] In this implementation, the power signal collected by the sensor or meter is preprocessed for subsequent model training, verification and testing. The knowledge transfer and model fine-tuning process utilizes the ability of deep learning models to transfer knowledge between related but different tasks, reducing the need for large amounts of labeled data and reducing training costs and time.
[0110] Implementation method 7: This implementation method is an example of a non-intrusive load monitoring method based on a Transformer model and transfer learning as described above, and specifically includes:
[0111] Step 1: Data preprocessing:
[0112] The power signals collected by sensors or meters are preprocessed for subsequent model training, verification and testing. The specific steps are as follows:
[0113] Step 1: Data cleaning to remove outliers and noise:
[0114] Visualize the power of the bus and each household load to check whether the data is complete. Observe the power waveform and delete the missing data that lasts more than half an hour. For the missing data of only a few seconds or minutes, it is still retained as noise to regularize the model.
[0115] Step 1 and 2: Data alignment
[0116] The sampling rates of the bus data and the power of each household load are unified to achieve time step alignment. Generally, the data with the lowest sampling rate is used as the standard.
[0117] Step 13: Data standardization:
[0118] Time Bus power It is expressed as:
[0119] ,
[0120] in, is the total number of load types, Indicates load At the point in time The power, is the noise term.
[0121] After data synchronization, the power data is standardized and the standardized data can be used for model training, verification and testing. Taking bus data as an example, the standardized bus power It can be calculated using the following formula:
[0122] ,
[0123] in, represents the mean value of power, Represents the standard deviation of power.
[0124] Step 2: Build a Transformer-based NILM model
[0125] Step 21: Model architecture design
[0126] The model architecture proposed in this embodiment is shown in Figure 2, including convolutional layers, pooling layers, position encoding layers, position embedding, Transformer encoders, flattening layers, and fully connected layers. The model extracts features through convolutional layers, and then performs feature extraction and sequence modeling through a four-head three-layer Transformer encoder. Finally, the features are restored and the output is predicted through a flattening layer and a fully connected layer. The overall structure is designed to effectively capture the load operation rules in the sequence data and perform sequence-to-point load power prediction for NILM tasks. Specifically, the Transformer-based NILM model architecture and dimensional design are as follows: Figure 2 shown.
[0127] Step 2: Input layer
[0128] This embodiment adopts a sequence-to-point learning strategy, in which the model input Is the length The goal is to predict the center point of the bus power sequence. Load Power Therefore, the input bus sequence length at the input layer is .
[0129] Step 2: One-dimensional convolution layer and maximum pooling layer
[0130] Power Sequence It enters the one-dimensional convolution layer 1 in sequence to perform preliminary feature extraction, then enters the maximum pooling layer 1 for preliminary extraction of key features, then further extracts features through the one-dimensional convolution layer 2, and finally enters the maximum pooling layer 2 to complete the feature extraction process. Among them, the one-dimensional convolution layer performs a convolution operation on the input bus power sequence to extract local features in the bus power sequence, and controls the dimension of the output feature by adjusting the number of output channels. This step is used for the model to learn the abstract features of the input sequence and provide feature input for subsequent position embedding and Transformer encoder. Both convolution layers can be expressed by the following formula:
[0131] ,
[0132] Then the convolutional layer output Perform maximum pooling, that is, downsample the extracted features so that the model focuses on more significant features in the sequence. Using the maximum pooling layer effectively retains the key information in the sequence while reducing the number of parameters, which helps improve the efficiency and generalization ability of the model. Both maximum pooling layers can be expressed by the following formula:
[0133] .
[0134] Step 2-3: Position Encoding Layer
[0135] In the Transformer model, since the self-attention mechanism does not have the ability to process the position information of elements in the sequence, a position encoding layer is introduced to give the model the ability to perceive the order. In this embodiment, sine and cosine functions are used for position encoding to generate a unique encoding vector for each position. The mathematical expression of position encoding is as follows:
[0136] For each position in the sequence and each dimension , position encoding No. The dimensions are calculated as follows:
[0137] ,
[0138] ,
[0139] in, is the model dimension. This ensures that the encoding of each position is unique and the encodings of adjacent positions are similar, allowing the model to learn position information.
[0140] Step 214: Position Embedding Layer
[0141] In order to provide the model with information about the position of each element in the sequence, this embodiment introduces position embedding. This is particularly important for the attention-based model Transformer of this embodiment, because the Transformer itself does not have the ability to process sequence order. Position embedding is a method of encoding the absolute position information of each position in a sequence as a vector. By adding position embedding, the model can understand the relative position of each element in the sequence, which helps the model distinguish the importance of different positions. Position embedding can be combined with the features extracted by the convolutional layer to enhance the representation ability of the model and enable the model to better understand the sequence data.
[0142] ,
[0143] in, is the result of position embedding, is the output after the second maximum pooling layer, is the position information of the sine and cosine codes. The position code is added to the features of each sequence element by addition operation, and the dimension of the output after adding the position code will be consistent with the dimension before adding the position code.
[0144] Step 215: Transformer encoder
[0145] The Transformer encoder in this embodiment is a four-head three-layer encoder structure, which mainly includes the following steps:
[0146] Step 2151: Multi-head attention mechanism
[0147] The multi-head attention mechanism is one of the core components of the Transformer model, which enables the model to capture information from different representation subspaces simultaneously. In the multi-head attention mechanism, in each encoder layer, the input sequence is mapped into query ,key Sum vector.
[0148] ,
[0149] ,
[0150] ,
[0151] in, , , are three randomly initialized matrices.
[0152] Then, by calculating the query and key The dot product of is then normalized by softmax to obtain the attention weight of each position to all positions. Finally, the attention weight is multiplied by the value vector , and perform weighted summation to obtain the final attention output .
[0153] ,
[0154] in, represents the scaling factor, is the dimension of the key.
[0155] The multi-head attention mechanism performs multiple attention functions in parallel, each time using a different linear transformation to obtain , , To improve the expressiveness of the model:
[0156] ,
[0157] in, , , , and is the parameter matrix of model learning, Is the number of heads, you can set the number of heads .
[0158] Step 2152: Residual Connection
[0159] In order to avoid the problem of gradient vanishing or gradient exploding when training deep networks, Transformer introduces residual connections to strengthen forward and backward propagation. Specifically, residual connections are used to embed the position And the output after multi-head attention Addition:
[0160] ,
[0161] This allows gradients to propagate more smoothly, speeding up training and improving model performance.
[0162] Step 2153: Layer Normalization
[0163] Layer normalization is a standardization technique that normalizes the distribution of each feature in order to speed up training and improve the generalization performance of the model:
[0164]
[0165] in, The columns of the matrix The mean value is obtained by taking the unit as is the dimension of the matrix rows, Indicates the matrix Line Elements of a column. The columns of the matrix The variance is obtained with unit. A very small number to prevent the denominator from being 0 during the calculation process.
[0166] Step 2154: Feedforward Neural Network
[0167] Build a basic neural network structure, which contains two linear layers and a ReLU (Rectified Linear Unit) activation function. By combining the linear layer and the ReLU activation function, the input Perform feature transformation and nonlinear mapping to obtain the output of the feedforward neural network .
[0168] ,
[0169] Among them, the ReLU activation function , if the input is a positive number, the ReLU function outputs the value; if the input is a negative number or zero, it outputs 0. The ReLU activation function helps introduce nonlinear characteristics into the network, helps alleviate the gradient vanishing problem, and speeds up the convergence of the network.
[0170] Step 216: Flatten the layer
[0171] In the network architecture proposed in this application, the flattening layer does not involve parameter learning. Its main function is to transform the multidimensional tensor processed by the Transformer encoder into Convert to a one-dimensional tensor , so that the data can be processed by the fully connected layers behind the model.
[0172] Step 217: Fully connected layer
[0173] Build a three-layer fully connected network and The structure composed of activation functions. Through the linear layer and Activation function combination, after flattening Perform feature transformation and nonlinear mapping to learn complex feature representations. Finally, the NILM prediction result is obtained:
[0174] ,
[0175] in, Indicates load At the midpoint of the input sequence The corresponding power value.
[0176] Step 22: Model training
[0177] The model training process is a key step in enabling the Transformer model to accurately perform non-intrusive load monitoring. This process involves the selection of loss functions, the application of optimization algorithms, and the implementation of a series of training strategies aimed at minimizing prediction errors and improving the generalization ability of the model.
[0178] Step 221. Loss Function
[0179] function Defines the mapping from the input bus sequence to the load power, which can be parameterized in the form Indicates that are model parameters, The deep learning model designed for us. The model training process involves minimizing the prediction error, using the mean square error as the loss function to calculate the error between the model's predicted load power and the actual load power. The mean square error function measures the average of the sum of squares of the differences between the predicted value and the true value, and is suitable for regression tasks.
[0180] ,
[0181] in, express Load at a time point The actual power value, express Load at a time point The predicted power value, represents the number of training samples, Indicates load The loss function is Represents the set of loss functions for all loads.
[0182] Step 222: Optimizer
[0183] In order to optimize the model parameters, this application method chooses to use the Adam optimizer. Adam is an optimization algorithm based on first-order gradients that can automatically adjust the learning rate, thereby showing good convergence on NILM tasks and complex data.
[0184] Step 223: Training strategy
[0185] Model training is done by inputting training data into the model in batches and then adjusting the model parameters over multiple iterations. Each iteration involves using forward propagation to calculate the model output and loss function value, backpropagation to calculate the gradient of the loss function relative to each parameter, and using the Adam optimizer to update the model parameters based on the gradient. Each batch of data processed will produce a loss value, and the Adam optimizer will update the model parameters to minimize this loss value.
[0186] At the same time, in order to prevent the model from overfitting, an early stopping strategy is adopted. If the loss on the validation set does not decrease significantly in multiple consecutive iterations, the training process is stopped.
[0187] Step 3: Transfer Learning Technology
[0188] In the field of NILM, the goal of transfer learning is to use a source load task Use the knowledge learned from the past to improve tasks in different regions or load types Prediction performance on the source task With the dataset Related, among which Is the source region The bus power sequence, The corresponding load The power, Indicates the total number of load types. With the dataset Related, among which The target area The bus power sequence, The corresponding load In this embodiment, transfer learning is used to improve the performance and efficiency of NILM. Specifically, the following steps are included:
[0189] Step 31: Model freezing layer selection
[0190] First, select the model layer to be frozen for transfer learning. In this embodiment, the model parameters of the frozen convolutional layer are selected mainly from the following aspects:
[0191] 1) Generality of feature extraction: In NILM, convolutional layers are often used to extract useful features from power consumption data, such as the on / off behavior of loads, usage patterns, periodicity, etc. These features have a certain generality across different environments and loads. If these layers have been trained on a wide range of datasets, they can capture the key knowledge of extracting features from power signals, which is general and can be applied to new datasets.
[0192] 2) Adaptability and stability: When dealing with new environments or new loads, the NILM model can utilize the existing feature extraction capabilities by keeping the convolutional layer parameters unchanged. This ensures that the model performs more stably in new environments and reduces performance fluctuations caused by different data distributions.
[0193] 3) Prevent overfitting: Especially in new environments with less data or fewer types of loads, retraining all layers may cause the model to overfit to a small number of training samples, thereby reducing generalization ability. By freezing the pre-trained feature extraction layer, the number of free parameters of the model can be effectively reduced, reducing the risk of overfitting.
[0194] 4) Training efficiency: Freezing pre-trained layers can reduce the number of parameters that need to be updated during training, thereby reducing the demand for computing resources and speeding up the training process, which is especially important in environments with limited computing resources.
[0195] 5) Focus on high-level features: In NILM tasks, it is often necessary to adjust the last few layers of the model according to the specific environment to capture the unique consumption patterns and behaviors of specific workloads. After freezing the convolutional layers, more resources and attention can be focused on the adjustment and optimization of these layers.
[0196] Therefore, the strategy of freezing convolutional layers in NILM is mainly to exploit the already learned general power feature extraction capabilities while reducing the complexity and resource consumption of the adjustment requirements for the target task.
[0197] Step 32: Source Task Selection
[0198] In transfer learning, choosing the right source task It is crucial. The choice is based on the data of the source task The richness and representativeness of Similarities between. Ideal It should contain enough variation and complexity to ensure that the learned features can be effectively transferred to other tasks.
[0199] In view of the NILM problem, this embodiment adopts two methods to determine the appropriate : Analysis of working and usage characteristics of the average number of active channels and load of convolutional layers.
[0200] Step 321: Average number of active channels in the convolutional layer
[0201] The average number of active channels in the convolutional layer reflects the activation frequency of the model when processing load data. Specifically, by setting the activation threshold to 0.01, the number of channels exceeding this threshold is counted in each forward propagation. In time The number of active channels is :
[0202] ,
[0203] in, is the indicator function,
[0204] ,
[0205] in, is load In time Corresponding to The output value of each channel, is the total number of channels in the convolutional layer. Throughout the observation sequence Average number of active channels in The calculation formula is:
[0206] .
[0207] Select the workload with the highest average number of active channels as the source task, whose index :
[0208] .
[0209] In the simulation experiment of the average number of active channels in the convolutional layer, the washing machine has the highest average number of active channels, so we initially considered choosing the washing machine for the subsequent transfer learning strategy simulation. .
[0210] Step 322: Analysis of load working characteristics and usage characteristics
[0211] In addition to quantitative indicators, this embodiment also analyzes different loads in terms of electrical characteristics and operating characteristics. The rationality of choosing a washing machine as the source task lies in its universal use in households and its complex operating mode. The working cycle of a washing machine includes multiple stages, such as water injection, washing, rinsing, and drying, and each stage has a unique power consumption pattern. In addition, different laundry programs (such as fine wash, quick wash, etc.) further increase the diversity of operating modes.
[0212] Compared with other household loads, the power load characteristics of washing machines not only vary greatly, but also have a high degree of periodicity and phase characteristics, which are also present in many other household loads but are not as obvious or complex as those of washing machines. For example, compared with a simple on / off load (such as an electric kettle) or a load with relatively stable power consumption (such as a refrigerator), the power load characteristics of washing machines not only vary greatly, but also have significant periodicity and phase characteristics. These characteristics give the load monitoring Transformer model for washing machines an advantage in learning how to extract diverse load characteristics from complex usage patterns.
[0213] Therefore, based on the above two methods, it is determined that the washing machine is selected as the source task in this embodiment. .
[0214] Step 33: Migration fine-tuning strategy
[0215] The target tasks of NILM transfer learning in this embodiment involve two aspects: inter-regional migration and inter-load migration.
[0216] 1) Inter-regional transfer: Inter-regional transfer learning is to evaluate the The model parameters trained on In another region The performance of the same load. are the model parameters of the frozen layers in transfer learning, are the model parameters that need to be fine-tuned.
[0217] 2) Load transfer: Load transfer learning is to explore Model parameters trained on a load Whether the migration to the source region can be successful Or another region Another load of .
[0218] Both types of migration can be described using the same mathematical framework to show how The model parameters learned from Transferred and fine-tuned to suit the target task . This involves two steps: model pre-training and model parameter transfer fine-tuning.
[0219] Step 331: Model pre-training
[0220] In the pre-training phase, in the source region Pre-training the model for washing machines.
[0221] ,
[0222] in, Indicates the region The washing machine dataset on are the initialization model parameters of the convolutional layer and other layers of the model, are the model parameters of the convolutional layers and other layers saved in pre-training, For load The loss function of .
[0223] Step 332: Model parameter migration and fine-tuning
[0224] Then, the pre-trained model parameters Migrate to the target region Target load On, and make fine adjustments:
[0225] ,
[0226] in, Target area If the target region is You can also write . To use the target region Load The model parameters of other layers except the convolutional layers after fine-tuning.
[0227] Finally, in the target area and target load Evaluate the performance of the migrated model on:
[0228] .
[0229] The above knowledge transfer and model fine-tuning process utilizes the ability of deep learning models to transfer knowledge between related but different tasks, reducing the need for large amounts of labeled data and reducing training costs and time.
[0230] Step 4: Experimental verification and model deployment
[0231] After the model migration is completed, each load model is saved. In order to evaluate the load monitoring performance of the model, this embodiment selects the following evaluation indicators to evaluate the algorithm:
[0232] 1) Mean Absolute Error (MAE): Evaluation Load Predicted value at each time point With actual value The mean of the absolute differences between . The smaller it is, the more accurate the prediction results of the model are. Represents the total number of test samples.
[0233] .
[0234] 2) Normalized Signal Aggregate Error (SAE): It indicates the relative error of total energy. The smaller the SAE, the smaller the prediction error of the model and the better the model performance.
[0235] ,
[0236] in, Indicates load The total energy consumption, Indicates the predicted load The total energy consumption, is the sampling interval (in this embodiment, the sampling interval is 8 seconds).
[0237] 3) Energy per Day (EpD): It indicates the absolute error of energy prediction in one day. The smaller the EpD, the smaller the absolute error of energy prediction in one day, and the better the model performance.
[0238] ,
[0239] in, , indicating the sample The total number of days included in . , indicating the number of sampling points contained in a day. , indicating load The sum of actual energy consumed during a day cycle, , indicating load The total amount of energy predicted over a one-day period.
[0240] Performance evaluation can guide model optimization and ensure the accuracy and reliability of the monitoring system. Finally, the trained model is deployed to the actual monitoring system, such as integrated into smart meters or energy management systems, to achieve detailed monitoring and management of electricity consumption in homes or industrial sites, and provide support for energy conservation and efficient use of loads.
[0241] The technical effects of the present invention are given below:
[0242] A. Dataset
[0243] In order to verify the effectiveness and transferability of the model of the present invention, three public datasets, REFIT, UK-DALE and REDD, were selected:
[0244] 1) REFIT: REFIT data is collected from 20 buildings in the UK from 2013 to 2015. The dataset is power data sampled every 8 seconds, including the power of the bus and each load. In the experiment of the present invention, REFIT is the largest of the three datasets, so it may have better generalization ability when used to train deep learning models.
[0245] 2) UK-DALE: The UK-DALE dataset contains power data of five households in the UK from 2013 to 2015. The power sampling periods of the bus and each load are 1 second and 6 seconds respectively.
[0246] 3) REDD: REDD is a dataset collected from 6 US households. The dataset includes the power of the bus and multiple loads, with sampling periods of 1 second and 3 seconds respectively. In addition, REDD also provides high-frequency current and voltage data at a sampling frequency of 15KHz. The observation length ranges from 3 days to 19 days.
[0247] B. Data Preprocessing
[0248] First, the data are aligned in time step. According to the sampling rates of the three data sets selected by the present invention, REFIT has the smallest sampling rate, so the sampling rates of the three data sets are unified to the sampling rate of REFIT, that is, the UK-DALE and REDD data sets are downsampled to 1 / 8 Hz.
[0249] Then, the data is standardized. In the experiments of the present invention, the mean and standard deviation values used for standardization are shown in Table 1. It should be noted that the parameters in Table 1 are only used to standardize the model training, validation and test data, and are not used to determine the actual mean and variance of these household loads.
[0250] Table 1 Standardization parameters of data
[0251]
[0252] Finally, the three data sets are divided. The data division method is shown in Table 2. It should be noted that the REDD data set does not contain electric kettle data, so the corresponding table content is a horizontal line.
[0253] Table 2 Division of three public datasets
[0254]
[0255] C. Verify the effectiveness of the Transformer model proposed in this paper
[0256] In order to evaluate the Transformer model proposed in the present invention (the present invention), several state-of-the-art architectures were used for comparison, including a sequence-to-point convolutional neural network (sequence-to-point S2P) and a bidirectional long short-term memory network (bidirectional LSTM) as well as a neural network (BERT4NILM) model that first applied the Transformer model.
[0257] 1) CNN-based Seq2point model (sequence to point S2P): The model contains multiple one-dimensional convolutional layers and ReLU activation functions, as well as two fully connected layers to process the input active power sequence. The model first processes the input bus active power sequence through a series of convolutional layers, and then outputs a single load average active power estimate at the midpoint of the sequence through a fully connected layer.
[0258] 2) Bidirectional Long Short-Term Memory Network (Bidirectional LSTM): The main structure of the bidirectional LSTM model includes an initial one-dimensional convolutional layer, two bidirectional LSTM layers, and two fully connected layers. By combining the advantages of convolutional neural networks and bidirectional long short-term memory networks, the model can not only handle long-term dependencies in time series data, but also capture the global context information of the sequence through bidirectional transmission, thereby achieving more accurate household appliance electricity consumption prediction in the NILM task.
[0259] 3) Transformer-based model (BERT4NILM): This model is based on the Transformer method and combines the encoder-decoder architecture with the attention mechanism. By combining the processing power of time series data with attention focus, it can achieve higher accuracy and efficiency in predicting the power consumption pattern of a single load compared to models without attention mechanisms.
[0260] The three networks were modified to have consistent hyperparameters with the Transformer model proposed in this application, and then the above four models were trained until convergence. The general hyperparameter settings of the algorithm are shown in Table 3.
[0261] Table 3 General hyperparameter settings of the algorithm
[0262]
[0263] Table 4 shows the comparison results of different algorithms and the Transformer model proposed in the present invention (the best results in the four experiments are marked in black bold font). It can be seen from Table 4 that compared with sequence-to-point S2P, bidirectional LSTM and BERT4NILM, the results of the Transformer model proposed in the present invention are more stable and accurate. This verifies the effectiveness of the Transformer model proposed in the present invention.
[0264] Table 4 Comparison results of training and testing different algorithms on REFIT and the Transformer model proposed in this invention
[0265]
[0266] D. Transformer model transfer learning verification
[0267] a. Count the average number of activated channels in the convolutional layer to select the source task for Transformer model transfer learning
[0268] The present invention sets the activation threshold to 0.01, and counts the number of channels exceeding this threshold in the second convolutional layer in each forward propagation of the model of the present invention, and further averages the number of active channels of all batches of test data to obtain the average number of active channels reflecting the overall activity of the model.
[0269] Table 5 shows the statistical results of the average number of active channels in the convolutional layers of the five load models. The average number of active channels in the washing machine model is higher than that in other load models. This result shows that the convolutional layer of the washing machine model has learned more key features, which are essential for identifying the complex working mode of the load. At the same time, the washing machine model shows the most active channels, which reflects its high responsiveness and sensitivity under changing working conditions.
[0270] These findings not only validate the advantages of the washing machine model in capturing complex load behaviors, but also suggest that it may exhibit better adaptability and generalization capabilities when performing transfer learning.
[0271] Table 5 Statistics of the average number of active channels in the convolutional layer of the Transformer model
[0272]
[0273] b. Verify the transfer learning performance of the present invention
[0274] In order to verify the performance of the proposed transfer learning method of the present invention, the following four sets of simulation designs were carried out:
[0275] 1) Same dataset test: The model is trained on the REFIT dataset and evaluated on the same dataset. The same method is also applied to the UK-DALE and REDD datasets, and the results of the same dataset test are used as the baseline results.
[0276] 2) Direct cross-dataset testing: The Transformer model of the present invention is trained on the REFIT dataset and directly tested on the UK-DALE and REDD datasets to evaluate the direct transferability of the model.
[0277] 3) Model parameter migration and target dataset fine-tuning: The Transformer model of the present invention is trained only on REFIT, the convolutional layers of the model are frozen, and then the remaining layers of the Transformer model are fine-tuned using the UK-DALE and REDD datasets respectively, and tested on these two datasets.
[0278] 4) Source task load model parameter transfer: Transfer learning was performed on the source task load washing machine. Specifically, the parameters of the washing machine Transformer model trained on the REFIT dataset were used to freeze the convolutional layers of the model, and the other layers were fine-tuned on the UK-DALE and REDD datasets, and performance tests were performed.
[0279] The above simulation design is intended to verify the performance of the model of the present invention in different levels of transfer learning applications, from direct cross-domain application to migration fine-tuning of the source load model. The simulation results are shown in Tables 6-7 according to the test data sets.
[0280] Table 6 shows the four sets of simulation results on the UK-DALE dataset. The same evaluation index of each load is compared longitudinally, and the best results among the four sets of simulation designs are marked in black bold font.
[0281] From the results in Table 6, we can see that compared with the same dataset test on UK-DALE, the direct cross-dataset test of training on REFIT and then testing on UK-DALE has better results. In particular, in the four experiments on electric kettles, the results of the second group are the best. The reason behind this result may be that REFIT and UK-DALE are both datasets from the UK, and the working characteristics of the same load in the same region are relatively similar, while the scale of the REFIT dataset is larger, so the model trained with REFIT may have better generalization.
[0282] The model parameter migration and target dataset fine-tuning tests have the best performance on MAE and EpD of microwave ovens and three evaluation indicators of washing machines, indicating that the Transformer convolutional layer can extract more effective features when trained on REFIT than on the UK-DALE dataset. It also illustrates the feasibility of the strategy of migrating Transformer model parameters, freezing the convolutional layer and fine-tuning other layers.
[0283] After migrating the source task washing machine model to the UK-DALE dataset, we can see that the best performance was achieved in all three evaluation indicators for the refrigerator and dishwasher loads, and the SAE result for the microwave oven was also better than the result of the same dataset test. This shows that the source task model migration also played a positive role in improving the model performance.
[0284] Table 6 Transfer learning performance of the Transformer model of the present invention tested on the UK-DALE dataset
[0285]
[0286] Table 7 shows the results of four sets of experiments conducted on the REDD dataset. It should be noted that the REDD dataset does not include loads such as electric kettles, so the evaluation indicators of electric kettles on the REDD dataset are not listed in Table 7.
[0287] From the experimental results in Table 7, we can see that, unlike the UK-DALE dataset, the direct cross-dataset test of training on REFIT and then testing on REDD has the worst effect. The potential reason for this result may be that the REFIT and REDD datasets come from different countries, and the standard voltage, frequency, load manufacturing standards and usage habits of the two countries are different. This also further illustrates the necessity of transfer learning and model fine-tuning for datasets with large differences.
[0288] From the results of the third group of simulations on the REDD dataset, the frozen convolutional layer and the target dataset fine-tuning test experiments, it can be seen that the best performance was achieved on the three evaluation indicators of the washing machine and the MAE and EpD of the refrigerator, which also illustrates the effectiveness of the transfer learning proposed in the present invention to a certain extent.
[0289] Finally, after a washing machine-specific migration test on the REDD dataset, the best performance was achieved on the three evaluation indicators of microwave ovens and dishwashers, as well as the SAE evaluation indicator of refrigerators. The possible reason behind this result is that the data scale of REFIT is dozens of times that of REDD data, and the data collection cycle is also longer. The convolutional layer parameters of the Transformer model trained on REFIT extract more sufficient data features, providing strong data support for the power prediction of subsequent layers. In addition, from the analysis of the working characteristics and usage characteristics of the load, since dishwashers and washing machines have similar electrical performance and working modes, it can be found that the best evaluation index performance was obtained in the washing machine model parameter migration simulation whether in the UK-DALE dataset or the REDD dataset. This shows that the effect of transfer learning on loads with similar working characteristics and usage characteristics may be better.
[0290] Table 7 Transfer learning performance of the Transformer model of the present invention tested on the REDD dataset
[0291]
[0292] The simulation results on the above two data sets verify the effectiveness and practicality of the load monitoring method based on the Transformer model and transfer learning proposed in this invention, which solves the problems in the prior art. The proposed method can better capture the complex nonlinear relationship in the load data and improve the accuracy and reliability of load monitoring. In addition, the use of transfer learning methods enables the model to adapt quickly when applied to new power systems or environments, reducing the need for readjustment and retraining.
[0293] It should be noted that the above simulation design is only an example of the implementation of the present invention, and can be adjusted and optimized according to specific needs in actual applications. For example:
[0294] 1) Sensor selection and data collection: You can choose the appropriate sensor type and data collection equipment according to the specific application scenario to balance cost and performance requirements. Different sensors may have different accuracy, sampling frequency and cost, and you can make a choice based on actual needs.
[0295] 2) Model structure and parameter selection: CNNs, Transformers, and fully connected layer structures are used in model design, but the model structure and parameters can also be adjusted according to load characteristics and real-time requirements. For example, the number of Transformer layers can be increased or decreased, the size of the convolution kernel, the number of neurons can be adjusted, etc.
[0296] 3) Transfer learning strategy:
[0297] Transfer learning is flexible and allows you to choose different base models for initialization and adjust fine-tuning strategies based on the similarities and differences between different loads, such as freezing parameters of different layers and adjusting learning rates.
[0298] It is worth noting that although Transformer technology has been widely used in fields such as natural language processing and machine vision, its application in the field of load monitoring is still in the exploratory stage. Therefore, the research on the Transformer-based method and its migration ability in this invention is expected to bring new technological breakthroughs and application prospects in the field of NILM.
Claims
1. A non-intrusive load monitoring method based on Transformer model and transfer learning, It is characterized in that The method comprises: Step 1: preprocess the collected power signal; Step 2: Establish a Transformer-based NILM model, and use the Transformer-based NILM model to predict the power of a certain load; The input of the Transformer-based NILM model is the bus power series , the goal is to predict the power of a certain load at the center point of the sequence, including convolutional layers, pooling layers, position encoding layers, position embedding layers, Transformer encoders, flattening layers, and fully connected layers; The bus power sequence It sequentially enters the one-dimensional convolution layer for preliminary feature extraction, then enters the maximum pooling layer for preliminary key feature extraction, then further extracts features through the one-dimensional convolution layer, and finally enters the maximum pooling layer to complete the feature extraction process; The position encoding layer uses sine and cosine functions to perform position encoding and generates a unique encoding vector for each position; The Transformer encoder includes a multi-head attention mechanism, which performs multiple attention functions in parallel, each time using a different linear transformation to obtain the query ,key ,value To improve the expressiveness of the model; The fully connected layer performs feature transformation and nonlinear mapping on the flattened one-dimensional tensor through a combination of a linear layer and a tanh activation function to learn complex feature representations, and finally obtains the NILM prediction result; Step 3: Use transfer learning technology to optimize the prediction performance of the Transformer-based NILM model on tasks in different regions or load types to obtain non-intrusive load monitoring results.
2. According to claim 1, a non-intrusive load monitoring method based on Transformer model and transfer learning, It is characterized in that In step 2, the multi-head attention mechanism executes the attention function multiple times in parallel, each time using a different linear transformation to obtain the query ,key ,value To improve the expressiveness of the model, specifically: , in, , , , and is the parameter matrix of model learning, is the number of heads.
3. According to claim 1, a non-intrusive load monitoring method based on Transformer model and transfer learning, It is characterized in that In step 2, the fully connected layer performs feature transformation and nonlinear mapping on the flattened one-dimensional tensor through a combination of a linear layer and a tanh activation function to learn complex feature representations, and finally obtains the NILM prediction result, which is specifically: , in, Indicates load At the midpoint of the input sequence The corresponding power value.
4. According to claim 1, a non-intrusive load monitoring method based on Transformer model and transfer learning, It is characterized in that In step 3, the use of transfer learning technology to optimize the prediction performance of the Transformer-based NILM model on tasks in different regions or load types includes source task selection, specifically: Calculate load Throughout the observation sequence Average number of active channels in ,The workload with the highest average number of active channels is selected as the source task.
5. According to claim 4, a non-intrusive load monitoring method based on Transformer model and transfer learning, It is characterized in that The source task selection also includes determining the source task in combination with the power load characteristics, periodicity and phase characteristics of the load.
6. According to claim 5, a non-intrusive load monitoring method based on Transformer model and transfer learning, It is characterized in that In step 3, the use of transfer learning technology to optimize the prediction performance of the Transformer-based NILM model on tasks in different regions or load types includes a migration fine-tuning strategy, specifically: In the pre-training phase, in the source region Pre-train the model for the source task. , in, Indicates the region The source task dataset on are the initialization model parameters of the convolutional layer and other layers of the model, are the model parameters of the convolutional layers and other layers saved in pre-training, For load The loss function of The pre-trained model parameters Migrate to the target region Target load On, and make fine adjustments: , in, Target area Datasets, To use the target region Load The model parameters of other layers except the convolutional layers after fine-tuning.
7. According to claim 1, a non-intrusive load monitoring method based on Transformer model and transfer learning, It is characterized in that Step 1 specifically includes: Visualize the power of the bus and each household load to check whether the data is complete; observe the power waveform and delete the missing data lasting more than half an hour. For the missing data of only a few seconds or minutes, keep it as noise to regularize the model; The sampling rate of bus data and the power of each household load is unified to achieve time step alignment; Data standardization, including: Time Bus power It is expressed as: , in, is the total number of load types, Indicates load At the point in time The power, is the noise term; After data synchronization, the power data is standardized and used for model training, verification, and testing; Normalized bus power It can be calculated using the following formula: , in, represents the mean value of power, Represents the standard deviation of power.
8. A computer device comprising a memory and a processor, wherein a computer program is stored in the memory. It is characterized in that When the processor runs the computer program stored in the memory, the steps of the method according to any one of claims 1 to 7 are performed.
9. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a plurality of computer instructions, and the plurality of computer instructions are used to enable a computer to execute the method according to any one of claims 1 to 7.
10. An electronic device, It is characterized in that include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 7.
