Power time sequence characterization method based on hybrid context attention

Through a power time series list method with mixed context attention, combined with multi-scale convolutional layer and Transformer encoder, the problem of adapting power time series data diversity is solved, and accurate feature extraction and model generalization of different sequence lengths and periods are realized. , saving computing resources.

CN119128477APending Publication Date: 2024-12-13HUAZHONG UNIV OF SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411092589.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-09
Publication Date
2024-12-13

AI Technical Summary

Technical Problem

The prior art cannot effectively adapt to the diversity of data in different time series, especially in power prediction scenarios. Traditional methods cannot simultaneously capture the common and specific characteristics of time series, and there is a serious waste of computing resources.

Method used

Using the power time series list method based on mixed context attention, the power time series data is projected into the potential representation space through the data embedding layer, and self-attention calculation is performed using a multi-scale convolution layer and a Transformer encoder to form mixed context attention. mechanism to extract diverse power data characteristics.

Benefits of technology

This method can extract more accurate and reasonable features without destroying the time domain continuity, and is suitable for power time series data of different sequence lengths and periods, improving the generalization ability of the model and computing resource utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119128477A_ABST
    Figure CN119128477A_ABST
Patent Text Reader

Abstract

The invention belongs to the field of time sequence characterization, and particularly relates to a hybrid context attention-based power time sequence characterization method, which comprises the following steps of: projecting power time sequence data to be characterized to a potential characterization space by adopting a data embedding layer to obtain a potential characterization, and dividing the potential characterization into a plurality of fragments, each fragment is used as a mark Token, and a sequence Token is obtained; pooling the sequence Token to summarize information contained in a plurality of local sequences of the sequence Token to obtain a plurality of congruence features, and correspondingly taking the congruence features as a plurality of main marks; all the main marks and all the marks Token are spliced, an encoder is adopted to carry out self-attention calculation on a spliced result to obtain deep representation, time sequence representation is completed, and a mixed context attention calculation mechanism can be achieved in the self-attention calculation process. According to the method, accurate features can be extracted for diversified power data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of time series representation, and more specifically, relates to a power time series representation method based on hybrid contextual attention. Background Art

[0002] Real life contains a large number of different time series application scenarios, and the time series in different scenarios have obvious differences in time granularity, data dimension, and information capacity. For example, in the industrial electricity consumption forecasting scenario, data from multiple meters can be obtained, and multivariate time series data are usually predicted, while in the residential electricity consumption forecasting scenario, a univariate prediction of electricity consumption is required. In addition to the data dimension, there are also large differences in amplitude and trend characteristics between industrial and residential electricity consumption data. Traditional machine learning methods cannot adapt to changes in application scenarios and can only retrain models for new scenarios, which seriously wastes computing resources. Therefore, it is very necessary to propose a design method for a general representation learning model for time series.

[0003] In terms of data representation, time series have the following characteristics: 1) Time series have temporal continuity, and temporal change is one of the main characteristics of time series, so its continuity cannot be destroyed when extracting representations; 2) Time series have obvious periodicity, but data from different sources have different data change trends. Therefore, the model needs to be able to capture more comprehensive representations, have strong generalization capabilities, and adapt to changes in data scenarios. Learning a general time series representation requires comprehensive learning of different data-specific representations, which requires learning both the common representation of time series and retaining the specific representations of different data.

[0004] The current Transformer structure shows great potential in the field of time series representation learning. The traditional TST (Time Series Transformer) directly applies the Transformer structure to the time series field, taking a single data point as a token (feature). Although this method completely retains the temporal continuity of the data, the amount of information contained in a single point is limited and is easily affected by noise fluctuations, which interferes with the Transformer structure's calculation of the relationship between tokens, and the amount of calculation is large. PatchTST uses fixed-length sequence fragments as tokens based on TST, but the fixed-length token division method may destroy the temporal dependency between sequences and is not applicable to all time series. The periodicity contained in different time series is quite different. Using the same fixed-length segmented sequence is obviously unable to adapt to the change of data periodicity and interfere with the model's capture of data periodicity and other features. Based on the Transformer, TimeMAE uses two different encoder modules to learn the representation of visible positions and mask positions through a decoupled autoencoder architecture, but it is not suitable for processing the long-term dependency of time series data and is difficult to capture and represent complex features in time series.

