Time sequence prediction method and device based on multi-scale patch parallel prediction network

Through a multi-scale patch parallel prediction network, combined with sliding windows and Transformer skeletons, different scale features are integrated to solve the problem of difficulty in capturing short-term fluctuations and long-term trends in the existing technology, achieving more efficient time series prediction, and is suitable for power data prediction. .

CN118735059APending Publication Date: 2024-10-01XINJIANG UNIVERSITY
View PDF 0 Cites 10 Cited by

Patent Information

Application Number
CN202410853459.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-28
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

Existing time series forecasting methods are difficult to fully capture complex short-term fluctuations and long-term trends, and a single loss function lacks flexibility when training models in diverse forecasting tasks, resulting in poor forecasting results.

Method used

A multi-scale patch parallel prediction network is used to segment data through sliding windows and generate patch representations of multiple scales. The Transformer skeleton and adaptive fusion module are used to integrate features of different scales and a hybrid loss function is designed to improve prediction accuracy.

Benefits of technology

It significantly improves the accuracy of multivariate time series prediction, improves the model's expression ability and prediction performance for complex data, is suitable for power time series data prediction in industrial control systems, and has high training and inference time efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118735059A_ABST
    Figure CN118735059A_ABST
Patent Text Reader

Abstract

The invention discloses a time sequence prediction method and device based on a multi-scale patch parallel prediction network. The time series prediction method based on the multi-scale patch parallel prediction network comprises the following steps: inputting a to-be-predicted target into a time series prediction model to obtain a prediction result; the time sequence prediction model is established by the following steps: S10: acquiring power time sequence data, segmenting a data set in a sliding window mode, and generating an original training data set Dtrain and an original test data set Dtest; s20, performing data analysis and preprocessing on the data set Dtrain and the data set Dtest, and recording a training set statistical value set Strain adopted during data preprocessing; s30, constructing an initial time sequence prediction model; and S40, training the initial time sequence prediction model to obtain the time sequence prediction model. The time sequence prediction method and device based on the multi-scale patch parallel prediction network have higher accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of time series prediction, and in particular relates to a time series prediction method and device based on a multi-scale patch parallel prediction network. Background Art

[0002] In today's era of information explosion, time series prediction technology has become one of the important driving forces for promoting social progress and development. In recent years, with the rapid development of technologies such as big data and artificial intelligence, time series prediction technology has been widely used in many key areas related to national economy and people's livelihood, such as power forecasting, weather forecasting, and traffic flow forecasting, which has had a profound impact on people's production and life. In these prediction scenarios, it is particularly important to accurately predict data over a long period of time. Through time series prediction technology, we can conduct in-depth analysis of future development trends, cyclical fluctuations, and potential influencing factors, so as to formulate strategies and avoid risks in advance, and provide timely and effective support for people's decision-making. Taking power forecasting as an example, time series prediction technology constructs a prediction model that can reflect the law of power demand changes by deeply mining and analyzing historical power consumption data. This technology can not only help power workers achieve more refined power system management and ensure the stability of power supply, but also provide a scientific basis for energy dispatching, electricity price setting, etc., and promote the sustainable development of the power industry.

[0003] Traditional time series data, as a set of specific variable data recorded in a continuous order within a specific time span, has a distinct dynamic nature of changing over time. Compared with static image and text data, time series data uniquely reflects the dynamic evolution under the passage of time. Generally speaking, these data can be decomposed into three main parts: trend terms, which represent overall growth or decay; cycle terms, which reflect periodic fluctuations in the data; and residual terms, which are random fluctuations after removing trends and cycles. Time series prediction is based on this unique data characteristic. By deeply analyzing these components in historical data, it is possible to predict the trend of data changes over a long period of time in the future. Traditional time series prediction methods, such as polynomial fitting, can process historical data and predict future trends to a certain extent, but their prediction effects are often limited when faced with complex and changeable data patterns. In particular, when faced with large-scale data sets, the computational efficiency of polynomial fitting methods will drop significantly, and the prediction process will become relatively slow, making it difficult to meet the real-time and accuracy requirements of modern data analysis. Therefore, with the continuous advancement of technology, researchers are constantly exploring new time series forecasting methods, such as deep learning, machine learning, etc., to better capture complex patterns in the data, improve the accuracy and efficiency of forecasts, and cope with increasingly complex and changeable data challenges.

[0004] With the rapid development of artificial intelligence technology, neural network-based methods have dominated the field of time series prediction. At present, the widely used neural network methods in the field of time series prediction mainly include three schools: methods based on convolutional neural networks (CNNs), methods based on multi-layer perceptrons (MLPs), and variants based on Transformer models. CNN-based methods have shown excellent performance in processing time series data by capturing local dependencies of data through ordinary convolutions with their powerful local feature extraction capabilities. However, CNN also has certain limitations in modeling the dynamics and temporal nature of time series. It mainly focuses on local features in space and may not be able to fully capture these key characteristics in time series data. MLP-based methods attempt to decompose time series data into multiple components and predict each component independently. However, this method may appear to be relatively simple when dealing with complex time patterns and it is difficult to fully fit the complexity and dynamics of the data. The original Transformer model has achieved remarkable results in dealing with the problem of permutation invariance with its powerful self-attention mechanism, but the characteristic of time series data is that its temporal arrangement has a crucial impact on the overall characteristics. Therefore, researchers have made targeted improvements to the Transformer model to better meet the needs of time series prediction, such as introducing positional encoding to capture time series information, or combining techniques such as temporal convolution with the Transformer model to more accurately capture the dynamic dependencies in time series data. These improvements have enabled methods based on the Transformer model to show great potential in the field of time series prediction.

[0005] Current methods based on Transformer models are trying to reduce spatial and temporal complexity to adapt to the characteristics of time series data, such as using patch-based methods. However, current methods still have shortcomings in two aspects: first, it is difficult to fully capture the complex short-term fluctuations and long-term trends in time series data, which requires the model to have cross-scale learning capabilities; second, a single loss function is difficult to better train the model in a variety of prediction tasks, and a more flexible and adaptive loss function needs to be designed.

[0006] In view of this, the present invention proposes a new time series prediction method and device based on a multi-scale patch parallel prediction network, which has higher accuracy in multivariate time series prediction. Summary of the invention

[0007] The object of the present invention is to provide a time series prediction method based on a multi-scale patch parallel prediction network, which effectively improves the accuracy of multivariate time series prediction.

[0008] In order to achieve the above purpose, the technical solution adopted is:

[0009] A time series prediction method based on a multi-scale patch parallel prediction network is as follows: inputting a target to be predicted into a time series prediction model to obtain a prediction result;

[0010] The establishment of the time series prediction model includes the following steps:

[0011] S10: Read data from the power transformer database in chronological order, and split the data set by sliding window to generate an original training data set Dtrain and an original test data set Dtest;

[0012] S20: Perform data analysis and preprocessing on the data set Dtrain and the data set Dtest to obtain a preprocessed training data set D'train and a preprocessed test data set D'test; and record a training set statistical value set Strain used in data preprocessing;

