Building load prediction method and device based on multi-task tcn-transformer
By combining the advantages of TCN and Transformer through the multi-task TCN-Transformer architecture, the problem of difficulty in balancing local short-term fluctuations and long-term dependencies in existing building load forecasting is solved, achieving higher accuracy in building load forecasting and adapting to the differentiated needs of multiple building clusters.
Patent Information
- Application Number
- CN202611351987.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-02
- Publication Date
- 2026-11-20
AI Technical Summary
Existing building load forecasting methods struggle to simultaneously account for both local short-term load fluctuations and long-term dependencies between time series, resulting in insufficient forecast accuracy, especially in scenarios with multiple building clusters where adaptability is poor.
A multi-task TCN-Transformer architecture is adopted. By mining the lag characteristics of the load, and combining the multi-task TCN-Transformer collaborative architecture, load forecasting is performed. TCN is used to extract local short-term change features, Transformer obtains long-term global dependencies, and meteorological features and load-type features are fused through cross-attention to generate load forecast results for each building.
It improves the accuracy of building load forecasting, enhances the adaptability to multi-building cluster scenarios, and strengthens forecast accuracy, especially in small sample scenarios.
Smart Images

Figure CN123140346A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of building load forecasting technology based on industrial big data processing, and specifically to a building load forecasting method based on a multi-task TCN (Temporal Convolutional Network) transformer. Background Technology
[0002] Building load forecasting is the foundation for regional cooling and heating energy dispatching, pipeline supply and demand matching, and economic operation and regulation of energy systems. Accurate building load forecasting results can provide a reliable basis for energy station unit dispatching and energy storage resource allocation, thereby reducing overall energy costs. Therefore, high-precision building load forecasting technology has always been a key research direction in the field of smart energy.
[0003] The historical load time-series data collected automatically from multiple buildings in the park over a long period of time constitutes industrial big data generated by the operation of energy infrastructure, characterized by continuous time series, multi-dimensionality, and massive growth. Currently, building load forecasting typically employs time-series deep learning methods, often using a single deep learning network to mine the load time-series variation patterns in the collected data. Based on these historical load characteristics, a prediction model is trained, and the trained model is used to extrapolate the load of individual buildings or clusters of buildings.
[0004] Most existing prediction architectures use independent network modules to extract time-series features, which makes it difficult to simultaneously take into account both local short-term load fluctuations and long-term dependencies between time series. They also have limited ability to mine the coupling correlations between input features and poor adaptability to multi-building cluster scenarios with different characteristics. Ultimately, the prediction accuracy is difficult to meet the requirements of refined scheduling of energy systems. Summary of the Invention
[0005] The purpose of this invention is to provide a building load forecasting method and device based on multi-task TCN-Transformer. By mining the lag characteristics of the load and combining the multi-task TCN-Transformer collaborative architecture for load forecasting, the method solves the problem of low accuracy of existing building load forecasting results.
[0006] This invention is achieved through the following technical solution:
[0007] The first aspect of this application provides a building load forecasting method based on multi-task TCN-Transformer, including:
[0008] Acquire multidimensional data that can affect building load; the multidimensional data includes at least meteorological data of the location of each building, historical load time series data of each building, and type labels of each building;
[0009] Based on the historical load time series data, the correlation between load time series data under different candidate time steps is calculated, and the candidate time steps with a correlation higher than a preset correlation threshold are determined as the delay step corresponding to the building load.
[0010] Using the reference time as the time series segmentation node, historical load data before the reference time and matching each delay step are extracted from the historical load time series data to construct hysteresis features.
[0011] Building type labels are embedded and encoded to obtain building embedding features. The hysteresis features, historical load time series data, meteorological data and building embedding features of each building are concatenated to generate feature vectors for each building.
[0012] The feature vectors are input into a pre-trained multi-task TCN-Transformer model to obtain the building load prediction results output by the model.
[0013] The multi-task TCN-Transformer model extracts local short-term variation features from lag features, historical load time series, and meteorological time series in the time series dimension through TCN; obtains long-term global dependencies between time series data through Transformer; fuses meteorological features and load-type features based on cross-attention; the fused features are combined with building embedding features and input into the multi-task output head, and outputs the load prediction results of each building based on independent output branches adapted to each building.
[0014] In one feasible implementation, the method further includes:
[0015] Based on a preset time step, the average load value within the corresponding time period before the reference time is calculated, and the average value feature is constructed.
[0016] The mean feature is added to the feature vector.
[0017] In one feasible implementation, the method further includes a model pre-training step:
[0018] A meta-feature library for storing static metadata of buildings is pre-built; the static metadata includes at least the building function type, building area, personnel capacity, number of floors, and usage schedule information;
[0019] Based on building samples with existing historical load data from multiple buildings, the multi-task TCN-Transformer model is trained using a two-layer optimization strategy.
[0020] The two-layer optimization strategy includes: the inner layer generates the task head corresponding to the building based on the building's meta-features through the meta-generation network, and completes the single-building task adaptation by combining the building's historical load samples; the outer layer simultaneously optimizes the global loss of the TCN-Transformer backbone network and the meta-generation network based on the prediction loss of all building samples in each iteration, and completes the overall model parameter update.
[0021] In one feasible implementation, the method further includes:
[0022] For new buildings without historical load data, the static meta-features of the new buildings are input into the trained meta-generative network to generate a task head specific to the new buildings. The TCN-Transformer backbone network with frozen parameters is reused to perform zero-sample cold start prediction of the load of the new buildings.
[0023] In one feasible implementation, the extraction of local short-term variation features from lag characteristics, historical load time series, and meteorological time series in the time series dimension through TCN includes:
[0024] The time series feature obtained by splicing the lag feature, historical load time series, and meteorological time series is input into the first residual block of multiple TCN residual blocks set in a serial stack;
[0025] Within each TCN residual block, causal convolution and dilated convolution are used to perform one-dimensional convolution operations on the input temporal features, and the output of the convolution operation is used to perform residual concatenation operations with the original input features of the TCN residual block.
[0026] The output of the previous TCN residual block is used as the input of the next TCN residual block, and the output of the last TCN residual block is used as the local short-time variation feature.
[0027] In one feasible implementation, long-term global dependencies between time-series data are obtained through a Transformer; meteorological features and load-related features are fused based on cross-attention; the fused features, combined with building embedding features, are input into a multi-task output head, and load prediction results for each building are output based on independent output branches adapted to each building, including:
[0028] The local short-time change features are input into the Transformer encoder;
[0029] The temporal load features carrying long-period global dependencies are obtained by multi-head self-attention and temporal feedforward network operation based on Transformer encoder.
[0030] The time-series load characteristics and the corresponding meteorological data are input into the cross-attention module to generate fused features;
[0031] The fused features and building embedded features are concatenated and then input into the multi-task output head. The load prediction results for each building are obtained through the independent output branches corresponding to each building.
[0032] In one feasible implementation, the method further includes constructing a database system for building load forecasting;
[0033] The database system is divided into original data partitions, feature intermediate data partitions, and model prediction result partitions, and an association index is established between the partitions;
[0034] Based on the time-series access characteristics of load forecasting tasks, a tiered storage strategy is configured, using in-memory database caching for high-frequency read / write real-time time-series data and persistent disk storage for historical archive data.
[0035] A second aspect of this application provides a building load forecasting device based on a multi-task TCN-Transformer, comprising:
[0036] A multidimensional data acquisition unit is used to acquire multidimensional data that can affect building load; the multidimensional data includes at least meteorological data of the location of each building, historical load time series data of each building, and type labels of each building;
[0037] The delay step size determination unit is used to calculate the correlation between load time series data under different candidate time steps based on the historical load time series data, and determine the candidate time steps with a correlation higher than a preset correlation threshold as the delay step size corresponding to the building load.
[0038] The hysteresis feature construction unit is used to extract historical load data before the reference time and matching each delay step from the historical load time series data, using the reference time as the time series segmentation node, and construct hysteresis features.
[0039] The feature vector generation unit is used to embed and encode the building type label to obtain building embedding features, and to concatenate the lag features, historical load time series data, meteorological data and building embedding features of each building to generate the feature vector of each building.
[0040] The load prediction unit is used to input the feature vector into the pre-trained multi-task TCN-Transformer model to obtain the load prediction results of each building output by the model.
[0041] The multi-task TCN-Transformer model extracts local short-term variation features from lag features, historical load time series, and meteorological time series in the time series dimension through TCN; obtains long-term global dependencies between time series data through Transformer; fuses meteorological features and load-type features based on cross-attention; the fused features are combined with building embedding features and input into the multi-task output head, and outputs the load prediction results of each building based on independent output branches adapted to each building.
[0042] A third aspect of this application provides an electronic device, including: a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the steps of the above-described method.
[0043] A fourth aspect of this application provides a storage medium, comprising: storing a program or instructions on the storage medium, wherein the program or instructions, when executed by a processor, implement the steps of the above-described method.
[0044] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0045] This embodiment constructs lag features adapted to each building by mining the temporal correlation of historical loads. Since the lag features are determined through correlation analysis of historical load data, the model can focus on historical loads with high correlation to the reference time by extracting load features with high correlation to the historical load data through correlation analysis, thereby improving the prediction accuracy. This embodiment further adopts a multi-task TCN-Transformer collaborative architecture to capture the local short-term variation law of load time series and the long-term global dependence of time series data respectively. It uses cross attention to achieve the fusion of meteorological features and load-type features, and introduces building embedded features to represent the inherent attributes of different buildings. It fully explores the coupling relationship between multi-source features, improves the adaptability of the scheme to differentiated building cluster scenarios, and further improves the load prediction accuracy. Attached Figure Description
[0046] To more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly described below. It should be understood that the following drawings only show some embodiments of the present invention and should not be considered as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort. In the drawings:
[0047] Figure 1 A flowchart illustrating a building load forecasting method based on multi-task TCN-Transformer provided in this application embodiment;
[0048] Figure 2 A schematic diagram of the framework for multi-task learning provided in an embodiment of this application;
[0049] Figure 3 A schematic diagram of the causal convolutional structure of the TCN network in the prediction method provided in the embodiments of this application;
[0050] Figure 4 A schematic diagram of the dilated convolutional structure of the TCN network in the prediction method provided in the embodiments of this application;
[0051] Figure 5 A schematic diagram of the structure of the residual module of the TCN network in the prediction method provided in the embodiments of this application;
[0052] Figure 6 This is a schematic diagram of the transformer structure in the prediction method provided in the embodiments of this application;
[0053] Figure 7 A comparison chart of prediction results using the method of this embodiment and a conventional method is provided as an example of an embodiment of this application.
[0054] Figure 8 A schematic diagram of a building load prediction device based on a multi-task TCN-Transformer provided in this application embodiment;
[0055] Figure 9 This is a schematic diagram of the structure of a computing device provided in an embodiment of this application. Detailed Implementation
[0056] To make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the embodiments and accompanying drawings. The illustrative embodiments and descriptions of the present invention are only used to explain the present invention and are not intended to limit the present invention.
[0057] As will be known to those skilled in the art, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.
[0058] The terms “comprising” and “having”, and any variations thereof, in the specification, claims, and accompanying drawings of this application are intended to cover non-exclusive inclusion, so that a process, method, system, product, or apparatus that comprises a series of elements is not necessarily limited to those elements, but may include other elements not expressly listed or inherent to such process, method, product, or apparatus.
[0059] Example 1:
[0060] Embodiment 1 of this application provides a building load forecasting method based on multi-task TCN-Transformer to solve the problem of low accuracy of existing building load forecasting results.
[0061] The subject executing this method can be any computing device capable of implementing the method, such as a server, mobile phone, personal computer, smart wearable device, smart robot, etc.
[0062] Furthermore, the embodiments of this application do not limit the execution order of different steps. When using the method provided in the embodiments of this application, the execution order of different steps can be adjusted according to actual needs.
[0063] For ease of description, the following uses a building load forecasting device based on a multi-task TCN-Transformer as the execution subject of this method to provide a detailed description of the method provided in this application embodiment.
[0064] like Figure 1 The diagram shown is a flowchart illustrating a specific implementation of a building load forecasting method based on a multi-task TCN-Transformer according to an embodiment of this application, including the following steps 11-15:
[0065] Step 11: Obtain multidimensional data that can affect building load.
[0066] The multidimensional data includes at least the meteorological data of each building's location, the historical load time series data of each building, and the type label of each building.
[0067] Meteorological data includes meteorological data such as temperature, humidity, wind speed, and solar radiation.
[0068] Historical load time-series data reflects the building's historical load at different times. It should be noted that the historical load time-series data used in this embodiment is energy-related industrial big data continuously collected by metering instruments in various buildings within the park. The data is continuously and incrementally collected as the system operates. This solution uses feature construction and time-series modeling of this type of industrial big data to achieve accurate prediction of building heating and cooling loads.
[0069] The type in this embodiment can be the functional type of the building, such as an office building or a dormitory building.
[0070] In addition, multidimensional data can also include calendar features, such as holidays, weekends / weekdays, etc.
[0071] For the acquired multidimensional data, perform the following big data processing steps:
[0072] Z-score normalization is used to ensure that feature data of different dimensions are mapped to the same scale. The specific formula for normalization is:
[0073] ;
[0074] In the formula, The original data, The mean, The standard deviation is denoted as .
[0075] Adopt 3 The criteria identify and remove outlier data; data is considered outlier if it meets the following formula:
[0076] .
[0077] The K-nearest neighbor algorithm is used to complete the data by analyzing the samples. In the feature space, find the K most similar neighbor samples and use the inverse of the distance between the samples as the weight to calculate the filling value of the missing position.
[0078] ;
[0079] in, Let be the value of the i-th neighbor. Similarity weight (usually taken as...) (That is, the reciprocal of the neighbor distance). This method can make full use of the local similarity of the data and maintain the smoothness of the time series.
[0080] The moving average method is used to smooth the data, specifically by using the average value of data over a recent period as the forecast or smoothed value for the current period, thereby eliminating short-term random fluctuations.
[0081] ;
[0082] in, Let be the moving average for period t. t represents the actual value in period t, and n is the number of periods in the moving average, i.e., the window size (default is 3).
[0083] Step 12: Based on the historical load time series data, calculate the correlation between load time series data at different candidate time steps, and determine the candidate time steps with a correlation higher than a preset correlation threshold as the delay step corresponding to the building load.
[0084] Based on the load data sampling period, a set of candidate time steps is preset as the lag order to be screened, forming a candidate set. For example, if the load data is sampled hourly, the candidate step size can be selected as 1, 2, 3...24, 48, 72 (hours), etc., covering the intraday and interday cycle range.
[0085] For each candidate step size, construct two sets of time series sequences. For example, take the current candidate compensation τ, and split the original historical load data into: sequence A formed by removing the last τ data points from the original load time series and sequence B formed by removing the first τ data points from the original load time series; the lengths of the two sequences are kept the same, and sequence B is equivalent to sequence A shifted to the right by τ time points.
[0086] The correlation coefficient is used to calculate the correlation between sequence A and sequence B, and the correlation measure corresponding to the candidate time step τ is obtained.
[0087] The calculated correlation value is compared with a preset correlation threshold. If the correlation value is greater than the preset correlation threshold, the candidate time step is retained as the available delay step for the building. If the correlation value is less than or equal to the threshold, the candidate time step is discarded. The retained candidate time steps are written into the delay step set.
[0088] Step 13: Using the reference time as the time series segmentation node, extract the historical load data before the reference time and match each delay step from the historical load time series data to construct the lag feature.
[0089] The reference time is the starting reference time for load forecasting and also a time-series dividing point. Using this time as the boundary, the input features are constructed using historical data that has been collected and is available before the reference time, without introducing future data after the reference time. The subsequent forecasts are for the building load at one or more times after the reference time.
[0090] Using the reference time as the dividing node, complete and usable historical load time-series data prior to the reference time is extracted. For each delay step within the delay step set, the historical load value corresponding to the sampling time shifted forward by that delay step from the reference time is located. The load data extracted from each delay step are arranged and combined in order of delay step size to form the hysteresis feature corresponding to that sample.
[0091] Taking delay step sizes of 1, 2, 4, 8, and 96 as examples, the hysteresis characteristic at the reference time t can be expressed as:
[0092] ;
[0093] In the formula, This represents the load value at time t. This is the lag step size, taken as 1, 2, 4, 8, and 96 time intervals respectively. When t < When this occurs, the feature value is a missing value.
[0094] The data of historical time steps with high correlation is used as the feature of the current time step. This method can help the subsequent prediction model capture the historical dependencies in the time series, facilitate the model to better mine the load evolution law, and ultimately improve the accuracy of load prediction.
[0095] Step 14: Perform embedding encoding on the building type label to obtain a building embedding feature, and concatenate the lag feature, historical load time series data, meteorological data and building embedding feature of each building to generate a feature vector for each building.
[0096] In a feasible implementation, this step further includes: calculating the average load value in the corresponding period before the reference time point based on a preset time step to construct an average feature; concatenating the average feature, lag feature, historical load time series data, meteorological data and building embedding feature of each building to generate a feature vector.
[0097] In this implementation, the average value can be calculated through a rolling window. By calculating the average value of data of several previous time steps at a certain moment, short-term fluctuations can be smoothed, which helps the model capture long-term change trends and smooth short-term fluctuations.
[0098] The preset time step may be each delay step determined in the above step 12.
[0099] For example, if the delay steps are 4, 16, and 96 respectively, then for a given window size , the rolling window average feature value at time point t is:
[0100] ;
[0101] Where w is the size of the rolling window, the summation range is from t-w to t-1 (excluding the current time point t), and the feature value is a missing value when t<w.
[0102] Combine the lag feature and the average feature into a vector :
[0103] ;
[0104] The vector is concatenated with the historical load series and meteorological data to form a complete input feature :
[0105] ;
[0106] Where H is the length of the historical series, represents the vector concatenation operation.
[0107] Each building is labeled with a category and input into the model via embedding. Each building is given a label (e.g., office building or dormitory building) and these labels are transformed into a set of continuous, low-dimensional numerical vectors. The type characteristics of the buildings are represented numerically, enabling the model to utilize the vector features of the buildings and achieve shared learning while taking into account the differences between different buildings.
[0108] Step 15: Input the feature vector into the pre-trained multi-task TCN-Transformer model to obtain the building load prediction results output by the model.
[0109] The multi-task TCN-Transformer model extracts local short-term variation features from lag features, historical load time series, and meteorological time series in the time series dimension through TCN; obtains long-term global dependencies between time series data through Transformer; fuses meteorological features and load-type features based on cross-attention; the fused features are combined with building embedding features and input into the multi-task output head, and output the load prediction results of each building based on independent output branches adapted to each building.
[0110] The multi-task TCN-Transformer model is an MTL (Multi-Task Learning)-TCN-Transformer architecture. This architecture is a hybrid prediction architecture integrating multi-task learning and a temporal dual-backbone system, consisting of a feature extraction backbone network and multi-task output branches. The TCN is responsible for shallow temporal modeling, capturing local short-term fluctuations in load and meteorological time series based on causal dilated convolutions and temporal residual structures. The Transformer encoder is responsible for deep temporal modeling, mining global temporal dependencies across time spans and distances through a multi-head self-attention mechanism. The architecture introduces a multi-task learning mechanism, sharing the TCN-Transformer backbone network parameters to uniformly learn the general energy consumption time series patterns of multiple buildings. Simultaneously, it configures independent task output branches for each building, fitting the personalized load variation characteristics of different buildings, thus adapting to the refined load prediction needs in multi-building cluster scenarios.
[0111] Multi-task learning (MTL) is a machine learning paradigm that improves overall prediction performance by simultaneously modeling multiple related tasks. For example... Figure 2As shown, MTL leverages the inherent connections between different tasks to extract global feature representations in a shared layer and characterize differentiated patterns in task-specific layers. For building load forecasting, while office buildings and dormitories differ in their energy consumption patterns, they also exhibit certain commonalities due to external factors such as weather conditions and temporal characteristics. Introducing the MTL framework enables cross-building knowledge sharing, alleviating the modeling difficulties caused by insufficient data for a single building and significantly improving prediction accuracy in small-sample scenarios. In multi-task learning, the overall optimization objective function can be expressed as: ;
[0112] In the formula, K represents the number of buildings. This represents the predicted loss for the k-th building. This is a weighting coefficient that can be dynamically adjusted based on the building's size or importance.
[0113] Temporal Convolutional Networks (TCNs) are convolutional neural network structures used to process time series data. They capture local short-term variation features in the sequence through dilated convolution and residual connections.
[0114] TCN also introduces causal convolution to ensure that the prediction result at each time step depends on past time steps, thus improving the model's stability. For example... Figure 3 As shown, for a given time series TCN outputs prediction results of the same length. Among them, the predicted value It depends only on the input values before the current moment, and has nothing to do with the input values at future moments.
[0115] In TCNs, convolutional layers expand the receptive field through dilated convolutions, enabling the network to capture dependencies over longer time scales with fewer layers. For example... Figure 4 As shown, dilated convolution is implemented by inserting holes between the convolution kernels, which effectively increases the receptive field while keeping the computational cost relatively small. The operation of dilated convolution can be represented as:
[0116] ;
[0117] Where k represents the kernel size and d is the dilation factor. denoted as the convolution kernel weights, and x as the input sequence.
[0118] The residual block module in TCN consists of multiple stacked residual blocks. Each residual block contains two layers of dilated convolutions and nonlinear activations. Its output is added to the input through residual connections to avoid the vanishing gradient problem in deep networks. The computation process of the residual block is as follows:
[0119] ;
[0120] in, This represents convolution and nonlinear transformation in the residual block. The original input features of the residual block are represented. The output of the residual mapping branch represents the features obtained after the input x has undergone a series of convolutions and nonlinear transformations, such as two layers of dilated convolution and nonlinear activation, inside the residual block.
[0121] In training deep networks, residual connections can pass information across layers, thereby improving training speed and avoiding the vanishing gradient problem. For example... Figure 5 As shown, the residual connection model of TCN also includes two layers of convolution and a nonlinear identity mapping. In addition, the residual connection module introduces the rectified linear function (ReLU) as the activation function, introduces weight normalization to achieve regularization, and introduces spatial loss to normalize all channels in each training iteration.
[0122] By using TCN to extract local short-term variation features in the time series dimension from lag characteristics, historical load time series, and meteorological time series, including:
[0123] The time series features obtained by concatenating lag features, historical load time series, and meteorological time series are input into the first residual block of multiple TCN residual blocks that are stacked in a serial manner. Within each TCN residual block, causal convolution and dilated convolution are used to perform one-dimensional convolution operations on the input time series features. The output of the convolution operation is then used to perform residual concatenation operations with the original input features of the TCN residual block. The output of the previous TCN residual block is used as the input of the next TCN residual block, and the output of the last TCN residual block is used as the local short-term variation feature.
[0124] Transformer encoders are used to capture global dependencies between different time steps in a sequence. For example... Figure 6 As shown, the Transformer encoder includes a self-attention mechanism, a feed-forward network, layer normalization, and residual connections.
[0125] The self-attention mechanism achieves global integration of sequence information by calculating the attention weights of each time step with all other time steps. Specifically, for the input sequence X, a query, key, and value matrix is first obtained through a linear transformation:
[0126] ;
[0127] in, , , Given a learnable weight matrix, the self-attention output is then computed:
[0128] ;
[0129] in, Let be the dimension of the key vector. Used to scale the dot product result and prevent gradient vanishing.
[0130] To capture the feature representations of different subspaces, we extend self-attention to a multi-head form:
[0131] ;
[0132] Among them, each attention head h represents the number of attention heads.
[0133] The features at each time step are nonlinearly transformed through a two-layer feedforward neural network:
[0134] ;
[0135] Apply residual connections and layer normalization around each sublayer (self-attention and feedforward network):
[0136] ;
[0137] This design helps alleviate the vanishing gradient problem, making the training of deep networks more stable.
[0138] In this model, the output of the TCN is used as the input to the Transformer encoder, and multiple Transformer encoding layers are used to further extract global features of the sequence. This hybrid architecture of TCN+Transformer combines the advantages of local feature extraction and global dependency modeling, significantly improving the model's ability to capture complex time series patterns.
[0139] To deeply integrate feature information from different sources, this embodiment designs a multi-head cross-attention mechanism specifically for interactive modeling of meteorological features and historical load features. This mechanism can dynamically adjust the degree of attention given to historical load information based on real-time meteorological conditions, achieving adaptive fusion of multi-source information.
[0140] The cross-attention mechanism uses meteorological features as the query and historical load features as the key and value, thereby extracting relevant patterns from historical load information. The specific calculation process is as follows:
[0141] Let the meteorological characteristics be The historical characteristics of the load are First, the query, key, and value are obtained through linear transformation:
[0142] ;
[0143] in, It is a learnable projection matrix.
[0144] Then calculate the cross-attention output:
[0145] ;
[0146] To capture different types of weather-load interaction patterns, cross-attention is extended to multi-head forms:
[0147] ;
[0148] Among them, each head h is the number of attention heads. This is for outputting the projection matrix.
[0149] To ensure training stability and preserve original information, residual connections and layer normalization are introduced in the cross-attention module:
[0150] .
[0151] This design allows the model to incorporate guiding information from meteorological conditions while preserving the original characteristics of the load history. Through a multi-head cross-attention mechanism, the model can adaptively fuse meteorological factors with load history, significantly improving the adaptability of load forecasting to complex environmental changes and its forecasting accuracy.
[0152] The Transformer is used to obtain long-term global dependencies between time-series data; meteorological features and load-related features are fused based on cross-attention; the fused features, combined with building embedding features, are input into a multi-task output head, and load prediction results for each building are output based on independent output branches adapted to each building, including:
[0153] The local short-term variation features are input into the Transformer encoder; the time-series load features carrying long-period global dependencies are obtained by multi-head self-attention and temporal feedforward network operation based on the Transformer encoder; the time-series load features and the relevant features corresponding to the meteorological data are input into the cross-attention module to generate fused features; the fused features and building embedding features are concatenated and input into the multi-task output head, and the load prediction results of each building are obtained through the independent output branches corresponding to each building.
[0154] In one feasible implementation, this embodiment also includes a model pre-training step:
[0155] A meta-feature library storing static metadata of buildings is pre-constructed; the static metadata includes at least the building function type, building area, personnel capacity, number of floors, and usage schedule information; based on building samples with existing historical load data of multiple buildings, the multi-task TCN-Transformer model is trained using a two-layer optimization strategy; the two-layer optimization strategy includes: the inner layer generates the corresponding task head for the building based on the building meta-features through the meta-generation network, and completes single-building task adaptation by combining the building's historical load samples; the outer layer, in each iteration, simultaneously optimizes the global loss of the TCN-Transformer backbone network and the meta-generation network based on the prediction loss of all building samples, and completes the overall model parameter update.
[0156] In this embodiment, the meta-generative network is a dedicated sub-network designed for multi-task learning. Its input is the static meta-features of the building (static metadata of the building in the meta-feature library), and its output is the task head network parameters adapted to the independent prediction task of the building. It is used to generate personalized task heads through the inherent static attributes of the building, replacing the manual design and initialization of task branches for each building, realizing the adaptive generation of parameters for different building task branches, adapting to the differentiated energy consumption characteristics of buildings, and supporting model training under the two-layer optimization framework.
[0157] During pre-training, the multi-task TCN-Transformer backbone network and meta-generator network are initialized; the backbone network is responsible for general temporal feature extraction; the meta-generator network receives the encoded building meta-feature vector (generated based on the building static meta-features) and outputs the complete set of network parameters for the corresponding building task head; each building is matched with a set of exclusive task heads generated by the meta-generator network.
[0158] In the inner optimization, for any building with complete historical load samples, the encoded meta-feature vector of the building is retrieved and input into the meta-generator network to generate the building-specific task header parameters; the temporal input features of the building are sent into the TCN-Transformer backbone network to extract shared temporal features, and the shared features are sent into the generated-specific task header. Combined with the historical load ground value of the building, the single-building prediction loss is calculated to complete the local adaptation optimization of the task branch of the building.
[0159] In the outer layer optimization, each iteration traverses all building samples, summarizes the prediction loss generated by the adaptation of all building single tasks, and constructs a global joint loss. Based on the global joint loss, backpropagation is performed synchronously to update all parameters of the TCN-Transformer backbone network and the parameters of the meta-generator network. The backbone network learns the common temporal patterns of multiple buildings, and the meta-generator network continuously optimizes the mapping relationship between building meta-features and task head parameters.
[0160] The process involves a two-layer iterative process of adapting the inner single-building task and updating the outer global parameters, which continues until the global loss meets the convergence condition or reaches the preset number of iterations, thus completing the overall training of the multi-task TCN-Transformer model.
[0161] In one specific implementation, this embodiment also includes load prediction for new buildings without historical load data. Specifically, it includes: for new buildings without historical load data, inputting the static meta-features of the new buildings into the trained meta-generator network to generate a task head specific to the new buildings, reusing the TCN-Transformer backbone network with frozen parameters, and performing zero-sample cold start prediction of the load of the new buildings.
[0162] The cold start load forecast for new buildings can specifically include:
[0163] Collect static metadata (building function type, building area, personnel capacity, number of floors, and usage schedule information) of newly added buildings without historical load data and add it to the meta-feature library; perform the same encoding process as in the training phase on this set of static metadata and convert it into structured meta-feature vectors;
[0164] The encoded new building meta-feature vector is input into the trained meta-generator network, and the meta-generator network outputs a complete network parameter of a dedicated task head adapted to the energy consumption characteristics of the building, which is then instantiated to obtain an independent prediction task branch for the new building.
[0165] Collect meteorological characteristics corresponding to the forecast period; retrieve reference buildings of the same type in the park with complete historical loads, and construct a baseline time series representation based on the historical time series patterns of the reference buildings; combine the static meta-features of newly added buildings to make scaling corrections, and form the input feature vector required by the model.
[0166] The general feature vector is fed into the TCN-Transformer backbone network with frozen parameters that are no longer updated. The backbone network reuses the multi-building general temporal feature extraction capability learned during training and outputs shared temporal features.
[0167] The shared time-series features output from the backbone network are fed into the generated task header for newly added buildings. This task header performs the mapping calculation and outputs the load forecast value for the corresponding time period of the newly added building, thus achieving zero-sample cold start prediction.
[0168] To verify the technical effect achieved by the prediction method proposed in this embodiment, a specific example is provided below.
[0169] By comparing the load prediction results of the existing multi-task LSTM (Long Short-Term Memory) model with the load prediction results of the multi-task TCN-Transformer model in this embodiment, historical load data, meteorological data, and other multi-dimensional data of the same teaching building were selected. The feature vectors generated based on the multi-dimensional data were input into the multi-task LSTM model and the multi-task TCN-Transformer model, respectively. The prediction results are shown in Table 1 below. Compared with the prediction performance of the multi-task LSTM, the multi-task TCN model improves the average prediction accuracy by about 6%; the mean absolute percentage error (MAPE) is controlled at around 5%. The fact that the value of 0.991 is greater than that of 0.935 for the multi-task LSTM indicates that the multi-task TCN model has a better fit, almost perfectly capturing the patterns and regularities in the data, and has higher prediction accuracy.
[0170] Table 1. Comparison of prediction performance of different models for a certain teaching building:
[0171]
[0172] like Figure 7 As shown, the prediction results of different models are illustrated. It can be seen that the prediction results obtained by the multi-task TCN-Transformer model in this embodiment are closer to the actual load.
[0173] In one feasible implementation, this embodiment also includes constructing a database system for building load forecasting;
[0174] The database system is a layered operating system, including a data acquisition layer, a data storage layer, and a data application layer.
[0175] The data acquisition layer utilizes field equipment such as electromagnetic flowmeters, temperature / pressure sensors, and electric regulating valves to collect pipeline operation data at a high-frequency sampling period of 5 minutes. This sampling frequency is significantly higher than the 15-minute resolution required for prediction, ensuring data redundancy and traceability.
[0176] The data storage layer uses a MySQL database as the core storage platform and is divided into original data partitions, feature intermediate data partitions, and model prediction result partitions, and an association index is established between the partitions.
[0177] The raw data partition is used to store the original time-series data collected from the source, including original historical load data, original meteorological monitoring data, and building static metadata. The data retains the original collection format and collection timestamp, and is not modified except for feature transformation and cleaning. This partition serves as the data source for the entire process and is used for subsequent data preprocessing and feature engineering.
[0178] The intermediate feature data partition is used to store intermediate data generated by preprocessing and feature engineering, including normalized time series data after missing completion, filtered delay step size parameters, constructed lag feature vectors, encoded building meta feature vectors, and other intermediate feature data of the model input. This partition receives the output of the original partition and is used for model training and prediction.
[0179] The model prediction results partition is used to store the output data of the multi-task TCN-Transformer model, including model training logs, the weight index of the trained model, the predicted values of each building load, the prediction error evaluation index, the zero-sample cold start prediction results, and other model output data.
[0180] Storage isolation mechanisms can be set for the three partitions, and differentiated read and write strategies can be configured: the original data partition is configured with read-only protection to prevent the source data from being tampered with; the feature intermediate data partition supports read and write, and is used to write feature engineering outputs for the model to read; the model prediction result partition is configured with append write and query permissions, and historical prediction results are only appended to the storage and are not overwritten arbitrarily to ensure the traceability of prediction data.
[0181] The construction of a range-based index can be achieved by defining a unified primary key as the cross-partition join field. This primary key can be in the form of building number + time batch identifier. Specifically:
[0182] Each original record within the original data partition is bound to a building number and a data collection batch. When storing the intermediate feature data partition, the corresponding original data batch index and building number are written to establish a mapping relationship with the original data partition. When storing the prediction data in the model prediction result partition, the corresponding feature batch index and building number are written to establish a mapping relationship with the intermediate feature data partition.
[0183] In addition, the database system in this embodiment can also: configure a hierarchical storage strategy based on the time-series access characteristics of the load forecasting task, use a memory database cache for high-frequency read and write real-time time-series data, and use persistent disk storage for historical archived data to improve data read and write efficiency.
[0184] Example 2:
[0185] To address the problem of low accuracy in existing building load forecasting results, and based on the same inventive concept as Embodiment 1, this application also provides a building load forecasting device based on a multi-task TCN-Transformer.
[0186] A schematic diagram of the specific structure of the device is shown below. Figure 8 As shown, it includes the following functional units:
[0187] The multidimensional data acquisition unit 81 is used to acquire multidimensional data that can affect building load; the multidimensional data includes at least meteorological data of the location of each building, historical load time series data of each building, and type labels of each building;
[0188] The delay step determination unit 82 is used to calculate the correlation between load time series data under different candidate time steps based on the historical load time series data, and determine the candidate time steps with a correlation higher than a preset correlation threshold as the delay step corresponding to the building load.
[0189] The hysteresis feature construction unit 83 is used to extract historical load data before the reference time and matching each delay step from the historical load time series data, using the reference time as the time series segmentation node, and construct hysteresis features.
[0190] The feature vector generation unit 84 is used to embed and encode the building type label to obtain building embedding features, and to concatenate the lag features, historical load time series data, meteorological data and building embedding features of each building to generate the feature vector of each building.
[0191] The load prediction unit 85 is used to input the feature vector into the pre-trained multi-task TCN-Transformer model to obtain the load prediction results of each building output by the model.
[0192] The multi-task TCN-Transformer model extracts local short-term variation features from lag features, historical load time series, and meteorological time series in the time series dimension through TCN; obtains long-term global dependencies between time series data through Transformer; fuses meteorological features and load-type features based on cross-attention; the fused features are combined with building embedding features and input into the multi-task output head, and outputs the load prediction results of each building based on independent output branches adapted to each building.
[0193] The feature vector generation unit is also used to: calculate the average load value within the corresponding time period before the reference time based on a preset time step, construct the average value feature, and add the average value feature to the feature vector.
[0194] The prediction device in this embodiment further includes a model pre-training unit, specifically used for:
[0195] A meta-feature library storing static metadata of buildings is pre-constructed; the static metadata includes at least the building function type, building area, personnel capacity, number of floors, and usage schedule information; based on building samples with existing historical load data of multiple buildings, the multi-task TCN-Transformer model is trained using a two-layer optimization strategy; the two-layer optimization strategy includes: the inner layer generates the corresponding task head for the building based on the building meta-features through the meta-generation network, and completes single-building task adaptation by combining the building's historical load samples; the outer layer, in each iteration, simultaneously optimizes the global loss of the TCN-Transformer backbone network and the meta-generation network based on the prediction loss of all building samples, and completes the overall model parameter update.
[0196] The load forecasting unit is also used for:
[0197] For new buildings without historical load data, the static meta-features of the new buildings are input into the trained meta-generative network to generate a task head specific to the new buildings. The TCN-Transformer backbone network with frozen parameters is reused to perform zero-sample cold start prediction of the load of the new buildings.
[0198] The load forecasting unit is specifically used for:
[0199] The time series features obtained by concatenating lag features, historical load time series, and meteorological time series are input into the first residual block of multiple TCN residual blocks that are stacked in a serial manner. Within each TCN residual block, causal convolution and dilated convolution are used to perform one-dimensional convolution operations on the input time series features. The output of the convolution operation is then used to perform residual concatenation operations with the original input features of the TCN residual block. The output of the previous TCN residual block is used as the input of the next TCN residual block, and the output of the last TCN residual block is used as the local short-term variation feature.
[0200] The load forecasting unit is also used for:
[0201] The local short-term variation features are input into the Transformer encoder; the time-series load features carrying long-period global dependencies are obtained by multi-head self-attention and temporal feedforward network operation based on the Transformer encoder; the time-series load features and the relevant features corresponding to the meteorological data are input into the cross-attention module to generate fused features; the fused features and building embedding features are concatenated and input into the multi-task output head, and the load prediction results of each building are obtained through the independent output branches corresponding to each building.
[0202] The prediction device database system of this embodiment divides the database system into original data partitions, feature intermediate data partitions, and model prediction result partitions, and establishes an association index between the partitions; it configures a hierarchical storage strategy based on the time-series access characteristics of the load prediction task, uses memory database caching for high-frequency read and write real-time time-series data, and uses persistent disk storage for historical archived data.
[0203] This embodiment constructs lag features adapted to each building by mining the temporal correlation of historical loads. Since the lag features are determined through correlation analysis of historical load data, the model can focus on historical loads with high correlation to the reference time by extracting load features with high correlation to the historical load data through correlation analysis, thereby improving the prediction accuracy. This embodiment further adopts a multi-task TCN-Transformer collaborative architecture to capture the local short-term variation law of load time series and the long-term global dependence of time series data respectively. It uses cross attention to achieve the fusion of meteorological features and load-type features, and introduces building embedded features to represent the inherent attributes of different buildings. It fully explores the coupling relationship between multi-source features, improves the adaptability of the scheme to differentiated building cluster scenarios, and further improves the load prediction accuracy.
[0204] Based on the same inventive concept as the foregoing embodiments of this application, this application also provides a computing device.
[0205] like Figure 9 As shown, the computing device includes a memory 91 and a processor 92. The memory 91 can be configured to store various other data to support operation on the electronic device. Examples of this data include instructions for any application or method used to operate on the electronic device. The memory 91 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0206] The processor 92, coupled to the memory 91, is used to execute the computer program stored in the memory 91 to perform a building load forecasting method based on a multi-task TCN-Transformer as described in the foregoing embodiments.
[0207] When processor 92 executes the computer program to perform a building load forecasting method based on multi-task TCN-Transformer, it constructs lag features adapted to each building by mining the correlation of historical load time series. Since the lag features are determined by correlation analysis of historical load data, the load features highly correlated with the reference time are extracted from the historical load data through correlation analysis as input to the model, enabling the model to focus on historical loads with high correlation and improve forecast accuracy. This embodiment further adopts a multi-task TCN-Transformer collaborative architecture to capture the local short-term variation law of load time series and the long-term global dependence of time series data respectively. It uses cross attention to achieve the fusion of meteorological features and load-type features, and introduces building embedded features to represent the inherent attributes of different buildings, fully mining the coupling relationship between multi-source features, improving the adaptability of the scheme to differentiated building cluster scenarios, and further improving the load forecasting accuracy.
[0208] When the processor 92 executes the computer program in the memory 91, in addition to the functions described above, it can also perform other functions, as detailed in the descriptions of the preceding embodiments.
[0209] Furthermore, such as Figure 9 As shown, the computing device also includes other components such as a display 94, a communication component 93, a power supply component 95, and an audio component 96. Figure 9 The diagram only shows some components and does not mean that the computing device includes only these components. Figure 9 The components shown.
[0210] Accordingly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a computer, can implement the methods provided in the above embodiments.
[0211] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0212] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0213] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A building load forecasting method based on multi-task TCN-Transformer, characterized in that, include: Acquire multidimensional data that can affect building load; The multidimensional data includes at least the meteorological data of the location of each building, the historical load time series data of each building, and the type label of each building; Based on the historical load time series data, the correlation between load time series data under different candidate time steps is calculated, and the candidate time steps with a correlation higher than a preset correlation threshold are determined as the delay step corresponding to the building load. Using the reference time as the time series segmentation node, historical load data before the reference time and matching each delay step are extracted from the historical load time series data to construct hysteresis features. Building type labels are embedded and encoded to obtain building embedding features. The hysteresis features, historical load time series data, meteorological data and building embedding features of each building are concatenated to generate feature vectors for each building. The feature vectors are input into a pre-trained multi-task TCN-Transformer model to obtain the building load prediction results output by the model. The multi-task TCN-Transformer model: extracts local short-term variation features of lag characteristics, historical load time series, and meteorological time series in the time series dimension through TCN; and obtains long-term global dependencies between time series data through Transformer. The system integrates meteorological features and load features based on cross-attention; the fused features are combined with building embedding features and input into a multi-task output head; and load prediction results for each building are output based on independent output branches adapted to each building.
2. The method according to claim 1, characterized in that, The method further includes: Based on a preset time step, the average load value within the corresponding time period before the reference time is calculated, and the average value feature is constructed. The mean feature is added to the feature vector.
3. The method according to claim 1, characterized in that, The method also includes a model pre-training step: A meta-feature library for storing static metadata of buildings is pre-built; the static metadata includes at least the building function type, building area, personnel capacity, number of floors, and usage schedule information; Based on building samples with existing historical load data from multiple buildings, the multi-task TCN-Transformer model is trained using a two-layer optimization strategy. The two-layer optimization strategy includes: the inner layer generates the task head corresponding to the building based on the building's meta-features through a meta-generation network, and completes the single building task adaptation by combining the building's historical load samples. In each iteration, the outer layer simultaneously optimizes the global loss of the TCN-Transformer backbone network and the meta-generator network based on the prediction loss of all building samples, thus completing the overall model parameter update.
4. The method according to claim 3, characterized in that, The method further includes: For new buildings without historical load data, the static meta-features of the new buildings are input into the trained meta-generative network to generate a task head specific to the new buildings. The TCN-Transformer backbone network with frozen parameters is reused to perform zero-sample cold start prediction of the load of the new buildings.
5. The method according to claim 1, characterized in that, The extraction of local short-term variation features in the time series dimension from lag characteristics, historical load time series, and meteorological time series using TCN includes: The time series feature obtained by splicing the lag feature, historical load time series, and meteorological time series is input into the first residual block of multiple TCN residual blocks set in a serial stack; Within each TCN residual block, causal convolution and dilated convolution are used to perform one-dimensional convolution operations on the input temporal features, and the output of the convolution operation is used to perform residual concatenation operations with the original input features of the TCN residual block. The output of the previous TCN residual block is used as the input of the next TCN residual block, and the output of the last TCN residual block is used as the local short-time variation feature.
6. The method according to claim 1, characterized in that, Use Transformer to obtain long-term global dependencies between time-series data; Based on cross-attention fusion of meteorological features and load-type features; The fused features, combined with building embedding features, are input into the multi-task output head. Based on independent output branches adapted to each building, the load prediction results for each building are output, including: The local short-time change features are input into the Transformer encoder; The temporal load features carrying long-period global dependencies are obtained by multi-head self-attention and temporal feedforward network operation based on Transformer encoder. The time-series load characteristics and the corresponding meteorological data are input into the cross-attention module to generate fused features; The fused features and building embedded features are concatenated and then input into the multi-task output head. The load prediction results for each building are obtained through the independent output branches corresponding to each building.
7. The method according to claim 1, characterized in that, The method also includes constructing a database system for building load forecasting; The database system is divided into original data partitions, feature intermediate data partitions, and model prediction result partitions, and an association index is established between the partitions; Based on the time-series access characteristics of load forecasting tasks, a tiered storage strategy is configured, using in-memory database caching for high-frequency read / write real-time time-series data and persistent disk storage for historical archive data.
8. A building load forecasting device based on multi-task TCN-Transformer, characterized in that, include: A multidimensional data acquisition unit is used to acquire multidimensional data that can affect building load. The multidimensional data includes at least the meteorological data of the location of each building, the historical load time series data of each building, and the type label of each building; The delay step size determination unit is used to calculate the correlation between load time series data under different candidate time steps based on the historical load time series data, and determine the candidate time steps with a correlation higher than a preset correlation threshold as the delay step size corresponding to the building load. The hysteresis feature construction unit is used to extract historical load data before the reference time and matching each delay step from the historical load time series data, using the reference time as the time series segmentation node, and construct hysteresis features. The feature vector generation unit is used to embed and encode the building type label to obtain building embedding features, and to concatenate the lag features, historical load time series data, meteorological data and building embedding features of each building to generate the feature vector of each building. The load prediction unit is used to input the feature vector into the pre-trained multi-task TCN-Transformer model to obtain the load prediction results of each building output by the model. The multi-task TCN-Transformer model: extracts local short-term variation features of lag characteristics, historical load time series, and meteorological time series in the time series dimension through TCN; and obtains long-term global dependencies between time series data through Transformer. The system integrates meteorological features and load features based on cross-attention; the fused features are combined with building embedding features and input into a multi-task output head; and load prediction results for each building are output based on independent output branches adapted to each building.
9. An electronic device, characterized in that, include: A processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the steps of the method as claimed in any one of claims 1-7.
10. A storage medium, characterized in that, include: The storage medium stores a program or instructions that, when executed by a processor, implement the steps of the method as described in any one of claims 1-7.