[0005] Therefore, it is of great significance to propose a power time series representation method based on hybrid contextual attention, which can extract more accurate and reasonable features for different sequence lengths and different periods without destroying the continuity of the time domain. Summary of the invention

[0006] In view of the defects of the prior art and the need for improvement, the present invention provides a power time series characterization method based on hybrid contextual attention, which aims to propose a power time series characterization method that can extract more accurate features for diverse data.

[0007] To achieve the above object, according to one aspect of the present invention, a method for characterizing power time series based on hybrid contextual attention is provided, comprising:

[0008] The data embedding layer is used to project the power time series data to be represented into the potential representation space to obtain the potential representation, and the potential representation is divided into multiple segments, each segment is used as a tag Token, and a sequence Token is obtained;

[0009] Pooling the sequence token to summarize the information contained in multiple local sequences of the sequence token to obtain multiple summary features, which correspond to multiple main tags;

[0010] All main tags are concatenated with all tag tokens, and an encoder is used to perform self-attention calculation on the concatenated result to obtain a deep representation, thereby completing the time series representation. The self-attention calculation process can realize the following mixed context attention calculation mechanism: the attention value between the main tag corresponding to each local sequence and the main tags corresponding to other local sequences is calculated respectively, and the attention value between each tag token is calculated respectively; the attention value between each tag token and other tag tokens in the local sequence where it is located and the tag tokens in other local sequences are also calculated at the same time.

[0011] Furthermore, it also includes: acquiring initial power time series data and preprocessing the power time series data.

[0012] Furthermore, the network structure of each convolutional layer in the data embedding layer is:

[0013] It includes multiple convolution blocks, a splicing unit and a computing unit; wherein the sizes of the convolution blocks are different and are used to capture data representations of different granularities; the splicing unit is used to splice multiple data representations of different granularities; the computing unit is used to average the splicing results of the splicing unit input by channel to obtain the overall representation of the convolution layer input data.

[0014] Furthermore, the encoder is a Transformer encoder.

[0015] The present invention also provides a power time series analysis method, comprising:

[0016] Using a hybrid context attention-based power time series representation method as described above, a time series representation of the power time series data to be analyzed is obtained;

[0017] Based on the time series representation, a time series analysis task is performed.

[0018] The present invention also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, it implements the above-mentioned method for characterizing electric power time series based on hybrid contextual attention and / or the above-mentioned method for analyzing electric power time series.

[0019] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a method for characterizing electric power time series based on hybrid contextual attention as described above and / or a method for analyzing electric power time series as described above.

[0020] The present invention also provides a computer program product, including a computer program or instructions, which, when executed by a processor, implements a power time series characterization method based on hybrid contextual attention as described above and / or a power time series analysis method as described above.

[0021] In general, the above technical solutions conceived by the present invention can achieve the following beneficial effects:

[0022] (1) The present invention proposes a method for representing power time series based on hybrid contextual attention, which pools the sequence tokens obtained by the data embedding layer to summarize the information contained in multiple local sequences of the sequence tokens, obtains multiple summary features, and corresponds to multiple main tags; the present invention proposes to splice all the main tags with all the tag tokens, and uses an encoder to perform self-attention calculation on the spliced ​​results to obtain a deep representation. This design uses the main tag (Mater Token) to summarize the information contained in the local sequence tag token, and does not simply summarize the sequence token as a tag, so the information contained is richer, so the main tag (Mater Token) is closer to the original sequence token. In the process of calculating the cross attention based on the splicing result, the encoder further strengthens the information interaction between the main tag (Mater Token) and the tag token, as well as the relationship calculation between each local sequence tag token, that is, through the calculation of local attention and cross attention, a hybrid contextual attention calculation mechanism is formed, so this hybrid contextual attention mechanism can make the obtained power data representation more accurate and reasonable. Therefore, the method of the present invention can extract more accurate features for diverse power data and is more suitable for power time series tasks.