[0013] S30: construct an initial time series prediction model;

[0014] S40: training the initial time series prediction model to obtain the time series prediction model.

[0015] Furthermore, in step S10, the step of dividing the data set by sliding window is as follows: the input data sequence is set to be from time 0 to time T, and the output sequence, that is, the sequence to be predicted, extends from time T+1 to time T+L, where T and L both represent specific time lengths.

[0016] Furthermore, in step S20, data analysis and preprocessing include: missing value processing, feature normalization, statistical value recording, and test data set preprocessing. The specific steps are:

[0017] S21 Missing value processing: fill the missing values ​​of the time series variables in the original training data set Dtrain, and select zero value or the mean value of the variable to correct the missing values ​​in the data set;

[0018] S22 feature normalization: According to the maximum and minimum values ​​of each feature, the maximum and minimum normalization method is used to map the feature values ​​to a unified range;

[0019] S23 Statistical value recording: In the process of missing value filling and feature normalization, the zero value or mean value used to correct the missing value is recorded and stored in the training set statistical value set Strain;

[0020] S24 Test data set preprocessing: Use the training set statistical value set Strain to perform the same data analysis and preprocessing on the test data set Dtest as the training set.

[0021] Furthermore, in step S30, the initial time series prediction model includes:

[0022] Multi-scale patch generation module: obtains patch representations of multiple scales of input data;

[0023] Transformer skeleton: input the patch representation of multiple scales as described above and obtain the predicted components of each scale;

[0024] Adaptive fusion module: weights the useful information at each scale, thereby fusing the prediction components at each scale to obtain the final prediction result;

[0025] Hybrid loss function module: compares the final prediction result with the actual value, uses the optimization algorithm to perform back propagation of the time series prediction model, and updates the time series prediction model parameters.

[0026] Furthermore, the step of obtaining patch representations of multiple scales of input data in the multi-scale patch generation module is:

[0027] First, use the predefined hyperparameter patch length set Patch_len = [PL1, ..., PL n+m ] and the patch spacing set Stride = [S1,…,S n+m ], calculate the number of patches of each scale Patch_num = [N1, ..., N n+m ];in

[0028] Then, while inputting the time series, multiple scale patch operations are performed to convert the input time series into a patch representation of the i-th scale. The process is as follows:

[0029] x=ReplicationPad1d((0,S i ); x=unfold(dimension=-1, size=PL i , S=S i );

[0030] Among them, ReplicationPad1d uses the first input sequence value to fill S i times to ensure that the input sequence can complete the subsequent patch segmentation, the unfold operation converts the sequence value of the last dimension to a length of PL i The step length is S i Expand to obtain the patch representation p of the i-th scale i .

[0031] Furthermore, the predefined hyperparameter patch length set Patch_len and patch spacing set Stride are used, and the specific value set is: the patch length value of each scale is set to 8*i, and the patch spacing length is taken as half of the patch length value, that is, 4*i.

[0032] Furthermore, the steps to obtain the predicted components of each scale in the Transformer skeleton are:

[0033] (1) normalizing the patch representation, the formula is: Xpi = Norm(pi); wherein Norm normalizes the patch representation;

[0034] (2) The patch representation is mapped to the Transformer latent space of dimension d via a trainable linear projection Wp∈RD×P, while a learnable additional positional encoding Wpos∈RD×N is used to monitor the temporal order of the patches, as follows:

[0035] (3)

[0036] Among them, Qh, Kh and Vh are the query, key and value obtained by the h-th head mapping by projecting the embedded representation of the patch into three linear spaces;

[0037] (4)

[0038] Where d is the dimension of each head, and Attention uses the multi-head scaled dot product attention mechanism to process the query, key, and value mapped by the h-th head to obtain the attention output of the h-th head.

[0039] (5)

[0040] Among them, h represents the number of multiple heads h∈{1, 2, …, H}, Concat concatenates the attention outputs of H heads to get the total attention, and Linear maps the hidden layer dimension to the number of input sequence channels;

[0041] (6) Perform residual connection and layer normalization on the total attention and the embedded representation of the input sequence. The formula is: Among them, LN is LinearNorm, that is, layer normalization;

[0042] (7) The attention output of the i-th scale is flattened and sent to the linear head transformation, converting the two-dimensional patch representation back to a one-dimensional sequence to obtain the prediction component of the i-th scale, which is formulated as: Among them, LH is LinearHead;

[0043] (8)Forecast i =denorm(forecast i ); wherein denorm is the inverse operation of the step Norm, and performs inverse normalization on the predicted component.

[0044] Furthermore, the step of obtaining the final prediction result in the adaptive fusion module is: setting a learnable weight parameter W, fusing the prediction components of each scale, and the formula used is:

[0045] Among them, ☉ represents the element-by-element product, Forecast i represents the output prediction component of the i-th patch-scale branch in the feature representation;

[0046] The formula for comparing the final predicted value and the actual value in the hybrid loss function module is:

[0047]

[0048] in, is the predicted value, y is the actual value, and the first half of the loss is consistent with the previous loss function.

[0049] Furthermore, in step S40, the step of training the initial time series prediction model includes:

[0050] S41: Use the multi-scale patch generation module to segment the training data set D'train to obtain patch representations of multiple scales P = [p1, ..., p n+m ], p i represents the patch representation of the i-th scale, i=1,...,n+m;

[0051] S42: The patch is represented by p i Send it into the Transformer skeleton to get the encoding representation H of the i-th scale i ;

[0052] S43: The encoding indicates H i Do a linear transformation to get the predicted component value f i ;

[0053] S44: the adaptive fusion module learns the weights W of patches of different scales, and fuses the prediction components of different scales according to the weights W to obtain a prediction value F after fusion of multiple scales;

[0054] S45: using the mixed loss function module to calculate the loss function value of the predicted value F and the true value Y, calculating the gradient of the parameters of the initial time series prediction model, using the optimization algorithm to perform the back propagation of the time series prediction model, and updating the parameters of the time series prediction model;

[0055] S46: judging whether the updated initial time series prediction model converges according to the change trend of the loss function value;

[0056] If there is no convergence, return to step S41 to continue training the initial time series prediction model and update the parameters of the initial time series prediction model;

[0057] When convergence has occurred, the parameters of the updated initial time series prediction model are saved to complete the training and obtain a trained time series prediction model, namely, a time series prediction model.

[0058] Another object of the present invention is to provide a time series prediction device based on a multi-scale patch parallel prediction network. In order to achieve the above object, the technical solution adopted is:

[0059] A time series prediction device based on a multi-scale patch parallel prediction network, comprising:

[0060] A data acquisition unit for collecting power time series data generated by power transformers in industrial control systems and storing it securely in a database;

[0061] The data preprocessing unit cleans, standardizes, and processes outliers on the collected data, and divides the data into training and test sets;

[0062] A multi-scale patch generation unit that obtains patch representations of multiple scales of the input data to simultaneously capture complex short-term fluctuations and long-term trends in time series data;

[0063] The patch feature extraction unit puts the generated patch representations of each scale into the Transformer skeleton structure for feature extraction and further learns the features of each scale;

[0064] The parallel multi-scale prediction unit feeds the features of each scale into the linear predictor and obtains the prediction components of each scale at the same time;

[0065] The adaptive fusion unit performs learnable adaptive fusion of prediction components at each scale to obtain prediction results that combine complex short-term fluctuations and long-term trends.

[0066] Compared with the prior art, the present invention has the following beneficial effects:

[0067] To address the problem that a single-scale patch still cannot fully capture the complex short-term fluctuations and long-term trends in time series data, the present invention uses a multi-branch architecture to convert time series into two-dimensional patches with different length scales, and uses an adaptive fusion module to integrate features from each scale, thereby effectively improving the accuracy of multivariate time series prediction. The specific advantages are:

[0068] 1. The technical solution of the present invention makes full use of the unique characteristics of patch representation to capture the periodicity and trend characteristics of time series data. By changing the size of the patch, the receptive field of the model for data is expanded at different scales, which helps to capture the dependencies at different time scales and enrich the expressive power of the model.

[0069] 2. The technical solution of the present invention introduces a multi-scale patch parallel prediction network, which can effectively fuse features of different scales, thereby significantly improving the model's prediction performance for future sequences.

[0070] 3. The technical solution of the present invention is to design a multi-scale patch parallel prediction network, which is a patch-based shallow structure. Compared with other deep Transformer models, the training time and inference time of this model are more efficient and suitable for the prediction of power time series data for industrial control systems. BRIEF DESCRIPTION OF THE DRAWINGS

[0071] Figure 1 It is a schematic diagram of the process of the present invention.

[0072] Figure 2 This is a model structure diagram of the multi-scale patch parallel prediction network proposed in the present invention.

[0073] Figure 3 This is a schematic diagram of the prediction results of power time series data in an industrial control system using the method proposed in the present invention.

[0074] Figure 4 A schematic diagram of the structure of a time series prediction device based on a multi-scale patch parallel prediction network provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0075] In order to further illustrate the time series prediction method and device based on the multi-scale patch parallel prediction network of the present invention and achieve the intended purpose of the invention, the time series prediction method and device based on the multi-scale patch parallel prediction network proposed by the present invention are described in detail below in combination with the preferred embodiments, and their specific implementation methods, structures, features and functions are described as follows. In the following description, different "one embodiment" or "embodiment" do not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.

