Time sequence anomaly detection method based on dynamic memory perception
By combining the U-Net model and the dynamic adaptive memory module, the problems of overfitting and insufficient discrimination ability of the existing Transformer model in photovoltaic power generation anomaly detection are solved, and efficient anomaly detection of photovoltaic power generation sequences is achieved.
Patent Information
- Application Number
- CN202511969769.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-24
- Publication Date
- 2026-05-19
AI Technical Summary
Existing Transformer-based models suffer from overfitting risks and insufficient discriminative ability in photovoltaic power generation anomaly detection. They are ill-suited to the dynamic and non-stationary characteristics of photovoltaic power generation sequences, resulting in limited ability to represent normal power generation patterns and low robustness and accuracy in anomaly detection.
The U-Net model is adopted, which combines multi-head self-attention and multi-head cross-attention. A dynamic adaptive memory module is introduced to record normal patterns through a dynamic memory pool, thereby enhancing the model's ability to represent global features and identify outliers in multivariate time series of photovoltaic power generation.
It significantly improves the model's ability to characterize non-stationary photovoltaic power generation sequences and its robustness in identifying outliers, thereby enhancing the accuracy and generalization ability of anomaly detection.
Smart Images

Figure CN122065203A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to time series anomaly detection networks, and in particular to a photovoltaic power generation anomaly detection method based on dynamic memory perception. Background Technology
[0002] Photovoltaic (PV) power generation, as a clean, renewable, and cost-effective energy source, holds significant potential for achieving energy transition and carbon neutrality goals. However, the PV power generation process is affected by various external factors, such as weather changes, irradiance fluctuations, and equipment malfunctions, posing a significant challenge to real-time monitoring and accurate prediction of PV power generation. Especially in data-driven prediction models, the reliability of the collected PV power generation data directly determines the model's performance and stability. When abnormal data is input into the model, it can lead to a significant decrease in the accuracy of deep learning prediction models. Therefore, introducing anomaly detection as a crucial preprocessing step before predicting PV power generation is essential.
[0003] Due to the complexity of anomalous patterns in photovoltaic (PV) systems and the scarcity of labeled anomalous samples, unsupervised learning methods aim to model the distribution of normal power generation data during the training phase and identify anomalous intervals deviating from this distribution during the inference phase. In recent years, deep learning-based unsupervised anomaly detection methods have been extensively studied, especially reconstruction-based methods such as autoencoders (AEs), variational autoencoders (VAEs), and generative adversarial networks (GANs), which have shown good potential in PV data anomaly detection. However, these methods generally suffer from overfitting to the training data distribution. Because PV power generation data patterns are highly variable and sensitive to noise, the models often lack generalization ability when faced with unseen operating states or sudden anomalies. Furthermore, insufficient discrimination between normal and anomalous points easily leads to anomalous points being reconstructed with low errors, especially when unlabeled anomalies are mixed into the training data. This problem is more severe, significantly weakening the reliability and robustness of PV power generation anomaly detection.
[0004] To address the aforementioned issues, the Transformer method, based on a self-attention mechanism, has been introduced into the field of photovoltaic (PV) power anomaly detection to better capture long-range dependencies and contextual relationships in PV power time series. Compared to traditional Recurrent Neural Networks (RNNs) and Convolutional Neural Networks (CNNs), Transformers offer stronger global modeling capabilities and parallel computing advantages in time series modeling. However, existing Transformer models still suffer from overfitting risks and insufficient discriminative power when handling diverse PV power generation sequences. Fixed-structure models struggle to adapt to the dynamic and non-stationary characteristics of PV sequences, limiting their ability to represent normal power generation patterns. Therefore, an improved Transformer anomaly detection method is urgently needed to enhance the model's generalization ability, strengthen the discrimination performance between normal and anomaly points, and adapt to the diversity and dynamic changes in PV power generation sequences, thereby achieving more robust and accurate anomaly detection. Summary of the Invention
[0005] The purpose of this invention is to provide a photovoltaic power generation anomaly detection method based on dynamic memory perception, thereby improving the accuracy of photovoltaic power generation anomaly detection.
[0006] This invention presents an innovative photovoltaic (PV) power generation anomaly detection method based on dynamic memory perception. The method proposes a dynamic memory perception-based PV power generation anomaly detection model. To achieve a flexible and universal model, convolutional smoothing and variable dimensionality increase operations are first performed on the multivariate time series of PV power generation. Then, the U-Net model is used to encode and decode the preprocessed PV power generation sequence for reconstruction. To enable the model to more effectively learn the feature distribution of normal data, this invention introduces multi-head self-attention and multi-head cross-attention into the encoder and decoder of the U-Net, respectively, to fully model the global feature representation of the multivariate time series, thereby enhancing the model's learning of the normal data distribution. Furthermore, to improve the model's ability to distinguish between normal and abnormal points, this invention proposes a dynamic adaptive memory module, which is injected into the skip connections of each layer of the U-Net. The output features of the encoder interact with the dynamic memory pool to record normal PV power generation patterns, accurately separating abnormal data points during the testing phase.
[0007] This invention includes the following steps: a time-series anomaly detection method based on dynamic memory perception, the method comprising the following steps:
[0008] (1) Perform data preprocessing on the photovoltaic power generation multivariate time series; perform linear interpolation on the missing values in the original series to avoid the missing values from seriously affecting the performance of the model of this invention, and perform data standardization on the multivariate time series;
[0009] (2) Obtain the preprocessed standardized multivariate time series data from step (1); process the standardized multivariate time series data... (B represents the batch size, T represents the sequence window length, and m represents the number of variables) Perform one-dimensional convolution smoothing and variable dimensionality increase operations to obtain a preliminary embedded multivariate time series representation. Where C represents the model embedding dimension, its mathematical expression is shown in formula (1):
[0010] S e =W((Conv 1D (S T )) T (1)
[0011] Among them, Conv 1D This represents a one-dimensional convolution operation. The superscript T indicates a linear transformation operation, and the superscript T indicates a matrix transpose operation.
[0012] (3) Obtain the embedded multivariate time series representation S from step (2). e A U-Net model was constructed, processed using a Transformer-based encoder-decoder and a dynamic adaptive memory module, and the original multivariate time series S was reconstructed. During the testing phase, normal and outlier data points were distinguished based on the reconstruction loss value.
[0013] (3.1) Constructing the U-Net model; the U-Net model consists of a multi-layer encoder and a multi-layer decoder. The multi-layer encoder is used to process the multivariate time series S. e Hierarchical feature distribution extraction is performed. Max pooling layers exist between layers to downsample the time series length. Multilayer decoders are used to recover the original time series from the latent distribution. One-dimensional convolutional layers between upper and lower layers are used to upsample the time series length accordingly. The encoder and decoder are connected through skip connections to pass the encoder's information to the decoder. Finally, the original multivariate time series is reconstructed through the output mapping layer. Its mathematical expressions are shown in formulas (2)-(5):
[0014]
[0015] Among them, Enc i and Dec i Let these represent the encoder layer and decoder layer of layer i, respectively. MaxPool represents the downsampling operation based on max pooling. Conv1D This represents an upsampling operation based on one-dimensional convolution, with the symbols → and ← representing the downsampled and upsampled features, respectively.
[0016] (3.2) Constructing a Transformer-based encoder-decoder; In order to fully capture the normal data distribution pattern of photovoltaic power generation multivariate time series, this invention uses the Transformer layer as the encoding and decoding layer of U-Net, wherein the encoder layer is composed of multi-head self-attention and feedforward network, and its mathematical expression is shown in formulas (6)-(9):
[0017]
[0018] F FF =LN(W2(ReLU(W1(F SA )))+F SA (9)
[0019] Where F represents the input features, W represents the linear transformation, and Q... j ,K j and V j Let F represent the query, key, and value vectors of the j-th attention head, respectively; H represents the number of attention heads; softmax represents the softmax activation function; Concat represents the feature concatenation operation; LN represents layer normalization; ReLU represents the ReLU activation function; and F... FF This represents the output features of the encoder layer. The decoder layer consists of a multi-head cross-attention network and a feedforward network. The mathematical expressions for multi-head cross-attention are shown in formulas (10)-(12):
[0020]
[0021] Where F1 and F2 represent two different input features, F CA The output features represent multi-head cross-attention;
[0022] (3.3) Constructing a dynamic adaptive memory module; To avoid interference from unlabeled abnormal power generation data in the training data on the modeling of normal power generation patterns, the dynamic adaptive memory module dynamically adjusts the memory terms according to the characteristic distribution of the photovoltaic power generation sequence to adapt to non-stationary time series (such as seasonal changes or trend drift), thereby improving the model's ability to model complex normal power generation patterns and distinguish abnormal data points. It takes the multi-scale time series features obtained from the multi-layer Transformer encoder as input and records the distribution pattern of normal points by interacting with the dynamic memory pool. Its mathematical expression is shown in formula (13):
[0023]
[0024] Among them, F e Indicates input features, Let P represent the output feature, P represent the dynamic memory pool, and the initial value is the cluster center of the input feature. `reshape` represents the dimension reshaping operation, `sim` represents the cosine similarity, and `softmax` represents the softmax activation function. To maintain the dynamic adaptability of the memory pool, the memory is dynamically updated using the input features, and its mathematical expression is shown in formula (14):
[0025] ΔP m =r·w k ·(F e -P m (14)
[0026] Among them, P m w represents the m-th memory in the pool. k Let ΔP represent the k-th weight in the cosine similarity matrix after softmax activation, r represent the update step size, and ΔP represent the weights. m Let w represent the update amount of the m-th memory. Given that some memories in the memory pool may become invalid during model training (w is very small), a selective forgetting mechanism is used to remove these invalid memories from the memory pool, and new memories are constructed based on the input features to replace them. The mathematical expressions for this are shown in formulas (15)-(17):
[0027] N P =FreCal(P) (15)
[0028] P = P[N] P >α] (16)
[0029]
[0030] Where FreCal represents the access frequency statistics operation, N P This represents the frequency with which each memory is accessed by the input feature. When the access frequency does not exceed the threshold α, it is considered an invalid memory and is deleted from the memory pool using formula (16). The number of clusters is ∑N P K-Means clustering algorithm with ≤α, where Concat represents the memory feature concatenation operation;
[0031] (4) Construct a photovoltaic power generation anomaly detection model based on dynamic memory perception, and train the model of this invention using photovoltaic power generation multivariate time series; In this invention, we use photovoltaic power dataset for experiments, the model is built based on the PyTorch framework, trained on NVIDIA RTX A6000 GPU, equipped with Intel i5 processor and Ubuntu system; the training process uses Adam optimizer for gradient update, the learning rate is 0.0001, and MSE loss is used as the training loss function;
[0032] (5) The model performance is evaluated based on three evaluation metrics: precision, recall, and F1 score. The mathematical expressions are shown in formulas (18)-(20):
[0033]
[0034] In this context, PR, RC, and F1 represent precision, recall, and F1 score, respectively, while TP, FP, and FN represent true positives, false positives, and false negatives, respectively.
[0035] Compared with the prior art, the advantages of the present invention are as follows:
[0036] ◆This invention combines U-Net with a Transformer encoder-decoder to achieve multi-element photovoltaic power generation.
[0037] The system models the global dependencies of time series and introduces a dynamic adaptive memory module to dynamically capture and remember normal patterns. Compared with traditional anomaly detection methods that rely solely on static features, this significantly enhances the ability to identify anomalies in non-stationary sequences.
[0038] ◆The dynamic adaptive memory module effectively captures photovoltaic power generation data through interaction with the multi-scale output features of the encoder.
[0039] The module identifies the normal patterns of photovoltaic multivariate time series, thereby suppressing the interference of missing values and noise on the representation during feature modeling. At the same time, the module maintains the adaptability of the memory pool through selective forgetting and dynamic update mechanisms, enabling it to adaptively adjust with the seasonal fluctuations and trend drift of the sequence, significantly improving the model's ability to represent complex non-stationary photovoltaic power generation patterns and its robustness in identifying outliers. Attached Figure Description
[0040] Figure 1 This is a flowchart of the steps of the present invention;
[0041] Figure 2 This is a schematic diagram of the framework of a photovoltaic power generation anomaly detection model based on dynamic memory perception.
[0042] Figure 3 This is a schematic diagram of the encoder Transformer layer structure;
[0043] Figure 4 This is a schematic diagram of the Transformer layer structure of the decoder;
[0044] Figure 5 This is a schematic diagram of the structure of a dynamic adaptive memory module. Detailed Implementation
[0045] The technical solution of the present invention will be further described below with reference to the accompanying drawings.
[0046] Example: A photovoltaic power generation anomaly detection method based on dynamic memory perception. The innovation mainly consists of three parts: First, the U-Net model is used to encode and decode the multivariate time series of photovoltaic power generation, and normal points and anomalies are distinguished by reconstructing the original time series; Second, multi-head self-attention and multi-head cross-attention are introduced into the encoder and decoder respectively to fully and effectively model the normal power generation patterns in the photovoltaic power generation sequence; Third, a dynamic adaptive memory module is proposed, which is injected into the skip connections of each layer of U-Net. The output features of the encoder record the normal power generation patterns by interacting with the dynamic memory pool, so as to accurately separate anomalies during the testing phase.
[0047] like Figure 1 As shown, the present invention includes the following steps:
[0048] Step (1): Perform data preprocessing on the photovoltaic power generation sequence; perform linear interpolation on the missing values in the sequence to avoid the missing values from seriously affecting the performance of the model of this invention, and perform data standardization on the sequence;
[0049] Step (1.1): First, a one-dimensional linear interpolation algorithm is used for each variable in the photovoltaic power generation sequence to fill in any missing values. The mathematical expression is shown in formula (1):
[0050]
[0051] Among them, S i (t) represents the value of the i-th variable in the photovoltaic power generation sequence S at time t, which is based on the existing data S. i (t k ) and S i (t k+1 Perform interpolation calculations;
[0052] Step (1.2): Perform data standardization on the photovoltaic power generation sequence data, as shown in formula (2):
[0053]
[0054] Where S represents the original value of the photovoltaic power generation sequence, min(S) and max(S) represent the minimum and maximum vectors calculated by variables in the training sequence, and ∈ is a very small constant vector to prevent the denominator from being 0. norm This represents the standardized multivariate time series of photovoltaic power generation.
[0055] Step (2): Obtain the preprocessed standardized multivariate time series data S from step (1) (here, for convenience, S represents the multivariate time series processed by steps (1.1) and (1.2)); process the standardized multivariate time series... (B represents the batch size, T represents the sequence window length, and m represents the number of variables) Perform one-dimensional convolution smoothing and variable dimensionality increase operations to obtain a preliminary embedded multivariate time series representation. Where C represents the model embedding dimension, and its mathematical expression is shown in formula (3):
[0056] S e =W((Conv 1D (S T )) T (3)
[0057] Among them, Conv 1D This represents a one-dimensional convolution operation. The superscript T indicates a linear transformation operation, and S indicates a matrix transpose operation. e The input to the encoder will be used for subsequent encoding and decoding reconstruction.
[0058] Step (3): Obtain the embedded multivariate time series representation S from step (2). e A U-Net model was constructed, and a Transformer-based encoder-decoder and dynamic adaptive memory module were used to process it, reconstructing the original multivariate time series S. During the testing phase, normal and abnormal points in the photovoltaic power generation sequence were distinguished based on the reconstruction loss value.
[0059] Step (3.1): Construct the U-Net model; the U-Net model consists of a multi-layer encoder and a multi-layer decoder. The multi-layer encoder is used to process the multivariate time series S. e Hierarchical feature distribution extraction is performed. Max pooling layers exist between layers to downsample the time series length. Multilayer decoders are used to recover the original time series from the latent distribution. One-dimensional convolutional layers between upper and lower layers are used to upsample the time series length accordingly. The encoder and decoder are connected through skip connections to pass the encoder's information to the decoder. Finally, the original multivariate time series is reconstructed through the output mapping layer. Its mathematical expressions are shown in formulas (4)-(8):
[0060]
[0061] Among them, Enc i and Dec i These represent the encoder and decoder layers of the i-th layer, respectively. MaxPool represents the downsampling operation based on max pooling, used to halve the sequence length. Conv 1D This represents an upsampling operation based on one-dimensional convolution, used to recover the sequence length. The symbols → and ← represent the downsampled and upsampled features, respectively. and ReLU represents the linear transformation of the output mapping layer, and ReLU represents the ReLU activation function. Represents the reconstructed multivariate time series output by the model;
[0062] Step (3.2) Constructing a Transformer-based encoder-decoder; In order to fully capture the normal power generation mode in the photovoltaic power generation sequence, this invention uses the Transformer layer as the encoder-decoder layer of U-Net to examine the entire sequence features from a global perspective. The encoder layer consists of a multi-head self-attention network and a feedforward network, and its mathematical expression is shown in formulas (9)-(12):
[0063]
[0064] F FF =LN(W2(ReLU(W1(F SA )))+F SA (12) Among them, Let W represent the input features, and W represent the linear transformation. Let represent the query, key, and value vectors of the j-th attention head, respectively; H represents the number of attention heads; softmax represents the softmax activation function; Concat represents the feature concatenation operation; LN represents layer normalization; and ReLU represents the ReLU activation function. This represents the output features of the encoder layer. The decoder layer consists of a multi-head cross-attention network and a feedforward network. The mathematical expressions for multi-head cross-attention are shown in formulas (13)-(15):
[0065]
[0066] in, This represents two different input features. The output features represent multi-head cross-attention;
[0067] Step (3.3) Build a dynamic adaptive memory module; to avoid interference from unlabeled outliers in the training data that might interfere with the model's modeling of normal power generation patterns, the dynamic adaptive memory module dynamically adjusts the memory terms according to the feature distribution of the time series to adapt to non-stationary time series (such as seasonal changes or trend drift), thereby improving the model's ability to model complex normal patterns and distinguish outliers. It takes the multi-scale time series features obtained from the multi-layer Transformer encoder as input and records the distribution pattern of normal points by interacting with the dynamic memory pool. Its mathematical expression is shown in formula (16):
[0068]
[0069] in, Indicates input features, Indicates output features, This represents a dynamic memory pool, where M represents the number of memories, initialized to the cluster centers of the input features, and reshape represents the dimension reshaping operation used to reshape the memory pool with dimensions of 1. The input features are reshaped into The features are sim, cosine similarity, and softmax, softmax activation function. To maintain the dynamic adaptability of the memory pool, the memory is dynamically updated using the input features, and its mathematical expression is shown in formula (17):
[0070] ΔP m =r·w k ·(F e -P m (17)
[0071] in, w represents the m-th memory in the pool. k This represents the k-th weight in the cosine similarity matrix after softmax activation, and r represents the update step size. Let w represent the update amount of the m-th memory. Given that some memories in the memory pool may become invalid during model training (w is very small), a selective forgetting mechanism is used to remove these invalid memories from the memory pool, and new memories are constructed based on the input features to replace them. The mathematical expressions for this are shown in formulas (18)-(20):
[0072] N P =FreCal(P) (18)
[0073] P = P[N] P >α] (19)
[0074]
[0075] FreCal represents the access frequency statistics operation. This represents the frequency with which each memory is accessed by the input feature. When the access frequency does not exceed the threshold α, it is considered an invalid memory and is deleted from the memory pool using formula (16). The number of clusters is ∑N P K-Means clustering algorithm with ≤α, where Concat represents the memory feature concatenation operation;
[0076] Step (4): Construct a photovoltaic power generation anomaly detection model based on dynamic memory perception, and train the model of this invention using photovoltaic power generation multivariate time series data; In this invention, we use a photovoltaic power dataset for experiments, the model is built on the PyTorch framework, trained on an NVIDIA RTX A6000 GPU equipped with an Intel i5 processor and Ubuntu system; The training process uses the Adam optimizer for gradient updates, the learning rate is 0.0001, and the MSE loss is used as the training loss function, the mathematical expression of which is shown in formula (21):
[0077]
[0078] Where S represents the original multivariate time series, This represents the multivariate time series after model encoding and decoding reconstruction;
[0079] Step (5): The model performance is evaluated based on three evaluation metrics: precision, recall, and F1 score. The mathematical expressions are shown in formulas (22)-(24):
[0080]
[0081] In this context, PR, RC, and F1 represent precision, recall, and F1 score, respectively; TP, FP, and FN represent true positives, false positives, and false negatives, respectively. PR calculates the proportion of samples predicted as outliers by the model that are actually outliers. RC calculates the proportion of samples correctly identified as outliers by the model. F1 represents the harmonic mean of precision and recall.
[0082] The model parameters were trained on the training set of the photovoltaic power generation dataset using the existing state-of-the-art time series anomaly detection methods (LSTM-AE, USAD, AnomalyTransformer, DCDetector, and AMFormer) and the photovoltaic power generation anomaly detection method based on dynamic memory perception proposed in this patent (Ours). The prediction precision, recall, and F1 score of each method were then evaluated on the test set. The experimental results are shown in Table 1.
[0083] Table 1: Experimental Results of Photovoltaic Power Generation Anomaly Detection
[0084]
[0085]
[0086] Analysis of Table 1 shows that the method proposed in this patent has significantly improved the anomaly detection index on the photovoltaic power dataset compared with existing anomaly detection methods. It is 3.11%, 3.06%, and 3.09% higher than the second-best method AMFormer in the three evaluation indicators of PR, RC, and F1, respectively. This indicates that the method proposed in this patent can effectively capture the complex photovoltaic power generation patterns in the training distribution through dynamic memory perception and global context modeling of Transformer, and thus accurately detect abnormal regions that deviate from the normal power generation pattern during the testing phase.
[0087] It should be noted that the above embodiments are not intended to limit the scope of protection of the present invention. Equivalent transformations or substitutions made based on the above technical solutions all fall within the scope of protection of the claims of the present invention.
Claims
1. A time-series anomaly detection method based on dynamic memory perception, characterized in that, The method includes the following steps: (1) Perform data preprocessing on the photovoltaic power generation multivariate time series; perform linear interpolation on the missing values in the original series to avoid the missing values from seriously affecting the performance of the model of this invention, and perform data standardization on the multivariate time series; (2) Obtain the preprocessed standardized multivariate time series data from step (1); (3) Obtain the embedded multivariate time series representation S from step (2). e We constructed a U-Net model, processed it using a Transformer-based encoder-decoder and a dynamic adaptive memory module, and reconstructed the original multivariate time series S. During the testing phase, we distinguished normal data points from abnormal data points based on the reconstruction loss value. (4) Construct a photovoltaic power generation anomaly detection model based on dynamic memory perception, and train the model of this invention using photovoltaic power generation multivariate time series. (5) The model performance is evaluated based on three evaluation metrics: precision, recall and F1 score.
2. The time series anomaly detection method based on dynamic memory perception according to claim 1, characterized in that, Step (1): Perform data preprocessing on the photovoltaic power generation sequence, as follows: Step (1.1): First, use a one-dimensional linear interpolation algorithm for each variable in the photovoltaic power generation sequence to fill in any missing values, as detailed below. Among them, S i (t) represents the value of the i-th variable in the photovoltaic power generation sequence S at time t, which is based on the existing data S. i (t k ) and S i (t k+1 Perform interpolation calculations; Step (1.2): Perform data standardization processing on the photovoltaic power generation sequence data, as follows: Where S represents the original value of the photovoltaic power generation sequence, min(S) and max(S) represent the minimum and maximum vectors calculated by variables in the training sequence, and ∈ is a very small constant vector to prevent the denominator from being 0. norm This represents the standardized multivariate time series of photovoltaic power generation.
3. The time series anomaly detection method based on dynamic memory perception according to claim 2, characterized in that, Step (2) is as follows: Obtain the preprocessed standardized multivariate time series data from step (1); process the standardized multivariate time series data... One-dimensional convolution smoothing and variable dimensionality increase operations are performed, where B represents the batch size, T represents the sequence window length, and m represents the number of variables, to obtain a preliminary embedded multivariate time series representation. Where C represents the model embedding dimension, its mathematical expression is shown in formula (1): S e =W((Conv 1D (S T )) T ) (1) Among them, Conv 1D This represents a one-dimensional convolution operation. The superscript T indicates a linear transformation operation, and the superscript T indicates a matrix transpose operation.
4. The time series anomaly detection method based on dynamic memory perception according to claim 3, characterized in that, Step (3) is as follows: (3.1) Constructing the U-Net model; the U-Net model consists of a multi-layer encoder and a multi-layer decoder. The multi-layer encoder is used to process the multivariate time series S. e Hierarchical feature distribution extraction is performed. Max pooling layers exist between layers to downsample the time series length. Multilayer decoders are used to recover the original time series from the latent distribution. One-dimensional convolutional layers between upper and lower layers are used to upsample the time series length accordingly. The encoder and decoder are connected through skip connections to pass the encoder's information to the decoder. Finally, the original multivariate time series is reconstructed through the output mapping layer. Its mathematical expressions are shown in formulas (2)-(5): Among them, Enc i and Dec i Let these represent the encoder layer and decoder layer of layer i, respectively. MaxPool represents the downsampling operation based on max pooling. Conv 1D This represents an upsampling operation based on one-dimensional convolution, with the symbols → and ← representing the downsampled and upsampled features, respectively. (3.2) Constructing a Transformer-based encoder-decoder; In order to fully capture the normal data distribution pattern of photovoltaic power generation multivariate time series, the Transformer layer is used as the encoder-decoder layer of U-Net, wherein the encoder layer is composed of multi-head self-attention and feedforward network, and its mathematical expression is shown in formulas (6)-(9): F FF =LN(W2(ReLU(W1(F SA )))+F SA ) (9) Where F represents the input features, W represents the linear transformation, and Q... j ,K j and V j Let F represent the query, key, and value vectors of the j-th attention head, respectively; H represents the number of attention heads; softmax represents the softmax activation function; Concat represents the feature concatenation operation; LN represents layer normalization; ReLU represents the ReLU activation function; and F... FF The encoder layer represents the output features. The decoder layer consists of a multi-head cross-attention network and a feedforward network. The mathematical expressions for multi-head cross-attention are shown in formulas (10)-(12): Where F1 and F2 represent two different input features, F CA The output features represent multi-head cross-attention; (3.3) Constructing a dynamic adaptive memory module; In order to avoid interference from unlabeled abnormal power generation data in the training data on the modeling of normal power generation mode, the dynamic adaptive memory module dynamically adjusts the memory terms according to the characteristic distribution of photovoltaic power generation sequence to adapt to non-stationary time series, improve the model's ability to model complex normal power generation mode and distinguish abnormal data points. It takes the multi-scale time series features obtained from the multi-layer Transformer encoder as input and records the distribution pattern of normal points by interacting with the dynamic memory pool. Its mathematical expression is shown in formula (13): Among them, F e Indicates input features, Let P represent the output feature, P represent the dynamic memory pool, and the initial value is the cluster center of the input feature. Let reshape represent the dimension reshaping operation, sim represent the cosine similarity, and softmax represent the softmax activation function. In order to maintain the dynamic adaptability of the memory pool, the memory is dynamically updated using the input features. Its mathematical expression is shown in formula (14): ΔP m =r·w k ·(F e -P m ) (14) Among them, P m w represents the m-th memory in the pool. k Let ΔP represent the k-th weight in the cosine similarity matrix after softmax activation, r represent the update step size, and ΔP represent the weights. m Let m represent the update amount of the m-th memory. These invalid memories are deleted from the memory pool using a selective forgetting mechanism, and new memories are constructed to replace them based on the input features. The mathematical expressions are shown in formulas (15)-(17): N P =FreCal(P) (15) P=P[N P >a] (16) Where FreCal represents the access frequency statistics operation, N P This represents the frequency with which each memory is accessed by the input feature. When the access frequency does not exceed the threshold α, it is considered an invalid memory and is deleted from the memory pool using formula (16). The number of clusters is ∑N P The K-Means clustering algorithm for ≤α, where Concat represents the memory feature concatenation operation.
5. The time series anomaly detection method based on dynamic memory perception according to claim 4, characterized in that, Step (4) is as follows: the photovoltaic power dataset is used for the experiment, the model is built based on the PyTorch framework, and trained on the NVIDIA RTX A6000 GPU, equipped with an Intel i5 processor and Ubuntu system. The Adam optimizer is used for gradient updates during training, with a learning rate of 0.0001 and MSE loss as the training loss function.
6. The time series anomaly detection method based on dynamic memory perception according to claim 2, characterized in that, (5) The model performance is evaluated based on three evaluation metrics: precision, recall, and F1 score. The mathematical expressions are shown in formulas (18)-(20): In this context, PR, RC, and F1 represent precision, recall, and F1 score, respectively, while TP, FP, and FN represent true positives, false positives, and false negatives, respectively.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the time series anomaly detection method based on dynamic memory perception as described in any one of claims 1 to 6.
8. A computer-readable storage medium storing computer instructions thereon, characterized in that, When executed by the processor, the computer instructions implement the time series anomaly detection method based on dynamic memory awareness as described in any one of claims 1-6.