[0023] (2) The present invention has also improved and innovated the data embedding layer, and designed a strong convolution layer in the data embedding layer. This design integrates multiple convolutions of different sizes, so that the representation has a multi-scale field of view and contains richer data information. This design makes the representation perception field of view between adjacent markers Tokens overlap to a certain extent, instead of using a single scale to divide the data, so the time domain continuity of the data can be maintained without causing damage. At the same time, the multi-scale convolution design enables each marker Token to contain information of different field sizes, which can adapt to different power sequence lengths and different periods, and extract more accurate and reasonable features at the same time. Therefore, the present invention can extract more accurate and reasonable features for power time series data of different sequence lengths and different periods without destroying the time domain continuity. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1A flowchart of a method for characterizing electric power time series based on hybrid contextual attention provided by an embodiment of the present invention;

[0025] Figure 2 A schematic diagram of hybrid context attention calculation provided by an embodiment of the present invention;

[0026] Figure 3 A data embedding layer structure diagram provided by an embodiment of the present invention;

[0027] Figure 4 A diagram of the convolutional layer network structure in the data embedding layer structure provided by an embodiment of the present invention;

[0028] Figure 5 An architecture diagram of a power time series characterization and analysis model based on hybrid contextual attention provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0029] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.

[0030] Embodiment 1

[0031] A hybrid contextual attention-based power time series representation method, such as Figure 1 As shown, including:

[0032] The data embedding layer is used to project the power time series data to be represented into the latent representation space to obtain the latent representation, and the latent representation is divided into multiple segments, each segment is used as a token, and a sequence token is obtained;

[0033] Pooling is performed on the sequence tokens to summarize the information contained in multiple local sequences of the sequence tokens and obtain multiple summary features, which correspond to multiple main markers;

[0034] All main tags are concatenated with all tag tokens, and the encoder is used to perform self-attention calculation on the concatenated result to obtain a deep representation, completing the time series representation. The self-attention calculation process can realize the following mixed context attention calculation mechanism: the main tags corresponding to each local sequence are respectively calculated with the attention values ​​of the main tags corresponding to other local sequences, and at the same time, the attention values ​​of all tag tokens are respectively calculated; each tag token is also calculated with the attention values ​​of other tag tokens in the local sequence where it is located and with the attention values ​​of tag tokens in other local sequences. Figure 2 The schematic diagram of the hybrid context attention calculation is shown.

[0035] This embodiment proposes a method for characterizing electric time series based on hybrid contextual attention, which pools the sequence tokens obtained by the data embedding layer to summarize the information contained in multiple local sequences of the sequence tokens, and obtains multiple summary features, which correspond to multiple main tags; this embodiment proposes to splice all main tags with all tag tokens, and use the encoder to perform self-attention calculation on the spliced ​​results to obtain deep representation. This design uses the main tag (Mater Token) to summarize the information contained in the local sequence tag token, and does not simply summarize the sequence token as a tag, so the information contained therein is richer, so the main tag (Mater Token) is closer to the original sequence token. In the process of calculating the cross attention based on the splicing result, the encoder further strengthens the information interaction between the main tag (Mater Token) and the tag token, as well as the relationship calculation between each local sequence tag token, that is, through the calculation of local attention and cross attention, a hybrid contextual attention calculation mechanism is formed, so this hybrid contextual attention mechanism can make the obtained data representation more accurate and reasonable. Therefore, the method of this embodiment can extract more accurate features for diverse electric power data, and is more suitable for time series tasks.

[0036] It should be noted that the master token is initialized by pooling sequence tokens and will be updated during the encoder operation. The number of master tokens can be flexibly changed with the sequence length of the sequence token. The role of the master token is to summarize the representation information of the local sequence token, perform cross-attention calculations during the encoder's attention calculation process, realize mixed contextual attention, and promote local and global information exchange.

[0037] As a preferred implementation, the above characterization method may further include the following preprocessing step: obtaining initial time series data, and preprocessing the time series data.

[0038] Different tasks require the collection of corresponding data and labels. For example, classification tasks require the collection of time series and corresponding labels, and prediction tasks require the collection of historical time series and future data.

[0039] According to the set sampling time interval, the required time series data is collected and preprocessed. Time series usually have outliers and missing values ​​during the collection process, so outlier processing and missing value filling are required; in order to avoid the interference of different amplitudes of time series on the model learning process, the data needs to be normalized.