[0076] The following will further introduce the time series prediction method and device based on the multi-scale patch parallel prediction network of the present invention in detail in conjunction with specific embodiments:

[0077] In order to enhance the ability of prediction technology to extract short-term local dependency features and long-term global dependency features, thereby improving the accuracy of prediction, and reducing the time complexity and space complexity of the prediction method, and facilitating the actual deployment and application of the prediction method, the present invention provides a time series prediction method and device based on a multi-scale patch parallel prediction network, and the technical solution adopted is:

[0078] A time series prediction method based on a multi-scale patch parallel prediction network is as follows: inputting a target to be predicted into a time series prediction model to obtain a prediction result;

[0079] The establishment of the time series prediction model includes the following steps:

[0080] S10: Use the industrial control system to collect the power time series data generated by the power transformer, and split the data set by sliding window to generate the original training data set Dtrain and the original test data set Dtest;

[0081] S20: Perform data analysis and preprocessing on the data set Dtrain and the data set Dtest to obtain a preprocessed training data set D'train and a preprocessed test data set D'test; and record a training set statistical value set Strain used in data preprocessing;

[0082] S30: construct an initial time series prediction model;

[0083] S40: Training the initial time series prediction model to obtain a time series prediction model.

[0084] Preferably, in step S10, the step of dividing the data set by sliding window is: setting the input data sequence to be from time 0 to time T, and the output sequence, that is, the sequence to be predicted, extends from time T+1 to time T+L, where T and L both represent specific time lengths.

[0085] In the above technical solution, in order to construct the training data set and the test data set, the data set is segmented by a sliding window method, ensuring that the timestamp of the training data set is earlier than the timestamp of the test data set to simulate the time sequence and prediction scenario in the real world. In this way, the original training data set Dtrain and the original test data set Dtest obtained do not overlap in timestamps, ensuring the independence and accuracy of the prediction task.

[0086] Preferably, in step S20, data analysis and preprocessing include: missing value processing, feature normalization, statistical value recording, and test data set preprocessing, and the specific steps are:

[0087] S21 Missing value processing: fill the missing values ​​of the time series variables in the original training data set Dtrain, and select zero value or the mean value of the variable to correct the missing values ​​in the data set;

[0088] S22 feature normalization: According to the maximum and minimum values ​​of each feature, the maximum and minimum normalization method is used to map the feature values ​​to a unified range;

[0089] S23 Statistical value recording: In the process of missing value filling and feature normalization, the zero value or mean value used to correct the missing value is recorded and stored in the training set statistical value set Strain;

[0090] S24 Test data set preprocessing: Use the training set statistical value set Strain to perform the same data analysis and preprocessing on the test data set Dtest as the training set.

[0091] In the above technical solution, the present invention ensures the quality and accuracy of data through data analysis and preprocessing.

[0092] Preferably, in step S30, the initial time series prediction model includes:

[0093] Multi-scale patch generation module: obtains patch representations of multiple scales of input data;

[0094] Transformer skeleton: input the patch representation of multiple scales as described above and obtain the predicted components of each scale;

[0095] Adaptive fusion module: weights the useful information at each scale, thereby fusing the prediction components at each scale to obtain the final prediction result;

[0096] Hybrid loss function module: compares the final prediction result with the actual value, uses the optimization algorithm to perform back propagation of the time series prediction model, and updates the time series prediction model parameters.

[0097] Further preferably, the step of obtaining patch representations of multiple scales of input data in the multi-scale patch generation module is:

[0098] First, use the predefined hyperparameter patch length set Patch_len = [PL1, ..., PL n+m ] and the patch spacing set Stride = [S1,…,S n+m ], calculate the number of patches of each scale Patch_num = [N1, ..., Nn+m ];in

[0099] Then, while inputting the time series, multiple scale patch operations are performed to convert the input time series into a patch representation of the i-th scale. The process is as follows:

