Energy consumption monitoring method and system for green building based on Internet of Things
By combining the Seq2Seq model with a bidirectional Bi-GRU recurrent neural network, the prediction accuracy problem of traditional models when processing sequences are not equal, and more flexible and accurate energy consumption prediction in IoT building energy consumption analysis is achieved, improving the The robustness of the model.
Patent Information
- Application Number
- CN202411256518.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-09
- Publication Date
- 2024-12-13
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Traditional RNN and LSTM models cannot directly deal with the problem of different input and output sequence lengths when processing IoT building energy consumption data, resulting in a decrease in prediction accuracy. The prior art often introduces noise or loses information through fill or truncation operations.
Combining the Seq2Seq model and the bidirectional Bi-GRU recurrent neural network, the input and output sequences are processed through the encoding layer and the decoding layer respectively, and the output sequence of variable length is generated to solve the problem of sequence inequality, and to improve the accuracy of prediction through attention mechanism Sex and robustness.
It realizes more flexible and accurate energy consumption prediction in IoT building energy consumption analysis, improves the robustness and prediction accuracy of the model, and avoids the reduction in prediction accuracy caused by sequence inequality.
Smart Images

Figure CN119128388A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of Internet of Things building information technology, especially the field of intelligent processing and application technology, specifically to the application of neural network model technology in Internet of Things building information for energy consumption analysis, and particularly to an energy consumption monitoring method and system based on Internet of Things green buildings. Background Art
[0002] At present, neural network technologies such as convolutional neural network (CNN) and long short-term memory network (LSTM) have been widely used in green building energy consumption monitoring systems based on the Internet of Things. These technologies collect building energy consumption data through the Internet of Things technology and use deep learning models to process and analyze the data to achieve accurate monitoring and prediction of energy consumption.
[0003] The literature RUNGE J, ZMEUREANU RA review of deep learning techniques for forecasting energy use in buildings[J].Energies, 2021, 14(3): 608 discloses a convolutional neural network (CNN) technology for energy consumption analysis in IoT buildings, which is used to process two-dimensional image data such as temperature distribution maps and light intensity maps to identify key factors affecting energy consumption. However, the advantages of CNN are relatively limited when directly processing time series data.
[0004] The literature KIM TY, CHO S B. Predicting residential energy consumption using CNN-LSTM neural networks [J]. Energy, 2019, 182 (6): 72-81 and the literature MARINO DL, AMARASINGHE K, MANIC M. Building energy load forecasting using deep neural networks [C] / / IECON 2016-42nd Annual Conference of the IEEE Industrial Electronics Society, 2016: 7046-7051 both disclose energy consumption analysis technology for IoT buildings using LSTM neural networks, which essentially have the defect of only being able to handle problems of equal length from sequence to sequence.
[0005] That is, if the lengths of the input sequence and the output sequence are inconsistent, traditional RNN and LSTM models are difficult to apply directly. Specifically, when training traditional RNN and LSTM models, it is usually assumed that the input sequence and the output sequence have the same length. Each time step in the model receives an input and produces an output. This structure limits the model's ability to process sequences of unequal lengths. At this stage, the above defects are manifested as follows: when it is necessary to process all building energy consumption data within an arbitrary time period and predict the building energy consumption data at all times in a certain period of time, traditional RNN and LSTM models are unable to cope with it. Because they cannot directly generate output sequences that are longer or shorter than the input sequence. In order to circumvent this problem, the input or output sequence is sometimes padded or truncated, but this often introduces noise or loses useful information, resulting in a decrease in prediction accuracy.
[0006] To this end, the present invention proposes an energy consumption monitoring method and system based on the Internet of Things green building. Summary of the invention
[0007] In view of this, the present invention hopes to provide an energy consumption monitoring method and system based on the Internet of Things green building to solve or alleviate the technical problems existing in the prior art, that is, how to solve the problem that the neural network can only process sequences of equal length when facing the application of energy consumption analysis in the Internet of Things building information, and at least provide a beneficial option for this; the technical solution of the present invention is implemented as follows:
[0008] First, energy consumption monitoring method of green buildings based on IoT:
[0009] 1. Overview:
[0010] The present invention aims to combine the Seq2Seq model with the bidirectional Bi-GRU recurrent neural network model to solve the problem of unequal length of data sequences in the energy consumption analysis of IoT buildings. By introducing the Seq2Seq model, the input and output can be divided into two parts, the encoding layer and the decoding layer, so as to support the situation where the input and output sequences are of unequal length. At the same time, by utilizing the advantages of the bidirectional Bi-GRU recurrent neural network model, the scheme can simultaneously capture the forward and reverse dependencies in the time series data, and improve the accuracy and robustness of energy consumption prediction. Specifically, the encoding layer is responsible for processing the input sequence and generating an intermediate vector containing all important information; the decoding layer generates a variable length output sequence based on this intermediate vector and a given hidden state, that is, the energy consumption forecast value for a certain period of time in the future. This combination is expected to provide a more effective solution for energy consumption analysis of IoT buildings.
[0011] (II) Technical solution:
[0012] To achieve the above technical objectives, the present invention selects to perform the following steps:
[0013] 2.1 Step S1, data collection and preprocessing:
[0014] The data set D of building energy consumption is collected through IoT devices (such as smart meters, temperature and humidity sensors, etc.).
[0015] The collected data set D is then cleaned, including removing outliers and missing values, to ensure the accuracy and completeness of the data.
[0016] The Kappa consistency check algorithm is introduced to extract the features of the data set D that are useful for energy consumption prediction, namely historical energy consumption data, time features (hours, dates or seasons) and building area, to form the input sequence S.
[0017] 2.1.1 Step S100, data collection:
[0018] Dataset D includes electricity consumption a, water consumption b, and gas consumption c, as well as external factor data corresponding to these three, including weather d and personnel flow e:
[0019] D={(a i ,b i ,c i ,d i ,e i )|i=1,2,…,N};
[0020] Among them, a i represents the power consumption of the i-th sample; b i represents the water consumption of the i-th sample; c i represents the gas consumption of the i-th sample; d i represents the weather condition of the i-th sample; e i represents the personnel turnover of the i-th sample; N is the total number of samples.
[0021] 2.1.2 Step S101, data extraction:
[0022] For each feature f j ∈{a,b,c,d,e,a rea}, calculate its Kappa consistency score with energy consumption y. Select features with scores higher than the threshold θ as useful features, where a rea is the building area of the ith sample:
[0023] S1010, feature f j and energy consumption are discretized, and then the cross table between them is calculated to obtain the Kappa score;
[0024] S1011, when the Kappa score of a feature is higher than a preset threshold θ, the feature is considered useful for energy consumption prediction. Then all features with Kappa scores higher than the threshold θ are selected as useful features for subsequent model training;
[0025] S1012, then forms the input sequence S:
[0026] S=(x i ,t i ,areai)|i=1,2,…,M;
[0027] Among them, x i =(ai-τ,a i-τ+1 ,…,a i-1 ), represents the historical power consumption data of the i-th input sequence (sliding window); τ is the size of the sliding window. i represents the time feature (hour, date or season) of the i-th input sequence; area i represents the building area of the i-th input sequence; M is the total number of input sequences, which is equal to or less than N; in practical applications, y is the actual energy consumption data (such as electricity consumption), which is used to calculate the Kappa consistency score.
[0028] 2.2 Step S2, activate the Seq2Seq-Bi-GRU recurrent neural network model:
[0029] The recurrent neural network model includes: a Seq2Seq model and a bidirectional Bi-GRU recurrent neural network model; wherein: a bidirectional Bi-GRU is used as a component of the encoder to receive the input sequence S, and the forward and backward GRU layers are used to extract the forward and reverse dependencies in the input sequence S; then the hidden state output by the encoding layer is aggregated into a fixed-length intermediate vector C through an ECA attention mechanism and input into the decoding layer; the decoding layer receives the hidden state and output from the previous time step at each time step through the forward and backward GRU layers, as well as the intermediate vector C as an additional input, to generate a variable-length output sequence S' as a predicted value of energy consumption in a certain period of time in the future.
[0030] The layer structure of the Seq2Seq-Bi-GRU recurrent neural network model includes the following layers connected in sequence:
[0031] 2.2.1 Encoder:
[0032] The encoder is responsible for receiving the input sequence S. Through the bidirectional Bi-GRU network, it can extract the dependencies in the input sequence from both the forward and backward directions, thereby capturing more comprehensive feature information and encoding this information into a series of hidden states.
[0033] (1) Use bidirectional Bi-GRU to receive input sequence S:
[0034] S={(x i ,t i ,area i )|i=1,2,…,M};
[0035] (2) Forward GRU layer:
[0036]
[0037] in, is the forward hidden state of the encoder’s forward GRU layer, is the forward hidden state of the encoder’s forward GRU layer at the previous time step.
[0038] (3) Backward GRU layer:
[0039]
[0040] in, is the backward hidden state of the encoder's backward GRU layer, is the backward hidden state of the backward GRU layer of the encoder at the previous time step.
[0041] (4) Concatenate the forward and backward hidden states to form the encoder output h i :
[0042]
[0043] 2.2.2ECA Attention Mechanism (Encoder-Decoder Attention):
[0044] A bridge is built between the encoder and the decoder, which generates a fixed-length intermediate vector C by weighted summing the hidden states output by the encoder. This intermediate vector C can focus on the part of the input sequence that is most relevant to the current decoding step, thereby improving the accuracy and efficiency of decoding.
[0045]
[0046] Among them, α i is the attention weight, calculated by the encoder output h i The similarity with the current hidden state of the decoding layer is obtained.
[0047] 2.2.3 Decoder:
[0048] It is responsible for generating energy consumption prediction values for a certain period of time in the future and forming an output sequence S'. It also uses a bidirectional Bi-GRU network, combining the intermediate vector C and the hidden state and output of the previous time step to gradually generate prediction results. The decoder can capture the time dependency in the output sequence and generate a prediction sequence of variable length to meet the energy consumption monitoring needs in different time periods.
[0049] Use bidirectional Bi-GRU as the decoder component, including:
[0050] (1) Forward GRU layer:
[0051]
[0052] in, is the backward hidden state of the decoder's forward GRU layer, is the forward hidden state of the forward GRU layer of the decoder at the previous time step, yt is the output of the decoder at the tth time step, and yt-1 is the output of the decoder at the previous time step.
[0053] (2) Backward GRU layer:
[0054]
[0055] in, is the backward hidden state of the backward GRU layer of the decoder, is the backward hidden state of the backward GRU layer of the decoder at the previous time step.
[0056] (3) Concatenate the forward and backward hidden states to form the decoder output s t :
[0057]
[0058] (4) Generate output sequence S':
[0059] S = {ytt = 1, 2, .., T};
[0060] 2.3 Step S3, decoding:
[0061] The output sequence S' obtained in step S2 is converted into an energy consumption matrix A in the form of a time series to realize energy consumption monitoring of the building.
[0062]
[0063] Among them, yt is the output of the decoder at the tth time step, which represents the predicted value of energy consumption in a certain period of time in the future. Specifically, yt is regarded as a multidimensional vector, which represents the predicted values of different energy consumption indicators or different regions.
[0064] 2.4 Model training:
[0065] Although the above step S2 uses the Seq2Seq-Bi-GRU recurrent neural network model, the model still needs to be trained before deployment. The training steps include:
[0066] P1. Collect and divide the historical data set D':
[0067] According to step S1, data is collected from historical data to form a data set D', and then the preprocessed data set is divided into a training set D train and the test set D test ;
[0068] P2. Set training parameters:
[0069] Including learning rate, batch size, number of iterations, and Adam optimizer.
[0070] P3. Training model:
[0071] Using the training set D train The model is trained and the model parameters are updated through the back propagation algorithm to minimize the mean square error (MSE) between the predicted value and the actual value, and parameter tuning and model structure adjustment are performed as needed.
[0072] P4. Model evaluation and deployment:
[0073] Repeat forward propagation, loss calculation, and back propagation, and continuously iterate the training process until the stopping condition is met (the maximum number of iterations is reached or the loss function value is less than the threshold).
[0074] (III) Mechanism for solving technical problems:
[0075] 3.1 Introduction of Seq2Seq model:
[0076] The core of the Seq2Seq model lies in its encoding-decoding structure. The encoding layer receives input sequences of unequal lengths (such as historical energy consumption data and its related features) and processes them through a bidirectional Bi-GRU recurrent neural network. The bidirectional Bi-GRU can capture both the forward and reverse dependencies in the sequence and extract more comprehensive and in-depth feature information. The output of the encoding layer is a fixed-length intermediate vector C, which condenses all the important information of the input sequence.
[0077] The decoding layer generates a variable-length output sequence given the hidden state and the intermediate vector C. This means that no matter how the length of the input sequence changes, the length of the output sequence can be adjusted according to actual needs, thus solving the problem of equal length from sequence to sequence. The decoding layer also uses GRU or a similar recurrent neural network structure to ensure the continuity and relevance of the generated sequence.
[0078] 3.2 Advantages of Bidirectional Bi-GRU Recurrent Neural Network:
[0079] The bidirectional Bi-GRU combines the forward and backward GRU layers to capture both the forward and reverse dependencies in the sequence. This is particularly important for energy consumption analysis, because energy consumption data is often affected by multiple factors that may affect energy consumption at different points in time. By capturing these complex dependencies, the model can more accurately predict future energy consumption.
[0080] Compared with the traditional RNN model or LSTM model, the bidirectional Bi-GRU effectively alleviates the problem of gradient disappearance or explosion by introducing gating mechanisms (such as update gates and reset gates). In particular, the internal neurons of the traditional single Seq2Seq model are recurrent neural networks (RNNs), which are prone to gradient disappearance and gradient explosion. The problem is also solved, allowing the model to better process long sequence data. This is also of great significance for energy consumption analysis, because energy consumption data often involves a long time span.
[0081] 3.2 Overall mechanism principle:
[0082] When faced with the task of energy consumption analysis in IoT building information, the present invention first obtains a complete and accurate data set through data collection and preprocessing steps. Then, the input sequence is encoded and decoded using the encoding-decoding structure of the Seq2Seq model. In the encoding stage, the bidirectional Bi-GRU recurrent neural network extracts important feature information of the input sequence and generates an intermediate vector C; in the decoding stage, the model generates an output sequence of variable length as an energy consumption prediction result based on the intermediate vector C and a given hidden state. In this way, the present invention successfully solves the limitations of neural networks when faced with the problem of equal length between sequences, and provides a more flexible and effective solution for energy consumption analysis of IoT buildings.
[0083] Second, energy consumption monitoring system based on IoT green building:
[0084] like Figure 2 As shown, the system includes a processor and a memory connected to the processor, wherein the memory stores program instructions, and when the program instructions are executed by the processor, the processor executes the energy consumption monitoring method as described above, and the processor is connected to:
[0085] (1) The module responsible for collecting building energy consumption data through IoT devices is responsible for collecting building energy consumption data through IoT devices (such as smart meters, temperature and humidity sensors, etc.), including electricity consumption, water consumption, gas consumption, etc., as well as external factor data related to it (such as weather, personnel flow, etc.). The collected data needs to be cleaned to remove outliers and missing values to ensure the accuracy and completeness of the data. In addition, this module also needs to perform feature extraction to screen out features that are useful for energy consumption prediction and form an input sequence S. Its key technologies include:
[0086] 1.1) Data cleaning: Identify and process outliers and missing values through statistical methods.
[0087] 1.2) Feature extraction: Extract key features using methods such as correlation analysis and principal component analysis.
[0088] (2) The Seq2Seq-Bi-GRU model building module is responsible for building the Seq2Seq-Bi-GRU recurrent neural network model: It consists of an encoder and a decoder. The encoder uses a bidirectional Bi-GRU recurrent neural network that can simultaneously capture the forward and reverse dependencies in the sequence; the decoder generates a variable-length output sequence based on the output of the encoder, that is, the predicted value of energy consumption in a certain period of time in the future. Its key technologies include:
[0089] 2.1) Seq2Seq model: realizes the mapping of unequal length from input sequence to output sequence.
[0090] 2.2) Bidirectional Bi-GRU: Enhances the model’s ability to process sequence data and captures more comprehensive dependencies.
[0091] 2.3) Attention Mechanism: Introducing the attention mechanism in the decoding process enables the model to focus on the key parts of the input sequence more accurately.
[0092] (3) The model training module is responsible for training the Seq2Seq-Bi-GRU model using the preprocessed data set: During the training process, the model parameters are updated through the back propagation algorithm to minimize the error between the predicted value and the actual value. At the same time, parameter tuning and model structure adjustment are also required to improve the prediction performance of the model. Its key technologies include:
[0093] 3.1) Back propagation algorithm: used to update model parameters.
[0094] 3.2) Loss function: Mean square error (MSE), which is used to measure the difference between the predicted value and the actual value.
[0095] 3.3) Adam optimizer: used to accelerate the training process of the model.
[0096] (4) Model evaluation and deployment module responsible for evaluating and deploying the model: In the evaluation phase, the model's prediction performance is tested using a test set and the relevant performance index (MAE) is calculated. If the model performance meets the requirements, it is deployed so that it can run in an actual production environment. Its key technologies include:
[0097] 4.1) Performance evaluation metrics: used to quantify the predictive performance of the model.
[0098] 4.2) Model deployment technology: deploy the trained model to actual application scenarios.
[0099] Compared with the prior art, the present invention has the following beneficial effects:
[0100] 1. Solved the problem of unequal sequence lengths: By introducing the Seq2Seq model, the present invention successfully broke the limitation of traditional neural networks that the input and output must be of equal length when processing sequence data. This allows the model to be more flexibly applied to practical scenarios, especially in the field of IoT building energy consumption analysis, and solves the technical problem that the input historical energy consumption data sequence and the output future energy consumption prediction sequence are often of different lengths.
[0101] Second, improved prediction accuracy: The present invention combines a bidirectional Bi-GRU recurrent neural network to simultaneously capture both positive and negative dependencies in time series data. This comprehensive feature extraction method enables the model to more accurately capture complex patterns in energy consumption data, thereby improving prediction accuracy.
[0102] 3. Enhanced robustness of the model: Since the present invention can process sequence data of unequal lengths and can effectively capture the dependencies in time series data, it exhibits stronger robustness in the face of actual situations such as missing data, abnormal data or data fluctuations, making the model more stable and reliable in practical applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0103] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0104] Figure 1 It is a schematic diagram of the method flow of the present invention;
[0105] Figure 2 It is a schematic diagram of the system composition of the present invention;
[0106] Figure 3 This is a schematic diagram of the "sequence to sequence" architecture of the Seq2Seq model;
[0107] Figure 4 This is a schematic diagram of the model training process of the second embodiment of the present invention;
[0108] Figure 5 This is a schematic diagram of a Python calculation program in step S1 of the first embodiment of the present invention;
[0109] Figure 6 This is a schematic diagram of a model python architecture program of step S2 of the first embodiment of the present invention;
[0110] Figure 7 This is a schematic diagram of a Python execution program for model training in Embodiment 2 of the present invention;
[0111] Figure 8 This is a principle diagram of the "teacher forcing" technique of the second embodiment of the present invention;
[0112] Fig. 9 It is a comparative schematic diagram of the test examples of the present invention; the horizontal axis in the figure is the time period (days), and the vertical axis is the energy consumption level. DETAILED DESCRIPTION
[0113] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the accompanying drawings. In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention can be implemented in many other ways different from those described herein, and those skilled in the art can make similar improvements without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below;
[0114] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0115] Explanation of relevant terms:
[0116] (1) Dataset D: A comprehensive dataset that contains energy consumption data such as electricity consumption a, water consumption b, and gas consumption c, as well as related external factors such as weather d and population flow e.
[0117] (2) Kappa consistency test algorithm: a statistical method used to evaluate the consistency between the prediction results of the classification model and the actual results.
[0118] (3) Input sequence S: After preprocessing and feature extraction, an ordered data sequence containing historical energy consumption data and related features is formed as the input of the model.
[0119] (4) Seq2Seq model: A neural network architecture that can map one sequence to another, especially suitable for situations where the input and output sequence lengths are unequal. Its "sequence to sequence" architecture is as follows: Figure 3 shown.
[0120] (5) Bidirectional Bi-GRU recurrent neural network model: It combines the forward and backward GRU layers to simultaneously capture the positive and reverse dependencies in the sequence, thus improving the expressiveness of the model.
[0121] (6) Intermediate vector C: In the Seq2Seq model, the encoding layer encodes the input sequence into a fixed-length vector, which contains all the important information of the input sequence and is used by the decoding layer to generate the output sequence.
[0122] (7) Hidden states and outputs of the encoding layer: When the encoding layer processes the input sequence, it outputs a hidden state and an output at each time step. These hidden states contain the context information of the sequence and are used for calculations in the decoding layer.
[0123] (8) Forward and reverse dependencies in the input sequence S: In sequence data, the forward dependency refers to the relationship between the current element and the previous element, while the reverse dependency refers to the relationship between the current element and the following element. Bidirectional Bi-GRU can capture both types of dependencies at the same time.
[0124] Embodiment 1: Figure 1 As shown, this embodiment discloses an energy consumption monitoring method based on the Internet of Things green building, including the following execution steps:
[0125] In this embodiment, regarding step S1, data collection and preprocessing: a data set D of building energy consumption is collected through IoT devices (such as smart meters, temperature and humidity sensors, etc.). The collected data set D is then cleaned, including removing outliers and missing values to ensure the accuracy and completeness of the data.
[0126] At the same time, the Kappa consistency check algorithm is introduced to extract the features of the data set D that are useful for energy consumption prediction, namely historical energy consumption data, time features (hours, dates or seasons) and building area, to form the input sequence S.
[0127] Specifically, step S100, data collection: data set D includes power consumption a, water consumption b and gas consumption c, as well as external factor data corresponding to the three, including weather d and personnel flow e:
[0128] D={(a i ,b i ,c i ,d i ,e i )|i=1,2,…,N};
[0129] Among them, a i represents the power consumption of the i-th sample; b i represents the water consumption of the i-th sample; c i represents the gas consumption of the i-th sample; d i represents the weather condition of the i-th sample; e i represents the personnel turnover of the i-th sample; N is the total number of samples.
[0130] Specifically, step S101, data extraction: for each feature f j ∈{a,b,c,d,e,a rea}, calculate its Kappa consistency score with energy consumption y. Select features with scores higher than the threshold θ as useful features, where a rea is the building area of the ith sample:
[0131] S1010, each feature (including energy consumption and other external factors) and energy consumption are discretized, and then the cross table between them is calculated to obtain the Kappa score. The Kappa score is an indicator that measures the consistency between two categorical variables, and is used here to evaluate the correlation between features and energy consumption. Through discretization and calculation of the Kappa score, the contribution of each feature to energy consumption prediction can be effectively evaluated, providing a basis for subsequent feature selection.
[0132] S1011, set a threshold θ. When the Kappa score of a feature is higher than the threshold, the feature is considered useful for energy consumption prediction. Then all features with Kappa scores higher than the threshold are selected as useful features for subsequent model training. By setting a threshold and selecting features with high scores, the number of features can be effectively reduced, the complexity of the model can be reduced, and the most useful information for energy consumption prediction can be retained.
[0133] S1012, then forming an input sequence S: Based on the selected useful features, an input sequence S is formed. Each input sequence includes historical energy consumption data (obtained through a sliding window), time features, and building area. These input sequences will be used for subsequent model training. By forming an input sequence, the original data is converted into a format that can be processed by the model, which facilitates subsequent model training. At the same time, the use of a sliding window can capture the time dependency of energy consumption data and improve the accuracy of prediction.
[0134] S=(x i ,t i ,areai)|i=1,2,…,M;
[0135] Among them, x i =(ai-τ,a i-τ+1 ,…,a i-1 ), represents the historical power consumption data of the i-th input sequence (sliding window); τ is the size of the sliding window. i represents the time feature (hour, date or season) of the i-th input sequence; area i represents the building area of the i-th input sequence; M is the total number of input sequences, which is equal to or less than N; in practical applications, y is the actual energy consumption data (such as electricity consumption), which is used to calculate the Kappa consistency score.
[0136] Specifically, the Python execution program of step S1 above is as follows Figure 5 As shown in the figure, the principle is: Since the Kappa consistency test requires that the input is a categorical variable, it is first necessary to discretize the features and energy consumption using LabelEncoder. For each feature, calculate the Kappa consistency score between it and energy consumption (here is electricity consumption). The higher the score, the better the consistency between the feature and the energy consumption, that is, the more useful the feature is for energy consumption prediction. According to the set threshold θ, features with a Kappa score higher than the threshold are selected as useful features. Based on the selected useful features, an input sequence S is formed. Each input sequence includes historical energy consumption data (obtained through a sliding window), time features, and building area. These input sequences will be used for subsequent model training. Convert the input sequence S to DataFrame format for subsequent model training and other processing.
[0137] In this embodiment, with respect to step S2, a Seq2Seq-Bi-GRU recurrent neural network model is activated: the recurrent neural network model includes: a Seq2Seq model and a bidirectional Bi-GRU recurrent neural network model; wherein: a bidirectional Bi-GRU is used as a component of the encoder to receive the input sequence S, and the forward and reverse dependencies in the input sequence S are extracted through the GRU layers in the forward and backward directions; the hidden state output by the encoding layer is then aggregated into an intermediate vector C of a fixed length through the ECA attention mechanism and input into the decoding layer; the decoding layer receives the hidden state and output from the previous time step at each time step through the GRU layers in the forward and backward directions, as well as the intermediate vector C as an additional input, to generate an output sequence S' of variable length as a predicted value of energy consumption for a certain period of time in the future.
[0138] The layer structure of the Seq2Seq-Bi-GRU recurrent neural network model includes the following layers connected in sequence:
[0139] (I) Encoder:
[0140] The encoder is responsible for receiving the input sequence S. Through the bidirectional Bi-GRU network, it can extract the dependencies in the input sequence from both the forward and backward directions, thereby capturing more comprehensive feature information and encoding this information into a series of hidden states.
[0141] (1) Use a bidirectional Bi-GRU to receive the input sequence S: S = {(x i ,t i ,area i )|i=1,2,…,M};
[0142] (2) Forward GRU layer:
[0143] in, is the forward hidden state of the encoder’s forward GRU layer, is the forward hidden state of the encoder’s forward GRU layer at the previous time step.
[0144] (3) Backward GRU layer:
[0145] in, is the backward hidden state of the encoder's backward GRU layer, is the backward hidden state of the backward GRU layer of the encoder at the previous time step.
[0146] (4) Concatenate the forward and backward hidden states to form the encoder output h i :
[0147] It can be understood that the bidirectional Bi-GRU can process the forward and reverse information of the input sequence at the same time and capture more comprehensive features. It improves the model's ability to understand the input sequence and provides richer feature information for subsequent predictions. The forward GRU layer processes the input sequence in sequence, captures the forward dependencies in the sequence, and enables the model to understand the temporal order relationship in the input sequence. The backward GRU layer processes the input sequence in reverse order, captures the reverse dependencies in the sequence, and enhances the model's ability to capture the reverse dependencies in the input sequence. The hidden states of the forward and backward GRU layers are concatenated to form the output of the encoder, so that the output of the encoder contains both the forward and reverse feature information of the input sequence.
[0148] (II) ECA Attention Mechanism (Encoder-Decoder Attention):
[0149] A bridge is built between the encoder and the decoder, which generates an intermediate vector C of fixed length by weighted summing of the hidden states output by the encoder:
[0150] Among them, α i is the attention weight, calculated by the encoder output h i The similarity with the current hidden state of the decoding layer is obtained.
[0151] It can be understood that the intermediate vector C is generated by weighted summing of the hidden states output by the encoder. The weights are calculated by the attention mechanism, focusing on the part most relevant to the current decoding step. This improves the accuracy and efficiency of decoding, allowing the decoder to more accurately focus on important information in the input sequence.
[0152] (3) Decoder:
[0153] It is responsible for generating energy consumption prediction values for a certain period of time in the future and forming an output sequence S'. It also uses a bidirectional Bi-GRU network, combining the intermediate vector C and the hidden state and output of the previous time step to gradually generate prediction results. The decoder can capture the time dependency in the output sequence and generate a prediction sequence of variable length to meet the energy consumption monitoring needs in different time periods.
[0154] Use bidirectional Bi-GRU as the decoder component, including:
[0155] (1) Forward GRU layer:
[0156] in, is the backward hidden state of the decoder's forward GRU layer, is the forward hidden state of the forward GRU layer of the decoder at the previous time step, y t is the output of the decoder at time step t, y t-1 is the output of the decoder at the last time step.
[0157] (2) Backward GRU layer:
[0158] in, is the backward hidden state of the backward GRU layer of the decoder, is the backward hidden state of the backward GRU layer of the decoder at the previous time step.
[0159] (3) Concatenate the forward and backward hidden states to form the decoder output s t :
[0160] (4) The decoder generates a prediction value at each time step to form an output sequence S': S' = {y t |t=1,2,…,T}; it meets the energy consumption monitoring needs in different time periods and can generate prediction sequences of variable length.
[0161] It can be understood that the forward GRU layer of the decoder combines the intermediate vector C with the hidden state and output of the previous time step to generate the forward hidden state of the current time step, so that the decoder can gradually generate prediction results and capture the temporal dependencies in the output sequence. The backward GRU layer is similar to the forward GRU layer, but the processing direction is opposite, generating the backward hidden state of the current time step. The decoder's ability to capture reverse dependencies in the output sequence is enhanced. The hidden states of the forward and backward GRU layers are concatenated to form the output of the decoder, so that the output of the decoder contains both the forward and reverse feature information of the output sequence.
[0162] Specifically, the model python architecture program of step S2 above is as follows Figure 6As shown in the figure, the principle is to use a bidirectional GRU (Bi-GRU) to process the input sequence, thereby capturing the forward and reverse dependencies of the input sequence. The output (hidden state and output) of the encoder is passed to the decoder. The decoder (Decoder) also uses a bidirectional GRU to process the sequence in the decoding process. In each decoding step, the output of the previous decoding step, the current hidden state, and the encoder output weighted by the attention mechanism are combined to generate a new decoded output. During the decoding process, the attention mechanism (Attention Mechanism) uses a linear layer to calculate the similarity (attention weight) between the encoder output and the current decoding step. These weights are used to weighted sum the encoder output to generate a context vector, which is then combined with the output of the decoder to help the decoder generate predictions more accurately.
[0163] In this embodiment, regarding step S3, decoding: the output sequence S' obtained in step S2 is formed into an energy consumption matrix A in the form of a time series to realize energy consumption monitoring of the building:
[0164] Among them, y t is the output of the decoder at the tth time step, indicating the predicted energy consumption value in a certain period of time in the future. Each row of the matrix A represents the output of a time step. t is a multidimensional vector whose dimensions correspond to the number of energy consumption indicators or areas that need to be predicted. For example, if a building has three different energy consumption indicators (such as electricity, gas, and water), then y t will be a 3-dimensional vector.
[0165] y t Each element of represents the predicted value of the corresponding energy consumption indicator or area in a certain period of time in the future. These predicted values are derived based on the features extracted by the encoder and the learning ability of the decoder. The energy consumption matrix A is arranged in time series to facilitate time series analysis. It is easier to observe the trend of energy consumption, identify abnormal energy consumption patterns, and make energy consumption predictions.
[0166] Embodiment 2: Figure 4 , 7 As shown in FIG. 8 , this embodiment discloses a training method for the Seq2Seq-Bi-GRU recurrent neural network model as described in Embodiment 1, as shown in FIG. Figure 7 As shown, including:
[0167] P1. Collect and divide the historical data set D':
[0168] According to step S1, data is collected from historical data to form a data set D', and then the preprocessed data set is divided into a training set D trainand the test set D test ;
[0169] P2. Set training parameters:
[0170] Including learning rate, batch size, number of iterations, and Adam optimizer.
[0171] P3. Training model:
[0172] Using the training set D train The model is trained and the model parameters are updated through the back propagation algorithm to minimize the mean square error (MSE) between the predicted value and the actual value, and parameter tuning and model structure adjustment are performed as needed.
[0173] P4. Model evaluation and deployment:
[0174] Repeat forward propagation, loss calculation, and back propagation, and continuously iterate the training process until the stopping condition is met (the maximum number of iterations is reached or the loss function value is less than the threshold).
[0175] in Figure 7 In the program shown, a technique called "teacher forcing" is used (e.g. Figure 8 ), which decides with certain probability whether to use the real next word (from the target sequence) or the next word predicted by the decoder as the input of the next decoding step.
[0176] Test example:
[0177] 1. Introduction
[0178] Building energy consumption prediction is of great significance for achieving energy conservation, emission reduction and sustainable development. In recent years, deep learning models, especially recurrent neural networks (RNNs) and their variants, such as gated recurrent units (GRUs), have achieved remarkable results in time series data prediction. This study proposes a Seq2Seq-Bi-GRU model and compares it with the existing Seq-GRU model to verify its advantages in building energy consumption prediction.
[0179] 2. Experimental design
[0180] Experimental group: Seq2Seq-Bi-GRU recurrent neural network model as disclosed in Example 1;
[0181] Control group: The Seq-GRU neural network model in the literature [Li Kaijia, He Jin, Cao Jiabao, et al. Research on building energy consumption prediction method based on Seq-GRU [J]. Internet of Things Technology, 2024, 14(04): 55-60.] was used.
[0182] Experimental content: Using a set of exemplary building energy consumption data curves (such as Fig. 9 As shown), the horizontal axis is the time period (days) and the vertical axis is the energy consumption level.
[0183] (III) Experimental methods:
[0184] The first 7 days of building energy consumption data were used to train the models for the experimental and control groups.
[0185] After training is complete, the model is used to predict energy consumption level data for the next 7-76 days.
[0186] Randomly extract 50 scattered points from the predicted sequence and plot them on Fig. 9 for visual comparison.
[0187] (IV) Experimental results and analysis:
[0188] The scatter points predicted by the experimental group are closer to the actual energy consumption curve, showing higher prediction accuracy.
[0189] Although the control group also uses the Seq2Seq architecture and GRU units, the prediction results have large errors because the forward and reverse dependencies of the sequence are not considered.
[0190] The Seq2Seq-Bi-GRU model can capture both the forward and reverse dependencies of the sequence by introducing a bidirectional GRU, thereby improving the accuracy of prediction. The control group model may have performance degradation in long-term sequence prediction due to gradient vanishing or gradient exploding problems. The introduction of the attention mechanism may not be fully utilized in the Seq-GRU model because the limitations of its basic architecture (RNN) affect the overall performance.
[0191] All the above embodiments only express the implementation methods of the relevant practical applications of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be based on the attached claims.
[0192] For those skilled in the art, it can be further appreciated that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0193] At the same time, those skilled in the art can understand that all or part of the processes in all the above-mentioned embodiments can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media provided in this application and used in the embodiments may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
Claims
1. An energy consumption monitoring method for green buildings based on the Internet of Things, comprising collecting a data set D of building energy consumption through an Internet of Things device, characterized in that: The steps include: S1, extract the features of the data set D that are useful for energy consumption prediction and form the input sequence S; S2, activates the Seq2Seq-Bi-GRU recurrent neural network model; uses a bidirectional Bi-GRU as a component of the encoder to receive the input sequence S; then aggregates the hidden state output by the encoding layer into a fixed-length intermediate vector C through the ECA attention mechanism and inputs it into the decoding layer; the decoding layer receives the hidden state and output from the previous time step at each time step through the forward and backward GRU layers, as well as the intermediate vector C as an additional input, and generates a variable-length output sequence S' as the energy consumption prediction value for a certain period of time in the future S3, the output sequence S' is converted into an energy consumption matrix A in the form of a time series to realize energy consumption monitoring of the building.
2. The energy consumption monitoring method according to claim 1, characterized in that: In S1, the data set D includes electricity consumption a, water consumption b, and gas consumption c, as well as external factor data corresponding to the three, including weather d and personnel flow e: D={(a i ,b i ,c i ,d i ,e i )|i=1,2,…,N}; Among them, a i represents the power consumption of the i-th sample; b i represents the water consumption of the i-th sample; c i represents the gas consumption of the i-th sample; d i represents the weather condition of the i-th sample; e i represents the personnel turnover of the i-th sample; N is the total number of samples.
3. The energy consumption monitoring method according to claim 2, characterized in that: In S1, the extraction method is the Kappa consistency check algorithm, which is: For each feature f j ∈{a,b,c,d,e,a rea } and energy consumption are discretized, and then the cross table between them is calculated to obtain the Kappa score; when the Kappa score of a feature is higher than the preset threshold θ, this feature is considered useful for energy consumption prediction, and it is selected to form the input sequence S: S=(x i ,t i ,areai)|i=1,2,…,M; Among them, x i =(ai-τ,a i-τ+1 ,…,a i-1 ), represents the historical power consumption data of the i-th input sequence; τ is the size of the sliding window; t i represents the time characteristics of the i-th input sequence; area i represents the building area of the ith input sequence; M is the total number of input sequences; y is the actual energy consumption data.
4. The energy consumption monitoring method according to claim 1, characterized in that: The architecture of the Seq2Seq-Bi-GRU recurrent neural network model includes the following sequential connections: The encoder is responsible for receiving the input sequence S. Through the bidirectional Bi-GRU network, it can extract the dependencies in the input sequence from both the forward and backward directions and encode this information into a series of hidden states. The ECA attention mechanism generates an intermediate vector C of fixed length by weighted summing of the hidden states output by the encoder; The decoder also uses a bidirectional Bi-GRU network to combine the intermediate vector C with the hidden state and output of the previous time step to gradually generate the output sequence S'.
5. The energy consumption monitoring method according to claim 4, characterized in that: The encoder comprises: Use a bidirectional Bi-GRU to receive the input sequence S: S={(x i ,t i ,area i )|i=1,2,…,M}; Forward GRU layer: Backward GRU layer: Concatenate the forward and backward hidden states to form the encoder output h i : in, is the forward hidden state of the encoder’s forward GRU layer, is the forward hidden state of the encoder’s forward GRU layer at the previous time step, is the backward hidden state of the encoder's backward GRU layer, is the backward hidden state of the backward GRU layer of the encoder at the previous time step.
6. The energy consumption monitoring method according to claim 4, characterized in that: In the ECA attention mechanism: Among them, α i is the attention weight, calculated by the encoder output h i The similarity with the current hidden state of the decoding layer is obtained.
7. The energy consumption monitoring method according to claim 4, characterized in that: The decoder comprises: Forward GRU layer: Backward GRU layer: Concatenate the forward and backward hidden states to form the decoder output s t : in, is the backward hidden state of the decoder's forward GRU layer, is the forward hidden state of the forward GRU layer of the decoder at the previous time step, y t is the output of the decoder at time step t, y t-1 is the output of the decoder at the last time step, is the backward hidden state of the backward GRU layer of the decoder, is the backward hidden state of the backward GRU layer of the decoder at the previous time step.
8. The energy consumption monitoring method according to claim 7, characterized in that: The calculation method of the output sequence S' is: S' = {y t |t=1,2,…,T}.
9. The energy consumption monitoring method according to claim 1, characterized in that: In S3, the energy consumption matrix A is: Among them, y t is the output of the decoder at the tth time step, indicating the predicted energy consumption in a certain period of time in the future; and y t It can be regarded as a multidimensional vector, representing the predicted values of different energy consumption indicators or different areas.
10. The energy consumption monitoring system based on the Internet of Things green building is characterized by: The system includes a processor and a memory connected to the processor, wherein the memory stores program instructions, and when the program instructions are executed by the processor, the processor executes the energy consumption monitoring method according to any one of claims 1 to 9, and the processor is connected to, Responsible for the collection and preprocessing module of building energy consumption data collected through IoT device data; The Seq2Seq-Bi-GRU model building module is responsible for building the Seq2Seq-Bi-GRU recurrent neural network model; The model training module is responsible for training the Seq2Seq-Bi-GRU model using the preprocessed dataset; The model evaluation and deployment module is responsible for evaluating and deploying the model.
Citation Information
Cited By
Balance control method and system for amplitude and flow of regulating valve for chemical plant
CN119310831A