[0040] As a preferred implementation, in order to maintain the temporal consistency of the data, the data embedding layer adopts a multi-layer strong convolutional layer structure to project the data into a well-characterized potential representation space and naturally divide the sequence into multiple tokens for subsequent deep representation learning. Therefore, the network structure of each convolutional layer in the preferred data embedding layer of this embodiment is:

[0041] It includes multiple convolution blocks, a splicing unit and a computing unit; wherein the sizes of the convolution blocks are different and are used to capture data representations of different granularities; the splicing unit is used to splice multiple data representations of different granularities; the computing unit is used to average the splicing results of the splicing unit input by channel to obtain the overall representation of the convolution layer input data.

[0042] For example, Figure 3 The data embedding layer structure diagram shown includes three convolutional layers, two pooling layers, and two activation layers:

[0043] The representation dimension of the three convolutional layers first becomes smaller and then becomes larger, forming an information funnel to effectively filter the data information. The dimension sizes of the three convolutional layers are preferably set to 256, 128, and 256.

[0044] The pooling layer further expands the receptive field of the convolutional layer and uses the average pooling function to pool the data. The kernel sizes of the two layers of pooling are preferably set to 2 and 3.

[0045] The activation function of the activation layer uses the GELU function, and the calculation formula is as follows:

[0046] GELU(x)=x*P(X≤x)

[0047] For input x>0, the output of the GELU function is similar to the ReLU function, which is approximately linear output; for input x<0 and smaller, the output of the GELU function is close to 0; when x<0 and close to 0, the output of the GELU is nonlinear and continuous, so the input will be smoother after being activated by the GELU function.

[0048] like Figure 4 As shown, the convolutional layer network structure in the data embedding layer structure:

[0049] Each convolution layer includes multiple convolution blocks, each of which has a different size and is used to capture data representations of different granularities. The number of convolution blocks can preferably be set to 5, and the convolution kernel sizes can preferably be set to 1, 3, 5, 7, and 9, respectively. The input passes through multiple convolution blocks to obtain multiple data representations of different granularities, and the multiple data representations are concatenated and averaged by channel to extract the overall representation of the data.

[0050] As a preferred embodiment, the encoder is a Transformer encoder. The role of the master token here is to replace the classification token (Cls Token) in the traditional Transformer structure to summarize the data representation information. The encoder is based on the Tansformer structure and uses a hybrid contextual attention mechanism to calculate the cross attention between the master token and the sequence token.

[0051] In order to better illustrate the present invention, the following examples are given.

[0052] like Figure 5 As shown in the model architecture diagram, this example preferably sets the sampling time interval for time series data to 1 hour, outputs 24 data as a group every 24 hours, and the sampling period is 21 days, resulting in a one-dimensional vector of length 504. Input the data into the data embedding layer to obtain the potential representation (Token) of the data (sequence Token in the figure); then perform a pooling operation on the sequence Token to obtain multiple initial Master Tokens, and the number of Master Tokens can be preferably set to 3; concatenate multiple Master Tokens with the sequence Token, and the concatenation method is not limited. After concatenation, input them into the encoder to obtain the deep representation. The preferred structure of the encoder is Transformer, which is composed of multiple layers of multi-head self-attention layers. The number of layers of the attention layer and the number of heads of the multi-head attention mechanism can be preferably set to 12 and 8; finally, use the decoder to complete the time series analysis task from the deep representation extracted from the model.

[0053] In order to verify the effectiveness of the present invention, an application example is now given:

[0054] This example experiments on power time series analysis tasks of optimization prediction and classification.

[0055] Specifically, the preferred dataset for prediction is the ETTx dataset, which contains the oil temperature and power load time series collected by power transformers in two years. The ETTx dataset contains four subsets with different recording frequencies: the ETTh1 dataset and the ETTh2 dataset are recorded once every hour, and the ETTm1 dataset and the ETTm2 dataset are recorded every 15 minutes. The ETTh1 and ETTm1 datasets are derived from the same power transformer, and the ETTh2 and ETTm2 datasets are derived from the same power transformer. The preferred evaluation index is the mean square error MSE between the predicted value and the actual value, and the smaller the value, the better. The preferred experimental parameters are: data length is 504, prediction length is 96, batch size is set to 64, training rounds are 100, optimizer uses AdamW, the initial value of the learning rate is set to 0.001, warmup is used to update the learning rate, and the learning rate is decayed according to the cosine function after the 5th round. The experimental results of this example on prediction are shown in Table 1. Compared with the current mainstream representation learning methods PatchTST and TimeMAE, this example has the best performance.