[0100] x=ReplicationPad1d((0,S i ); x=unfold(dimension=-1, size=PL i , S=S i );

[0101] Among them, ReplicationPad1d uses the first input sequence value to fill S i times to ensure that the input sequence can complete the subsequent patch segmentation, the unfold operation converts the sequence value of the last dimension to a length of PL i The step length is S i Expand to obtain the patch representation p of the i-th scale i .

[0102] Further preferably, the predefined hyperparameter patch length set Patch_len and patch interval set Stride are used, and the specific value set is: the patch length value of each scale is set to 8*i, and the patch interval length is half of the patch length value, that is, 4*i.

[0103] Further preferably, the steps of obtaining the prediction components of each scale in the Transformer skeleton are:

[0104] (1) normalizing the patch representation, the formula is: Xpi = Norm(pi); wherein Norm normalizes the patch representation;

[0105] (2) The patch representation is mapped to the Transformer latent space of dimension d via a trainable linear projection Wp∈RD×P, while a learnable additional positional encoding Wpos∈RD×N is used to monitor the temporal order of the patches, as follows:

[0106] (3) Project the embedded representation of the patch into three linear spaces, and the formula is: Among them, Qh, Kh and Vh are the query, key and value obtained by the h-th head mapping by projecting the embedded representation of the patch into three linear spaces;

[0107] (4) Where d is the dimension of each head, and Attention uses the multi-head scaled dot product attention mechanism to process the query, key, and value mapped by the h-th head to obtain the attention output of the h-th head.

[0108] (5) Concatenate the attention outputs of H heads to get the total attention H i , the formula is: Among them, h represents the number of heads h∈{1, 2, …, H}, and Linear maps the hidden layer dimension to the number of input sequence channels;

[0109] (6) Perform residual connection and layer normalization on the total attention and the embedded representation of the input sequence. The formula is: Among them, LN is LinearNorm, that is, layer normalization;

[0110] (7) The attention output of the i-th scale is flattened and fed into the linear head transformation, thereby converting the two-dimensional patch representation back into a one-dimensional sequence and obtaining the prediction component of the i-th scale, which is formulated as: Among them, LH is LinearHead, that is, linear head transformation;

[0111] (8)Forecast i =denorm(forecast i ); wherein denorm is the inverse operation of the step Norm, and performs inverse normalization on the predicted component.

[0112] Further preferably, the step of obtaining the final prediction result in the adaptive fusion module is: setting a learnable weight parameter W, fusing the prediction components of each scale, and the formula used is:

[0113] Among them, ☉ represents the element-by-element product, Forecast i represents the output prediction component of the i-th patch-scale branch in the feature representation;

[0114] The formula for comparing the final predicted value and the actual value in the hybrid loss function module is:

[0115]

[0116] in, is the predicted value, y is the actual value, and the first half of the loss is consistent with the previous loss function.

[0117] Preferably, in step S40, the step of training the initial time series prediction model includes:

[0118] S41: Use the multi-scale patch generation module to segment the training data set D'train to obtain patch representations of multiple scales P = [p1, ..., p n+m ], p i represents the patch representation of the i-th scale, i=1,...,n+m;

[0119] S42: The patch is represented by p i Send it into the Transformer skeleton to get the encoding representation H of the i-th scale i ;

[0120] S43: The encoding indicates H i Do a linear transformation to get the predicted component value f i ;

[0121] S44: the adaptive fusion module learns the weights W of patches of different scales, and fuses the prediction components of different scales according to the weights W to obtain a prediction value F after fusion of multiple scales;

[0122] S45: using the mixed loss function module to calculate the loss function value of the predicted value F and the true value Y, calculating the gradient of the parameters of the initial time series prediction model, using the optimization algorithm to perform the back propagation of the time series prediction model, and updating the parameters of the time series prediction model;

[0123] S46: judging whether the updated initial time series prediction model converges according to the change trend of the loss function value;

[0124] If there is no convergence, return to step S44 to continue training the initial time series prediction model and update the initial time series prediction model parameters;

[0125] When convergence has occurred, the parameters of the updated initial time series prediction model are saved to complete the training and obtain a trained time series prediction model, namely, a time series prediction model.

[0126] Example 1: A time series prediction method based on multi-scale patch parallel prediction

[0127] Combination Figure 1 , the specific steps are as follows:

[0128] S10: Read data from the power transformer database in chronological order and store it securely in the database. Subsequently, in order to ensure the consistency and order of the data, read the data from the database in chronological order, and divide the data set into two parts by means of sliding window technology: one part is the original training data set Dtrain for training and the other part is the original test data set Dtest for testing.

[0129] The process of splitting data by sliding window is as follows: the input data sequence is set from time 0 to time T, and the output sequence, that is, the sequence to be predicted, extends from time T+1 to time T+L, where T and L represent specific time lengths. In order to construct the training data set and the test data set, ensure that the timestamp of the training data set is earlier than the timestamp of the test data set to simulate the time sequence and prediction scenarios in the real world. In this way, the original training data set Dtrain and the original test data set Dtest obtained do not overlap in timestamps, ensuring the independence and accuracy of the prediction task.

[0130] S20: Perform data analysis and preprocessing on the original training data set Dtrain and the original test data set Dtest obtained in S10. After the processing is completed, the preprocessed training data set D'train and the preprocessed test data set D'test are obtained. During the data preprocessing process, the statistical value set (Strain) used on the training set is recorded. These statistical values ​​have important reference value for subsequent data analysis and model training.

[0131] The steps of data analysis and preprocessing are:

[0132] S21 Missing value processing: In the first step of data preprocessing, missing values ​​are filled for the time series variables in the original training data set Dtrain. According to the actual meaning of each time series variable, zero value or the mean of the variable is selected to correct the missing values ​​in the data set to ensure the integrity and accuracy of the data.

[0133] S22 feature normalization: According to the maximum and minimum values ​​of each feature, the maximum and minimum normalization method is used to map the feature values ​​to a unified range. This step helps to eliminate the impact of dimensional differences between different features on model training.

[0134] S23 Statistical value recording: In the process of missing value filling and feature normalization, the zero value or mean used to correct the missing value, as well as the maximum and minimum values ​​of the features used for normalization are recorded. These statistical values ​​are stored in the training set statistical value set Strain for subsequent use.

[0135] S24 Preprocessing of the test data set Dtest: Use the training set statistical value set Strain to perform the same data analysis and preprocessing on the test data set Dtest as the training set. This includes filling the missing values ​​in the test set with zero values ​​or means in Strain, and normalizing the features of the test set according to the maximum and minimum values ​​of the features in Strain. This step ensures the consistency of data preprocessing between the training set and the test set, which helps to improve the generalization ability of the model.

[0136] S30: Build a time series prediction model, which includes:

[0137] Multi-scale patch generation module: obtains patch representations of multiple scales of input data;

[0138] Transformer skeleton: input the patch representation of multiple scales as described above and obtain the predicted components of each scale;

[0139] Adaptive fusion module: weights the useful information at each scale, thereby fusing the prediction components at each scale to obtain the final prediction result;

[0140] Hybrid loss function module: compares the final predicted value with the actual value, uses the optimization algorithm to perform backpropagation of the time series prediction model, updates the time series prediction model parameters, and further promotes model training in a favorable direction.

[0141] The specific processing procedures in each module are as follows:

[0142] S31: Multi-scale patch generation module. Obtain patch representations of multiple scales of input data, the steps are:

[0143] S311: Using a predefined hyperparameter patch length set Patch_len=[PL1, ..., PL n+m ] and the patch spacing set Stride = [S1,…,S n+m ], calculate the number of patches of each scale Patch_num = [N1, ..., N n+m ],in

[0144] The patch length value of each scale is set to 8*i, and the patch interval length is taken as half of the patch length value, that is, 4*i. In the embodiment of the present invention, Patch_len={8, 16, 32, 64, 128} and Stride={4, 8, 16, 32, 64} are adopted.

[0145] S312: After obtaining the number of patches Patch_num of each scale calculated in S311, the input time series is subjected to patch extraction operations of multiple scales at the same time, and the input time series is converted into a patch representation of the i-th scale. The detailed operation steps are as follows:

[0146] x=ReplicationPad1d((0,S i ); x=unfold(dimension=-1, size=PL i , S=S i );

[0147] Among them, ReplicationPad1d uses the first input sequence value to fill S i times to ensure that the input sequence can complete the subsequent patch segmentation, the unfold operation converts the sequence value of the last dimension to a length of PL i The step length is S i Expand to obtain the patch representation p of the i-th scale i .

[0148] S32: Transformer skeleton. The multi-scale patch representation is input into the Transformer skeleton to obtain the predicted components of each scale, including the following steps:

[0149] S321: Xpi=Norm(pi). Wherein, Norm normalizes the patch representation, thereby alleviating the distribution shift effect between the training data and the test data. In this embodiment, zero mean and unit standard deviation are used to normalize the patch data.

[0150] S322:

[0151] Among them, the patch representation is mapped to the Transformer latent space of dimension d through a trainable linear projection Wp∈RD×P, and a learnable additional position encoding Wpos∈RD×N is used to monitor the temporal order of the patch. This solves the problem that the essence of the Transformer architecture is order-independent and incorporates position information to capture the temporal dependency within the input sequence.

[0152] S323:

[0153] Among them, Qh, Kh and Vh are the query, key and value obtained by the h-th head mapping by projecting the embedded representation of the patch into three linear spaces.

[0154] S324: Where d is the dimension of each head, and Attention uses the multi-head scaled dot product attention mechanism to process the query, key, and value mapped by the h-th head to obtain the attention output of the h-th head.

[0155] S325:

[0156] Among them, h represents the number of heads h∈{1, 2, …, H}, Concat concatenates the attention outputs of H heads to obtain the total attention to obtain feature diversity, and Linear maps the hidden layer dimension to the number of input sequence channels for subsequent calculations.

[0157] S326:

[0158] Among them, this operation performs residual connection and layer normalization on the total attention and the embedded representation of the input sequence to reduce the imbalance caused by different network layers. LN stands for LinearNorm, that is, layer normalization.

[0159] S327:

[0160] Among them, this operation flattens the attention output of the i-th scale and sends it to the linear head transformation, so as to convert the two-dimensional patch representation back to a one-dimensional sequence and obtain the prediction component of the i-th scale. LH is LinearHead, that is, linear head transformation.

[0161] S328: Forecast i =denorm(forecast i ).

[0162] Among them, denorm is the inverse operation of the previous step Norm, and it performs inverse normalization on the prediction component. It adds back the mean and deviation when outputting the prediction so that the predicted sequence conforms to the distribution of the input sequence.

[0163] S33: Adaptive fusion module. The adaptive fusion module is used to weight the useful information in each scale, so as to fuse the prediction components of each scale to obtain the final prediction result. The steps are: setting the learnable weight parameter W, fusing the prediction components of each scale, and the formula used is:

[0164] Among them, ☉ represents the element-by-element product, Forecast i represents the output prediction component of the i-th patch-scale branch in the feature representation.

[0165] S34: Hybrid loss function module. The hybrid loss function module is used to compare the final prediction result with the actual value. The formula used is:

[0166]

[0167] in, is the predicted value, y is the actual value, the first half of the loss is consistent with the previous loss function, and the second half takes into account the over-sensitivity to outliers, thereby improving the robustness of the model to abnormal data.

[0168] S40: Train the constructed time series prediction model. The specific steps are as follows:

[0169] S41: Use the multi-scale patch generation module to segment the training data set D'train to obtain patch representations of multiple scales P = [p1, ..., p n+m ], p i Denotes the patch representation of the i-th scale, i=1,...,n+m.

[0170] S42: Patch representation p i Send it into the Transformer skeleton and get the encoding representation H of the i-th scale i ;

[0171] S43: Encoding representation H of the i-th scale i Do a linear transformation to get the predicted component value f i .

[0172] S44: Using the adaptive fusion module to learn the weights W of patches of different scales, the prediction components of different scales are fused according to the weights W to obtain a prediction result F after fusion of multiple scales.

[0173] S45: Use the mixed loss function module to calculate the loss function value of the predicted value F and the true value Y of the time series prediction model, calculate the gradient of the time series prediction model parameters, use the optimization algorithm to perform back propagation of the time series prediction model, and update the time series prediction model parameters.

[0174] S46: Determine whether the time series prediction model has converged based on the change trend of the loss function value. If not, return to step 41 to continue training the time series prediction model and update the time series prediction model parameters.

[0175] S47: When the time series prediction model has converged, various parameters of the time series prediction model are saved, and the training is completed to obtain a trained time series prediction model.

[0176] S50: predicting the data in the test data set D'test according to the trained time series prediction model to obtain a prediction result;

[0177] S60: Apply the above prediction results to the prediction of power time series data in industrial control systems.

[0178] Example 2.

[0179] The specific steps are as follows:

[0180] S10: Read data from the power transformer database in chronological order, and split the data set by sliding window to generate an original training data set Dtrain and an original test data set Dtest.

[0181] S20: Perform data analysis and preprocessing on the original training data set Dtrain and the original test data set Dtest obtained in S1 to obtain a preprocessed training data set D'train and a preprocessed test data set D'test, and record a training set statistical value set Strain used in data preprocessing.

[0182] S30: Use a multi-scale patch generation module to obtain patch representations of multiple scales of the input data.

[0183] S40: Input the multi-scale patch representation into the Transformer skeleton to obtain the encoding representation H of the i-th scale i .

[0184] S50: Encoding representation H of the i-th scale i Do a linear transformation to get the predicted component value f i .

[0185] S60: Using the adaptive fusion module to learn the weights W of patches represented by different scales, and fusing the prediction components of different scales according to the weights W to obtain a prediction result F after fusion of multiple scales.

[0186] S70: Use the mixed loss function module to calculate the loss function value of the predicted value F and the true value Y of the time series prediction model, calculate the gradient of the time series prediction model parameters, use the optimization algorithm to perform back propagation of the time series prediction model, and update the time series prediction model parameters.

[0187] S80: When the time series prediction model has converged, various parameters of the time series prediction model are saved, and the training is completed to obtain a trained time series prediction model.

[0188] S90: Predict the data in the test data set D'test according to the trained time series prediction model to obtain a prediction result, which is applied to the prediction of power time series data in the industrial control system.

[0189] The specific operation steps in steps S10-S90 are:

[0190] In S10 of this embodiment, a sliding window method is used to segment the data set, the input sequence length is T, and the output sequence length is L. The timestamp of the training data set is smaller than the timestamp of the test data set, and there is no intersection between the two types of data sets in timestamps.

[0191] In this embodiment S20, the original training data set Dtrain and the original test data set Dtest in S10 are used as inputs, and the data sets are preprocessed, including: missing value filling, selecting zero value, mean value, etc. to correct the missing values ​​according to the actual meaning of the feature value; feature normalization, performing maximum and minimum normalization on the features according to the maximum and minimum values ​​of each feature to eliminate the influence of the dimensions between the features. The preprocessed training data set D'train and the preprocessed test data set D'test are obtained, and the training set statistical value set index Strain used in the above data preprocessing is retained.

[0192] The specific steps of S30 in this embodiment include:

[0193] S31: Using the predefined hyperparameter patch length set Patch_len=[PL1, ..., PL n+m ] and the patch spacing set Stride = [S1,…,S n+m ], calculate the number of patches of each scale Patch_num = [N1, ..., N n+m ],in

[0194] S32: After obtaining the number of patches Patch_num at each scale, the input time series is subjected to patch extraction operations at multiple scales simultaneously, and the input time series is converted into a patch representation of the i-th scale. The detailed operation steps are as follows:

[0195] x=ReplicationPad1d((0,S i ); x=unfold(dimension=-1, size=PL i , S=S i );

[0196] Among them, ReplicationPad1d uses the first input sequence value to fill S itimes to ensure that the input sequence can complete the subsequent patch segmentation, the unfold operation converts the sequence value of the last dimension to a length of PL i The step length is S i Expand to obtain the patch representation p of the i-th scale i .

[0197] The specific steps of S4 in this embodiment include:

[0198] S41:Xp i =Norm(p i ).

[0199] Among them, Norm normalizes the patch representation to alleviate the distribution shift effect between training data and test data, and normalizes the patch data with zero mean and unit standard deviation.

[0200] S42:

[0201] Here, the patch representation is obtained by a trainable linear projection Wp∈R D×P Mapped to the Transformer latent space of dimension d, while adopting a learnable additional positional encoding Wpos∈R D×N To monitor the temporal order of patches, we address the problem that the nature of the Transformer architecture is order-independent and incorporate position information to capture temporal dependencies within the input sequence.

[0202] S43:

[0203] Among them, Qh, Kh and Vh are the query, key and value obtained by the h-th head mapping by projecting the embedded representation of the patch into three linear spaces.

[0204] S44:

[0205] Where d is the dimension of each head, and Attention uses the multi-head scaled dot product attention mechanism to process the query, key, and value mapped by the h-th head to obtain the attention output of the h-th head.

[0206] S45:

[0207] Among them, h represents the number of heads h∈{1, 2, …, H}, Concat concatenates the attention outputs of H heads to obtain the total attention to obtain feature diversity, and Linear maps the hidden layer dimension to the number of input sequence channels for subsequent calculations.

[0208] S46:

[0209] Among them, this operation performs residual connection and layer normalization on the total attention and the embedded representation of the input sequence to reduce the imbalance caused by different network layers. LN stands for LinearNorm, that is, layer normalization.

[0210] In this embodiment S50, the encoding representation H of the i-th scale is i Do a linear transformation to get the predicted component value f i , as follows:

[0211] S51:

[0212] Among them, this operation flattens the attention output of the i-th scale and sends it to the linear head transformation, so as to convert the two-dimensional patch representation back to a one-dimensional sequence and obtain the prediction component of the i-th scale. LH is LinearHead, that is, linear head transformation.

[0213] S52: Forecast i =denorm(forecast i ).

[0214] Among them, denorm is the inverse operation of the previous step Norm, and it performs inverse normalization on the prediction component. It adds back the mean and deviation when outputting the prediction so that the predicted sequence conforms to the distribution of the input sequence.

[0215] In S60 of this embodiment, a learnable weight parameter W is set for the prediction components of each scale, and the prediction components of each scale are fused. The specific formula is as follows:

[0216] Among them, ☉ represents the element-by-element product, Forecast i represents the output prediction component of the i-th patch-scale branch in the feature representation.

[0217] In S70 of this embodiment, a hybrid loss function module is used to compare the final prediction result with the actual value, and the formula is as follows:

[0218]

[0219] in, is the predicted value, y is the actual value, the first half of the loss is consistent with the previous loss function, and the second half takes into account the over-sensitivity to outliers, thereby improving the robustness of the model to abnormal data. The obtained loss function value determines whether the model has converged. If it has not converged, it means that the model parameters have not reached the optimal result, and it is necessary to return to S30 to continue training the model and update the model parameters.

[0220] In S80 of this embodiment, after the model has converged, various parameters of the model are saved.

[0221] In S90 of this embodiment, the test data set is predicted according to the model saved in S80 to obtain a prediction result of the test set.

[0222] Example 3.

[0223] In order to implement the above process, the present invention provides a time series prediction device based on a multi-scale patch parallel prediction network. Figure 2 , Figure 2 The specific model structure diagram of the multi-scale patch parallel prediction network proposed in the present invention is shown. The model structure of the present invention is divided into two main parts: a multi-scale patch generation module and an adaptive fusion module, wherein the multi-scale patch generation module is used to generate patch representations of the input sequence at different scales, so as to more effectively extract the dependencies of the input sequence at different scales, and the adaptive fusion module is used to fuse the most beneficial parts of each scale to simultaneously capture the long-term dependencies and short-term oscillation characteristics of the time series.

[0224] The prediction device comprises:

[0225] A data acquisition unit for collecting power time series data generated by power transformers in industrial control systems and storing it securely in a database;

[0226] The data preprocessing unit performs preprocessing steps such as data cleaning, standardization, and outlier processing on the collected content, and divides the data into training sets and test sets;

[0227] A multi-scale patch generation unit that obtains patch representations of multiple scales of the input data to simultaneously capture complex short-term fluctuations and long-term trends in time series data;

[0228] The patch feature extraction unit puts the generated patch representations of each scale into the Transformer skeleton structure for feature extraction and further learns the features of each scale;

[0229] The parallel multi-scale prediction unit feeds the features of each scale into the linear predictor and obtains the prediction components of each scale at the same time;

[0230] The adaptive fusion unit performs learnable adaptive fusion of prediction components at each scale to obtain prediction results that combine complex short-term fluctuations and long-term trends.

[0231] In combination with this embodiment, it can be seen that in practical applications, the present invention actually proposes a complete solution, including a specific computer storage medium and its supporting data processing unit. Among them, the computer storage medium is used to store a customized computer program, which, when executed on the data processing unit, can run the time series prediction method based on the multi-scale patch parallel prediction network introduced in the present invention, including its invention content and some or all of the steps in each embodiment. The storage medium is in various forms, including but not limited to a disk, an optical disk, a read-only storage memory (ROM) or a random access memory (RAM), etc.

[0232] For those skilled in the art, it can be clearly recognized that the technical solution of the present invention can be implemented by a computer program and its corresponding general hardware platform. Based on this understanding, the technical solution of the present invention, or its contribution to the prior art, can be embodied as a computer program software product, which is stored in the above-mentioned storage medium and contains several instructions for instructing a device containing a data processing unit (such as a personal computer, a server, a single-chip microcomputer, an MCU or a network device, etc.) to execute the methods described in various embodiments of the present invention or specific parts of its embodiments.

[0233] Example 4.

[0234] In order to verify the effectiveness of the present invention, this embodiment is verified by examples on data sets collected in four real scenarios, including ETTh1 data set, ETTh2 data set, ETTm1 data set and ETTm2 data set. These four real data sets are power transformer data provided by a power company, including power transformer load, oil temperature and other data from 2016 to 2018, where the sampling granularity of ETTm1 data set and ETTm2 data set is 15 minutes, and the sampling granularity of ETTh1 data set and ETTh2 data set is 1 hour.

[0235] Using the above dataset, follow the steps below to perform sequence prediction and evaluation:

[0236] S1: Read data from the power transformer database in chronological order, and split the data set by sliding window to generate the original training data set Dtrain and the original test data set Dtest.

[0237] S2: Perform data analysis and preprocessing on the original training data set Dtrain and the original test data set Dtest obtained in S1 to obtain the preprocessed training data set D'train and the preprocessed test data set D'test, and record the training set statistical value set Strain used in data preprocessing.

[0238] S3: Use the multi-scale patch generation module to obtain patch representations of multiple scales of the input data.

[0239] S4: Input the multi-scale patch representation into the Transformer skeleton to obtain the encoding representation H of the i-th scale i .

[0240] S5: The encoding representation H of the i-th scale i Do a linear transformation to get the predicted component value f i .

[0241] S6: Use the adaptive fusion module to learn the weights W of patches of different scales, and fuse the prediction components of different scales according to the weights W to obtain the prediction result F after fusion of multiple scales.

[0242] S7: Use the mixed loss function module to calculate the loss function value of the predicted value F and the true value Y of the time series prediction model, calculate the gradient of the time series prediction model parameters, use the optimization algorithm to perform back propagation of the time series prediction model, and update the time series prediction model parameters.

[0243] S8: When the time series prediction model has converged, save the parameters of the time series prediction model, complete the training, and obtain the trained time series prediction model.

[0244] S9: Predict the data in the test data set D'test according to the trained time series prediction model to obtain the prediction results, which are applied to the prediction of power time series data in industrial control systems.

[0245] In order to implement the above process, this embodiment provides a time series prediction device based on a multi-scale patch parallel prediction network. Figure 4 As shown, the prediction device comprises:

[0246] A data acquisition unit for collecting power time series data generated by power transformers in industrial control systems and storing it securely in a database;

[0247] The data preprocessing unit performs preprocessing steps such as data cleaning, standardization, and outlier processing on the collected content, and divides the data into training sets and test sets;

[0248] A multi-scale patch generation unit that obtains patch representations of multiple scales of the input data to simultaneously capture complex short-term fluctuations and long-term trends in time series data;

[0249] The patch feature extraction unit puts the generated patch representations of each scale into the Transformer skeleton structure for feature extraction and further learns the features of each scale;

[0250] The parallel multi-scale prediction unit feeds the features of each scale into the linear predictor and obtains the prediction components of each scale at the same time;

[0251] The adaptive fusion unit performs learnable adaptive fusion of prediction components at each scale to obtain prediction results that combine complex short-term fluctuations and long-term trends.

[0252] The results are shown in Table 1 and Figure 3 shown.

[0253] Figure 3 The prediction results of the method proposed in the present invention on the power time series data in an actual industrial control system are given, wherein the dotted line represents the true value and the solid line represents the predicted value.

[0254] Table 1-2 shows the test evaluation results of the method proposed in the present invention when it is verified on four power transformer data sets (ETTh1 data set, ETTh2 data set, ETTm1 data set and ETTm2 data set). At the same time, the results of other existing methods are listed in the figure to better demonstrate the effectiveness of the present invention through comparison, comparing the mean square error and the mean absolute error respectively. Among them, the model marked with black is the optimal result, and the model marked with underline is the suboptimal result. The compared methods cover transformer-based models, convolutional network-based models and multi-layer perceptron-based models, including (PatchTST, DLinear, MICN, FEDformer, Autoformer, Informer). The test results show that the present invention is superior to the compared models in both the mean square error and the mean absolute error of the prediction results, proving the feasibility and effectiveness of the modeling method of the present invention using a multi-scale patch parallel prediction network to extract multi-scale time dependencies.

[0255] Table 1

[0256]

[0257] Table 2

[0258]

[0259] Combined with the above content, it can be seen that after evaluating the prediction results on the test data set, the method of the present invention achieved an average mean square error of 0.405 and an average absolute error of 0.420 on the 4 prediction steps on the ETTh1 data set, which is 3.2% higher than the optimal result; on the ETTh2 data set, the mean square error is 0.375 and the average absolute error is 0.331, which is 1.0% higher than the optimal result; on the ETTm1 data set, the mean square error is 0.371 and the average absolute error is 0.352, which is 3.0% higher than the optimal result; on the ETTm2 data set, the mean square error is 0.309 and the average absolute error is 0.256, which is 2.8% higher than the optimal result. These results show that the method proposed in the present invention has a certain improvement in prediction accuracy compared with the existing methods, which verifies the effectiveness of the time series prediction method based on multi-scale dilated convolution proposed in the present invention.

[0260] The above is only a preferred embodiment of the embodiment of the present invention, and does not impose any form of limitation on the embodiment of the present invention. Any simple modification, equivalent changes and modifications made to the above embodiment based on the technical essence of the embodiment of the present invention are still within the scope of the technical solution of the embodiment of the present invention.

Claims

1. A time series prediction method based on a multi-scale patch parallel prediction network, characterized in that: The prediction method is as follows: inputting the target to be predicted into the time series prediction model to obtain the prediction result; The establishment of the time series prediction model includes the following steps: S10: Read data from the power transformer database in chronological order, and split the data set by sliding window to generate an original training data set Dtrain and an original test data set Dtest; S20: Perform data analysis and preprocessing on the data set Dtrain and the data set Dtest to obtain a preprocessed training data set D'train and a preprocessed test data set D'test; and record a training set statistical value set Strain used in data preprocessing; S30: construct an initial time series prediction model; S40: Training the initial time series prediction model to obtain the time series prediction model.

2. The time series prediction method according to claim 1, characterized in that: In step S10, the step of dividing the data set by sliding window is as follows: the input data sequence is set to be from time 0 to time T, and the output sequence, that is, the sequence to be predicted, extends from time T+1 to time T+L, where T and L both represent specific time lengths.

3. The time series prediction method according to claim 1, characterized in that: In step S20, data analysis and preprocessing include: missing value processing, feature normalization, statistical value recording, and test data set preprocessing. The specific steps are: S21 Missing value processing: fill the missing values ​​of the time series variables in the original training data set Dtrain, and select zero value or the mean value of the variable to correct the missing values ​​in the data set; S22 feature normalization: According to the maximum and minimum values ​​of each feature, the maximum and minimum normalization method is used to map the feature values ​​to a unified range; S23 Statistical value recording: In the process of missing value filling and feature normalization, the zero value or mean value used to correct the missing value is recorded and stored in the training set statistical value set Strain; S24 Preprocessing of the test data set Dtest: Use the training set statistical value set Strain to perform the same data analysis and preprocessing on the test data set Dtest as the training set.

4. The time series prediction method according to claim 1, characterized in that: In step S30, the initial time series prediction model includes: Multi-scale patch generation module: obtains patch representations of multiple scales of input data; Transformer skeleton: input the patch representation of multiple scales as described above and obtain the predicted components of each scale; Adaptive fusion module: weights the useful information at each scale, thereby fusing the prediction components at each scale to obtain the final prediction result; Hybrid loss function module: compares the final predicted value with the actual value, uses the optimization algorithm to perform back propagation of the time series prediction model, and updates the time series prediction model parameters.

5. The time series prediction method according to claim 4, characterized in that: The steps of obtaining patch representations of multiple scales of input data in the multi-scale patch generation module are: First, use the predefined hyperparameter patch length set Patch_len = [PL1, ..., PL n+m ] and the patch spacing set Stride = [S1,…,S n+m ], calculate the number of patches of each scale Patch_num = [N1, ..., N n+m ];in Then, while inputting the time series, multiple scale patch operations are performed to convert the input time series into a patch representation of the i-th scale. The process is as follows: x=ReplicationPad1d((0,S i ); x=unfold(dimension=-1,size=PL i ,S=S i ); Among them, ReplicationPad1d uses the first input sequence value to fill S i times to ensure that the input sequence can complete the subsequent patch segmentation, the unfold operation converts the sequence value of the last dimension into a length of PL i The step length is S i Expand to obtain the patch representation p of the i-th scale i .

6. The time series prediction method according to claim 5, characterized in that: The predefined hyperparameters of the patch length set Patch_len and the patch spacing set Stride are specifically set as follows: the patch length value of each scale is set to 8*i, and the patch spacing length is set to half of the patch length value, that is, 4*i.

7. The time series prediction method according to claim 4, characterized in that: The steps for obtaining the predicted components of each scale in the Transformer skeleton are: (1) normalizing the patch representation, the formula is: Xpi = Norm(pi); wherein Norm normalizes the patch representation; (2) The patch representation is mapped to the Transformer latent space of dimension d via a trainable linear projection Wp∈RD×P, while a learnable additional positional encoding Wpos∈RD×N is used to monitor the temporal order of the patches, as follows: (3) Project the embedded representation of the patch into three linear spaces, and the formula is: Among them, Qh, Kh and Vh are the query, key and value obtained by the h-th head mapping by projecting the embedded representation of the patch into three linear spaces; (4) Get the attention output of the hth head The formula is: Where d is the dimension of each head, and Attention uses the multi-head scaled dot product attention mechanism to process the query, key, and value mapped by the h-th head to obtain the attention output of the h-th head. (5) Concatenate the attention outputs of H heads to get the total attention H i , to obtain feature diversity, the formula is: Among them, h represents the number of heads h∈{1, 2, …, H}, and Linear maps the hidden layer dimension to the number of input sequence channels; (6) Perform residual connection and layer normalization on the total attention and the embedded representation of the input sequence. The formula is: Among them, LN is LinearNorm, that is, layer normalization; (7) The attention output of the i-th scale is flattened and fed into the linear head transformation, thereby converting the two-dimensional patch representation back into a one-dimensional sequence and obtaining the prediction component of the i-th scale, which is formulated as: Among them, LH is LinearHead, that is, linear head transformation (8)Forecast i =denorm(forecast i ); wherein denorm is the inverse operation of the step Norm, and performs inverse normalization on the predicted component.

8. The time series prediction method according to claim 4, characterized in that: The steps of obtaining the final prediction value in the adaptive fusion module are: setting the learnable weight parameter W, fusing the prediction components of each scale, and the formula used is as follows: Among them, ☉ represents the element-by-element product, Forecast i represents the output prediction component of the i-th patch-scale branch in the feature representation; The formula for comparing the final predicted value and the actual value in the hybrid loss function module is: in, is the predicted value, y is the actual value, and the first half of the loss is consistent with the previous loss function.

9. The time series prediction method according to claim 1, characterized in that: In step S40, the step of training the initial time series prediction model includes: S41: Use the multi-scale patch generation module to segment the training data set D'train to obtain patch representations of multiple scales P = [p1, ..., p n+m ], p i represents the patch representation of the i-th scale, i=1,...,n+m; S42: The patch is represented by p i Send it into the Transformer skeleton to get the encoding representation H of the i-th scale i ; S43: The encoding indicates H i Do a linear transformation to get the predicted component value f i ; S44: using the adaptive fusion module to learn the weights W of patches of different scales, and fusing the prediction components of different scales according to the weights W to obtain a prediction value F after fusion of multiple scales; S45: using the mixed loss function module to calculate the loss function value of the predicted value F and the true value Y, calculating the gradient of the parameters of the initial time series prediction model, using the optimization algorithm to perform the back propagation of the time series prediction model, and updating the parameters of the time series prediction model; S46: judging whether the updated initial time series prediction model converges according to the change trend of the loss function value; If there is no convergence, return to step S41 to continue training the initial time series prediction model and update the parameters of the initial time series prediction model; When convergence has occurred, the parameters of the updated initial time series prediction model are saved to complete the training and obtain a trained time series prediction model, namely, a time series prediction model.

10. A time series prediction device based on a multi-scale patch parallel prediction network, characterized in that: include: A data acquisition unit for collecting power time series data generated by power transformers in industrial control systems and storing it securely in a database; The data preprocessing unit cleans, standardizes, and processes outliers on the collected data, and divides the data into training and test sets; A multi-scale patch generation unit that obtains patch representations of multiple scales of the input data to simultaneously capture complex short-term fluctuations and long-term trends in time series data; The patch feature extraction unit puts the generated patch representations of each scale into the Transformer skeleton structure for feature extraction and further learns the features of each scale; The parallel multi-scale prediction unit feeds the features of each scale into the linear predictor and obtains the prediction components of each scale at the same time; The adaptive fusion unit performs learnable adaptive fusion of prediction components at each scale to obtain prediction results that combine complex short-term fluctuations and long-term trends.

Citation Information

Cited By

  • Factory equipment anomaly detection method based on time series prediction large model

    CN118965242A

  • Industrial automatic production scheduling prediction method and system based on feedforward rule learning

    CN119067268A

  • Method for measuring oil-water two-phase flow parameters of oil well

    CN119889513A

  • Method for measuring parameters of oil-water two-phase flow in oil well

    CN119889513B

  • Effective wave height prediction method based on multi-scale patch

    CN119961629A