[0056] Table 1 Experimental results of this example on prediction

[0057] Dataset This example PatchTST TimeMAE ETTh1 0.095 0.098 0.108 ETTh2 0.226 0.249 0.266 ETTm1 0.043 0.046 0.063 ETTm2 0.107 0.116 0.193

[0058] The preferred datasets for classification are Computers, ElectricDevices, ItalyPowerDemand and LargeKitchenAppliances datasets in the UCR database.

[0059] Among them, the Computers dataset contains electricity consumption behavior data of 251 households, sampled at intervals of 2 minutes within a month, the length of each data is 720, and the categories include desktop computers and laptops.

[0060] The ElectricDevices dataset includes electricity consumption data of seven types of household items, such as TVs, kettles, and refrigerators. It is classified only according to the electricity consumption every 15 minutes, and the length of each data is 96.

[0061] The ItalyPowerDemand dataset is 12 months of electricity demand data from Italy. The task is to distinguish between October to March and April to September. Data is collected every 15 days. The length of each data is 24 and there are 2 categories.

[0062] The LargeKitchenAppliances dataset contains electricity consumption data of 375 large kitchen appliances sampled at 2-minute intervals within a month. The length of each data is 720, and the categories include washing machines, tumble dryers, and dishwashers.

[0063] The preferred evaluation index for classification is the classification accuracy ACC, and the larger the value, the better. The preferred experimental parameters are: the batch size is set to 32, the training round is 1000, the optimizer uses AdamW, the initial value of the learning rate is set to 0.002, the learning rate is updated using warmup, and the learning rate is decayed according to the cosine function after the 5th round.

[0064] The experimental results of this example on classification are shown in Table 2. Compared with the current mainstream representation learning methods PatchTST and TimeMAE, this example has the best performance.

[0065] Table 2 Experimental results of this example on classification

[0066] Dataset This example PatchTST TimeMAE Computers 0.668 0.524 0.652 Electric Devices 0.639 0.509 0.508 ItalyPowerDemand 0.937 0.872 0.930 LargeKitchenAppliances 0.755 0.445 0.509

[0067] It should be noted that the time series data involved in the present invention may be time series data in the field of electricity. According to the actual task scenario, the original time series data is collected, and after preprocessing, a training sample training is constructed according to the method of the first embodiment to obtain a characterization model, which can be used for multi-task analysis of the corresponding scenario.

[0068] This method is proposed to solve the problem of learning the representation of electric power time series. In order to solve this problem, the key technology adopted by the present invention is to design a time-continuous data embedding layer structure and a hybrid context attention mechanism. 1) The time-continuous data embedding layer structure can convert the time series into a token containing multi-time granularity information on the basis of maintaining the temporal continuity of the time series; 2) The hybrid context attention mechanism can simultaneously learn the data information of long and short periods in the electric power time series, realize the mining of deep representations of the electric power time series, and adapt to various types of electric power time series in a certain scenario. This method can solve the problem of generalization in the field of electric power time series. When the electric power data field changes, the model performance often degrades, so it is necessary to enhance the generalization performance of the model. The present invention can solve the problem of learning the general representation of electric power time series. The time-continuous data embedding layer structure and the hybrid context attention mechanism can be used to fully learn the general representation of the electric power time series in the A data set, and the model can still play an efficient role in the application scenario where the B data set of different electric power data is located.

[0069] Embodiment 2

[0070] A power time series analysis method, comprising:

[0071] Using a hybrid context attention-based power time series representation method as described in the first embodiment above, a time series representation of the power time series data to be analyzed is obtained;

[0072] Based on the above time series representation, a time series analysis task is performed. For example, the extracted deep representation is input into the decoder to obtain the result of the corresponding time series analysis task.

[0073] The relevant technical solutions are the same as those in Embodiment 1 and Embodiment 2 and will not be described in detail here.

[0074] Embodiment 3

[0075] An electronic device includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, it implements a power time series characterization method based on hybrid contextual attention as described above and / or a power time series analysis method as described above.

[0076] The electronic device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The memory may be used to store computer programs and / or modules, and the processor may perform various functions of the electronic device by running or executing computer programs and / or modules stored in the memory, and calling data stored in the memory.

[0077] The relevant technical solutions are the same as those in Embodiment 1 and Embodiment 2 and will not be described in detail here.

[0078] Embodiment 4

[0079] A computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the computer program implements a power time series characterization method based on hybrid contextual attention as described above and / or a power time series analysis method as described above.

[0080] Specifically, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as a hard disk, an internal memory, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0081] The relevant technical solutions are the same as those in Embodiment 1 and Embodiment 2 and will not be described in detail here.

[0082] Embodiment 5

[0083] The present invention also provides a computer program product, including a computer program or instructions, which, when executed by a processor, implements a power time series characterization method based on hybrid contextual attention as described above and / or a power time series analysis method as described above.

[0084] The relevant technical solutions are the same as those in Embodiment 1 and Embodiment 2 and will not be described in detail here.

[0085] In general, the present invention provides a method for learning electric power time series representation based on hybrid contextual attention, which can learn the representation of electric power time series data by constructing a neural network. Starting from the diversity of electric power time series, this method proposes a time-continuous data embedding layer structure and a hybrid contextual attention mechanism, which can learn a more comprehensive electric power data representation without destroying the temporal continuity of the time series. Specifically, it can mine the deep representation of the electric power time series itself. For periodic data, it can better model the change relationship within and between data cycles, adapt to various types of time series, and make the process of learning electric power time series representation simpler and more efficient. The time series representation method proposed in the present invention can flexibly adjust the structure of the task-adapted decoder according to different task requirements, and is suitable for various types of electric power time series analysis tasks. It has a wider application scenario and saves computing resources.

[0086] It will be easily understood by those skilled in the art that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for representing power time series based on hybrid contextual attention, characterized in that: include: The data embedding layer is used to project the power time series data to be represented into the potential representation space to obtain the potential representation, and the potential representation is divided into multiple segments, each segment is used as a tag Token, and a sequence Token is obtained; Pooling the sequence token to summarize the information contained in multiple local sequences of the sequence token to obtain multiple summary features, which correspond to multiple main tags; All main tags are concatenated with all tag tokens, and an encoder is used to perform self-attention calculation on the concatenated results to obtain a deep representation, thereby completing the representation of the power time series. The self-attention calculation process can realize the following hybrid context attention calculation mechanism: the attention values ​​of the main tags corresponding to each local sequence are calculated respectively with the main tags corresponding to other local sequences, and at the same time, the attention values ​​of the main tags corresponding to all tag tokens are calculated respectively; the attention values ​​of each tag token are also calculated with other tag tokens in the local sequence where it is located and with tag tokens in other local sequences.

2. The power time series characterization method according to claim 1, characterized in that: Also includes: Initial power time series data is obtained and preprocessed.

3. The power time series characterization method according to claim 1, characterized in that: The network structure of each convolutional layer in the data embedding layer is: It includes multiple convolution blocks, a splicing unit and a computing unit; wherein the sizes of the convolution blocks are different and are used to capture data representations of different granularities; the splicing unit is used to splice multiple data representations of different granularities; the computing unit is used to average the splicing results of the splicing unit input by channel to obtain the overall representation of the convolution layer input data.

4. The power time series characterization method according to claim 1, characterized in that: The encoder is a Transformer encoder.

5. A method for analyzing power time series, characterized in that: include: Using a hybrid context attention-based power time series characterization method as described in any one of claims 1 to 4 to obtain a time series characterization of the power time series data to be analyzed; Based on the time series representation, an electric power time series analysis task is performed.

6. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, it implements a power time series characterization method based on hybrid contextual attention as described in any one of claims 1 to 4 and / or a power time series analysis method as described in claim 5.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, it implements a power time series characterization method based on hybrid contextual attention as described in any one of claims 1 to 4 and / or a power time series analysis method as described in claim 5.

8. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by the processor, it implements a power time series characterization method based on hybrid contextual attention as described in any one of claims 1 to 4 and / or a power time series analysis method as described in claim 5.