Time series anomaly detection method based on fast Fourier transform and masked convolution
By converting one-dimensional time series data into two-dimensional data and combining it with masked convolution and channel attention mechanisms, the shortcomings of traditional methods in long-term dependency modeling are solved, more efficient time series data anomaly detection is achieved, and the accuracy and robustness of detection are improved.
Patent Information
- Application Number
- CN202310963097.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-02
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2043-08-02
AI Technical Summary
Traditional anomaly detection methods for time series data are ineffective in modeling long-term dependencies, have difficulty capturing complex anomaly patterns, and lack robustness and accuracy.
A method based on fast Fourier transform and masked convolution is used to convert one-dimensional time series data into two-dimensional data. Masked convolution and channel attention mechanism are combined for feature extraction. Residual connection and discriminator are used for training optimization. Generator and discriminator perform adversarial learning, and data anomalies are judged through anomaly classification.
It improves the accuracy and robustness of time series data anomaly detection, can better capture complex abnormal patterns, reduce computational complexity, and enhance the model's generalization ability and feature expression capabilities.
Smart Images

Figure CN117033933B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data anomaly detection, and in particular to a time series anomaly detection method based on fast Fourier transform and masked convolution. Background Art
[0002] Anomaly detection in time series data is a key data mining technique widely used in various fields to address the monitoring and prediction of anomalies. With the rise of big data and the rapid development of information technology, the acquisition and storage of time series data, which contains time-related observations such as sensor data, transaction records, and network traffic, has become easier and more efficient. However, time series data often contains outliers or abnormal values. These outliers may be caused by equipment failures, sabotage, abnormal transactions, or emergencies.
[0003] Time series data anomaly detection plays an important role in many fields. For example, in the manufacturing industry, real-time monitoring of parameter data in the production process can help detect equipment failures early, avoid production line downtime and reduce product quality; in the financial field, time series data anomaly detection is crucial for discovering potential fraud, abnormal transactions and risk control; in the field of network security, time series data anomaly detection can promptly detect threats such as network attacks, intrusions and malware, and protect the security of networks and data; in the field of medical health, time series data anomaly detection can assist doctors in detecting patients' physiological abnormalities early and improve disease diagnosis and treatment effects.
[0004] Traditional methods for detecting anomalies in time series data typically use one-dimensional convolution or recurrent neural networks for modeling. However, due to the local nature of the one-dimensional convolution kernel, one-dimensional convolution can only model changes between adjacent time points and is therefore ineffective in modeling long-term dependencies. Recurrent neural networks (such as RNNs) can model dependencies between consecutive time points, but due to the limitations of the Markov assumption, these methods often struggle to capture long-term dependencies. Summary of the Invention
[0005] In order to overcome at least one deficiency in the prior art, the present application provides a time series anomaly detection method based on fast Fourier transform and masked convolution.
[0006] In a first aspect, a time series anomaly detection method based on fast Fourier transform and masked convolution is provided, comprising:
[0007] Obtain the time series data to be detected;
[0008] The time series data to be detected is input into the trained anomaly detection model to obtain an anomaly score. The anomaly detection model includes a generator and an anomaly score calculation module. The generator includes multiple data reconstruction modules using residual connections. The generator is used to output reconstructed data based on the time series data to be detected. The anomaly score calculation module is used to calculate the error between the reconstructed data and the time series data to be detected to obtain an anomaly score.
[0009] Determine whether the anomaly score is greater than the discrimination threshold. If so, the time series data to be detected is abnormal data; if not, the time series data to be detected is normal data.
[0010] In one embodiment, the data reconstruction module includes a fast Fourier transform module, n feature extraction branches and a reconstruction unit, each feature extraction branch includes a first shaping unit, a feature extraction unit and a second shaping unit;
[0011] The fast Fourier transform module is used to perform fast Fourier transform on the input data to obtain frequency domain data, and determine n significant frequencies and their corresponding n amplitudes in the frequency domain data; determine n period values based on the n significant frequencies, and each period value corresponds to a feature extraction branch;
[0012] The first shaping unit is used to shape the input data into two-dimensional data according to the corresponding period value;
[0013] The feature extraction unit is used to extract features from the two-dimensional data to obtain two-dimensional feature data;
[0014] The second shaping unit is used to shape the two-dimensional feature data into one-dimensional feature data;
[0015] The reconstruction unit is used to convert n amplitudes into n weights based on the Softmax function; and perform weighted summation on all one-dimensional feature data obtained by the n feature extraction branches based on the n weights to generate a reconstruction result.
[0016] In one embodiment, the feature extraction unit is a self-supervised prediction convolution attention block, which includes a mask convolution module and a channel attention module; the mask convolution module is used to perform a mask convolution operation on the two-dimensional data to obtain mask data; the channel attention module is used to automatically learn the correlation between different channels in the feature based on the mask data; the feature extraction unit is also used to multiply the mask data and the output of the channel attention module to obtain two-dimensional feature data.
[0017] In one embodiment, the residual connection is expressed by the following formula:
[0018] X k =AD Block(X k-1 )+X k-1 , k=2,…K
[0019] X1=AD Block(X0)
[0020] Among them, X k is the output of the kth data reconstruction module, AD Block is the data reconstruction module, X k-1 is the output of the k-1th data reconstruction module, K is the number of data reconstruction modules; X0 is the time series data to be detected.
[0021] In one embodiment, the anomaly detection model also includes a discriminator during the training process; the discriminator uses a multi-layer convolutional neural network structure to judge the original data and the data generated by the generator, and the trained generator is obtained through continuous confrontation and iterative optimization between the generator and the discriminator during the training process.
[0022] In one embodiment, the loss function used in the training process of the anomaly detection model is:
[0023]
[0024] Among them, L GAN is the loss function, E is the expectation, p data (x) represents the distribution of the real data sample x, D is the discriminator function, and G is the generator function.
[0025] In a second aspect, a time series anomaly detection device based on fast Fourier transform and masked convolution is provided, comprising:
[0026] A data acquisition module is used to obtain time series data to be detected;
[0027] The anomaly score acquisition module is used to input the time series data to be detected into the trained anomaly detection model to obtain an anomaly score. The anomaly detection model includes a generator and an anomaly score calculation module. The generator includes multiple data reconstruction modules using residual connections. The generator is used to output reconstructed data based on the time series data to be detected. The anomaly score calculation module is used to calculate the error between the reconstructed data and the time series data to be detected to obtain an anomaly score.
[0028] The judgment module is used to judge whether the anomaly score is greater than the discrimination threshold. If so, the time series data to be detected is abnormal data; if not, the time series data to be detected is normal data.
[0029] In a third aspect, a computer-readable storage medium is provided, which stores a computer program. When the computer program is executed by a processor, it implements the above-mentioned time series anomaly detection method based on fast Fourier transform and mask convolution.
[0030] In a fourth aspect, a computer program product includes a computer program / instruction, which, when executed by a processor, implements the above-mentioned time series anomaly detection method based on fast Fourier transform and masked convolution.
[0031] Compared to existing technologies, this application offers the following advantages: The proposed method for detecting anomalies in time series data based on fast Fourier transforms and masked convolutions transforms one-dimensional time series data into a two-dimensional space, then extracts features using masked convolution and a channel attention mechanism. This method provides more comprehensive and accurate anomaly detection. Compared to traditional methods, this method is better able to capture complex anomaly patterns in time series data and exhibits greater robustness and accuracy, providing a more reliable and efficient solution for applications such as data analysis, fault diagnosis, and anomaly detection in various fields. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] The present application may be better understood by referring to the following description in conjunction with the accompanying drawings, which together with the following detailed description are incorporated into and form a part of this specification. In the drawings:
[0033] Figure 1 A flowchart of a time series anomaly detection method based on fast Fourier transform and mask convolution according to an embodiment of the present application is shown;
[0034] Figure 2 shows a schematic diagram of an anomaly detection model;
[0035] Figure 3 shows a schematic diagram of a data reconstruction module AD Block;
[0036] Figure 4 shows a schematic diagram of the feature extraction unit SSPCAB Block;
[0037] Figure 5 The figure shows a structural block diagram of a time series anomaly detection device based on fast Fourier transform and mask convolution according to an embodiment of the present application. DETAILED DESCRIPTION
[0038] Exemplary embodiments of the present application are described below with reference to the accompanying drawings. For the sake of clarity and conciseness, not all features of actual embodiments are described in this specification. However, it should be understood that in the process of developing any such actual embodiment, many implementation-specific decisions may be made to achieve the developer's specific goals, and these decisions may vary from one implementation to another.
[0039] It is also necessary to explain here that, in order to avoid obscuring the present application due to unnecessary details, the accompanying drawings only show the device structure closely related to the solution according to the present application, while other details that are not closely related to the present application are omitted.
[0040] It should be understood that the present application is not limited to the described embodiments due to the following description with reference to the accompanying drawings. In this document, where feasible, the embodiments may be combined with each other, features between different embodiments may be replaced or borrowed, and one or more features may be omitted in one embodiment.
[0041] The present invention provides a time series anomaly detection method based on fast Fourier transform and mask convolution. Figure 1 A flowchart of a time series anomaly detection method based on fast Fourier transform and mask convolution according to an embodiment of the present application is shown. Figure 1 , methods include:
[0042] Step S11, obtaining time series data to be detected;
[0043] Step S12: input the time series data to be detected into the trained anomaly detection model to obtain anomaly scores; Figure 2 A schematic diagram of anomaly detection model is shown in Figure 2 The anomaly detection model includes a generator and an anomaly score calculation module. The generator includes multiple data reconstruction modules AD Block using residual connections. The generator is used to output reconstructed data based on the time series data to be detected; the anomaly score calculation module is used to calculate the error between the reconstructed data and the time series data to be detected to obtain the anomaly score. Here, the residual connection is expressed by the following formula:
[0044] X k =AD Block(X k-1 )+X k-1 , k=2,...K
[0045] X1=AD Block(X0)
[0046] Among them, X k is the output of the kth data reconstruction module, AD Block is the data reconstruction module, X k-1 is the output of the k-1th data reconstruction module, K is the number of data reconstruction modules; X0 is the time series data to be detected.
[0047] Here, the reconstructed data output by the generator is the output of the last data reconstruction module AD Block.
[0048] Step S13, judging whether the abnormality score is greater than the discrimination threshold, if so, the time series data to be detected is abnormal data, otherwise, the time series data to be detected is normal data.
[0049] In this embodiment, the AD Block is connected by the residual connection method, which can solve the gradient vanishing problem and make it easier for the gradient to be passed back to the earlier layer, thereby avoiding the situation where the gradient gradually decreases in the deep network, which helps to accelerate the convergence of the model. At the same time, the residual connection allows direct information flow. Adding the output of the previous layer to the input of the current layer can effectively transmit information; this jump connection method can help information be transmitted to subsequent layers faster, thereby improving the information transmission efficiency of the network. And deep networks are prone to overfitting training data. Through residual connections, the model can more easily learn the residual part because it only needs to learn relatively small changes, rather than the complete mapping. This helps to alleviate the overfitting problem and improve the generalization ability of the model.
[0050] In one embodiment, Figure 3 A schematic diagram of the data reconstruction module AD Block is shown, see Figure 3 The data reconstruction module AD Block includes a fast Fourier transform module FFT Module, n feature extraction branches and a reconstruction unit, each feature extraction branch includes a first reshaping unit Reshape, a feature extraction unit SSPCAB Block and a second reshaping unit Reshape Back;
[0051] The Fast Fourier Transform (FFT) Module is used to perform a Fast Fourier Transform on the input data to obtain frequency domain data, and determine n significant frequencies and their corresponding n amplitudes in the frequency domain data; n period values are determined based on the n significant frequencies, and each period value corresponds to a feature extraction branch; here, n can be 5, which is the set value.
[0052] The first reshaping unit, Reshape, is used to reshape the input data into two-dimensional data according to the corresponding period value. Here, all frequency components of the input data from the DC component to the highest positive frequency can be obtained. Each frequency component is represented by a complex value, the real part represents the amplitude of the frequency component, and the imaginary part represents the phase of the frequency component. After selecting the first n significant frequencies by amplitude, the n period values of the time series data can be obtained. The input data is reshaped into two-dimensional data according to these n periods. Specifically, the input data is divided into several periods. For example, if the period value is 10, the input data is divided into 10 periods. The reshaping formula can be:
[0053] X 2D =Reshape(Padding(X 1D ))
[0054] Among them, X 2D For two-dimensional data, Reshape is the first reshaping unit. Padding is an operation that adds additional boundary values after the input data to ensure that the size of the input data meets the requirements of the network. 1D Here, for the first data reconstruction module AD Block, the input data X 1D For the time series data to be detected, for the second data reconstruction module AD Block, input data X 1D It is the output of the first data reconstruction module AD Block.
[0055] The feature extraction unit SSPCAB Block is used to extract features from two-dimensional data to obtain two-dimensional feature data;
[0056] The second reshaping unit Reshape Back is used to reshape the two-dimensional feature data into one-dimensional feature data;
[0057] The reconstruction unit is used to convert n amplitudes into n weights based on the Softmax function; and based on the n weights, all one-dimensional feature data obtained by the n feature extraction branches are weighted summed to generate a reconstruction result. Here, the reconstruction result can be expressed as follows:
[0058]
[0059] w1,w2,...,w n =Softmax(A1,A2,...,A n )
[0060] Among them, X 1D ′ is the reconstruction result, Represents n one-dimensional feature data, w1,w2,...,w n Represent n weights respectively. A1,A2,...,A n Represent n amplitudes respectively.
[0061] In one embodiment, Figure 4 Shows a schematic diagram of the feature extraction unit SSPCAB Block, see Figure 4 , the feature extraction unit SSPCAB Block is a self-supervised prediction convolution attention block, which includes a masked convolution module Masked Conv Module and a channel attention module Channel Attention Module; the masked convolution module Masked Conv Module is used to perform two-dimensional data x 2D Perform mask convolution operation to obtain mask data x 2D-maskThe channel attention module is used to automatically learn the correlation between different channels in the feature according to the mask data; the feature extraction unit is also used to multiply the mask data and the output of the channel attention module to obtain the two-dimensional feature data x2 ′ D .
[0062] Specifically, the channel attention module includes a fully connected layer FC, a ReLU activation function, a fully connected layer FC, and a Sigmoid activation function connected in sequence.
[0063] In the above embodiment, compared to traditional convolution that only focuses on feature extraction in a local neighborhood, the masked convolution of this embodiment can better utilize global context information. By splitting the input and performing multiple convolution operations, masked convolution can obtain more global context features, thereby better understanding the overall semantics and structure. At the same time, by performing convolution and addition operations on inputs in different regions, masked convolution can more fully utilize the input information and integrate local features into global features, which can improve feature expression capabilities and make the model more accurate in predicting or reconstructing masked information. And because masked convolution can utilize global context information, it is more robust to noise and missing information. Even if there is a certain amount of noise or partial information missing in the input, masked convolution can reduce the impact through overall feature extraction and better predict or reconstruct the masked information. And because masked convolution only performs convolution operations on the visible part, it can reduce the number of locations that need to be calculated compared to traditional convolution. This is particularly useful for data with large areas of occlusion or shielding, which can reduce computational complexity and accelerate the training and inference process of the model.
[0064] Furthermore, channel attention is a type of attention mechanism used to improve model performance. It is primarily used in convolutional neural networks (CNNs) to automatically learn the correlations between different channels in a feature map, enhancing useful features and suppressing useless ones. The channel attention mechanism is implemented by introducing an attention module that weights each channel in the feature map based on its importance. Specifically, channel attention calculates the importance weight of each channel and multiplies it with the original feature map, thereby enhancing useful features and suppressing useless ones. Time series data often exhibits temporal correlations and patterns. Channel attention helps the model automatically learn the correlations between different channels in the data and extract useful time series features for time series reconstruction. By weighting the features, the model can better focus on important time series features, thereby improving the accuracy of time series data reconstruction. At the same time, time series data may contain some useless or redundant time series features. Channel attention can identify and suppress these useless time series feature channels, reducing the interference of meaningless noise on time series data reconstruction. This allows the model to focus more on important time series features, thereby improving the quality of time series data reconstruction.
[0065] In one embodiment, the anomaly detection model also includes a discriminator during the training process; the discriminator uses a multi-layer convolutional neural network structure to judge the original data and the data generated by the generator. Through the continuous confrontation and iterative optimization of the generator and the discriminator during the training process, a trained generator is obtained. The trained generator and the anomaly score calculation module constitute the trained anomaly detection model. Here, the discriminator D is mainly composed of a multi-layer convolutional neural network and a layer of Sigmoid function. By stacking multiple convolutional layers, the discriminator can learn more complex and abstract feature representations, thereby improving the ability to distinguish between real samples and generated samples. Here, LeakyReLU is used as the activation function in the convolution process to avoid the dead neuron problem of ReLU. At the same time, Batch Normalization is performed on the parameters of each layer, so that the distribution of the hidden layer data in the middle of the model is relatively stable, reducing the model's dependence on the underlying network and improving the training speed of the entire neural network.
[0066] Here, the discriminator uses a multi-layer convolutional neural network structure to judge the original data x and the generated data G(x). Through the continuous competition and iterative optimization of the generator and discriminator during the training process, the model can eventually learn the characteristics of normal data. Normal data can be well learned and reconstructed by the model, while abnormal data may produce large errors during the reconstruction process. Therefore, abnormal data usually corresponds to a higher reconstruction error, namely the anomaly score. By setting a threshold, the reconstruction error can be used to determine whether the data is abnormal.
[0067] In one embodiment, the loss function used in the training process of the anomaly detection model is:
[0068]
[0069] Among them, L GAN is the loss function, E is the expectation, p data (x) represents the distribution of the real data sample x, D is the discriminator function, and G is the generator function.
[0070] In order to further verify the effectiveness of the method of this application for anomaly detection of time series data, precision (Precision), recall (Recall) and F1-score (F1) are used to evaluate the anomaly detection performance of the model used by the method of this application and the comparison model. Among them, precision represents the percentage of correctly detected anomalies among all detected anomalies, recall represents the percentage of correctly detected anomalies among all anomalies, and F1 value is the harmonic mean of precision and recall.
[0071] The public SMD (Server Machine Dataset) dataset was used as the experimental dataset for anomaly detection. The SMD dataset was collected from 28 servers over a 10-day period. Normal data appeared for the first five days, followed by intermittent injection of anomalous data for the last five days. The 28 different machines correspond to 28 different entities, each with 38 dimensions of data. The training set was unlabeled, while the test set was labeled. The training set size was 708,420, and the test set size was 708,420, respectively. The anomaly rate was 4.21%.
[0072] The method in this application was implemented in Pytorch. To train the model, the Adam optimizer with an initial learning rate of 0.0001 was introduced. MSELoss was used as the loss function for the original and reconstructed data. The Windows_size of the time series data was 100, the Batch_size was 128, the training rounds were 10, the n value (i.e., the number of frequencies selected by the FFT transform) was 5, and the number of AD Block layers was 2. The experimental results on the SMD dataset are shown in Table 1. As can be seen from Table 1, the method in this application performs well in detecting anomalies in time series data.
[0073] Table 1 Experimental results on the SMD dataset
[0074]
[0075]
[0076] Using the same inventive concept as the time series anomaly detection method based on fast Fourier transform and masked convolution, this embodiment also provides a corresponding time series anomaly detection device based on fast Fourier transform and masked convolution. Figure 5 The following is a structural block diagram of a time series anomaly detection device based on fast Fourier transform and masked convolution according to an embodiment of the present application, including:
[0077] The data acquisition module 51 is used to acquire the time series data to be detected;
[0078] The anomaly score acquisition module 52 is used to input the time series data to be detected into the trained anomaly detection model to obtain an anomaly score. The anomaly detection model includes a generator and an anomaly score calculation module. The generator includes multiple data reconstruction modules using residual connections. The generator is used to output reconstructed data based on the time series data to be detected. The anomaly score calculation module is used to calculate the error between the reconstructed data and the time series data to be detected to obtain an anomaly score.
[0079] The judgment module 53 is used to judge whether the abnormality score is greater than the judgment threshold. If so, the time series data to be detected is abnormal data; otherwise, the time series data to be detected is normal data.
[0080] The time series anomaly detection device based on fast Fourier transform and masked convolution of this embodiment has the same inventive concept as the time series anomaly detection method based on fast Fourier transform and masked convolution mentioned above. Therefore, the specific implementation method of the device can be seen in the embodiment part of the time series anomaly detection method based on fast Fourier transform and masked convolution mentioned above, and its technical effect corresponds to the technical effect of the above method, which will not be repeated here.
[0081] An embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the above-mentioned time series anomaly detection method based on fast Fourier transform and mask convolution.
[0082] An embodiment of the present application provides a computer program product, including a computer program / instruction. When the computer program / instruction is executed by a processor, it implements the above-mentioned time series anomaly detection method based on fast Fourier transform and masked convolution.
[0083] In summary, this application has the following technical effects:
[0084] This application converts one-dimensional time series data into two-dimensional data through fast Fourier transform and shaping operations, and then uses masked convolution and channel attention mechanism to extract the features of the time series data and reconstruct the original data; compared with traditional methods, extracting local features of time series data in two-dimensional space can capture longer dependencies and contextual information of time series data, thereby analyzing the data more comprehensively and providing more accurate anomaly detection results.
[0085] By introducing a masking mechanism, masked convolution not only increases the flexibility and controllability of data, greatly reduces the amount of computation, but also provides better reconstruction effects; the channel attention mechanism enables the model network to more flexibly capture key information in different channels and improve the performance of the model; by enhancing useful channel features and suppressing useless channel features, the expressiveness and generalization capabilities of the model can be improved, thereby improving the accuracy of the task.
[0086] The above descriptions are merely examples of various embodiments of the present application, but the scope of protection of the present application is not limited thereto. Any modifications or substitutions that can be readily conceived by a person skilled in the art within the technical scope disclosed in the present application should be included within the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.
Claims
1. A time series anomaly detection method based on fast Fourier transform and masked convolution, characterized in that: include: Obtaining time series data to be detected; the time series data to be detected is data in the SMD public data set; The time series data to be detected is input into a trained anomaly detection model to obtain an anomaly score; the anomaly detection model includes a generator and an anomaly score calculation module, the generator includes multiple data reconstruction modules using residual connections, the generator is used to output reconstructed data based on the time series data to be detected; the anomaly score calculation module is used to calculate the error between the reconstructed data and the time series data to be detected to obtain an anomaly score; Determine whether the anomaly score is greater than a discrimination threshold; if so, the time series data to be detected is abnormal data; if not, the time series data to be detected is normal data; The data reconstruction module includes a fast Fourier transform module, n feature extraction branches and a reconstruction unit, each of the feature extraction branches includes a first shaping unit, a feature extraction unit and a second shaping unit; The fast Fourier transform module is used to perform a fast Fourier transform on the input data to obtain frequency domain data, and determine n significant frequencies and their corresponding n amplitudes in the frequency domain data; determine n period values based on the n significant frequencies, each period value corresponding to a feature extraction branch; The first shaping unit is used to shape the input data into two-dimensional data according to the corresponding period value; The feature extraction unit is used to extract features from the two-dimensional data to obtain two-dimensional feature data; The second shaping unit is used to shape the two-dimensional feature data into one-dimensional feature data; The reconstruction unit is used to convert the n amplitudes into n weights based on a Softmax function; and performing weighted summation on all one-dimensional feature data obtained by the n feature extraction branches based on the n weights to generate a reconstruction result; The feature extraction unit is a self-supervised prediction convolution attention block, which includes a mask convolution module and a channel attention module; the mask convolution module is used to perform a mask convolution operation on the two-dimensional data to obtain mask data; the channel attention module is used to automatically learn the correlation between different channels in the feature based on the mask data; the feature extraction unit is also used to multiply the mask data and the output of the channel attention module to obtain the two-dimensional feature data.
2. The method according to claim 1, wherein The residual connection is expressed by the following formula: ,k=2,…K in, is the output of the k-th data reconstruction module, For the data reconstruction module, is the output of the k-1th data reconstruction module, K is the number of data reconstruction modules; is the time series data to be detected.
3. The method according to claim 1, wherein During the training process, the anomaly detection model also includes a discriminator; the discriminator uses a multi-layer convolutional neural network structure to judge the original data and the data generated by the generator, and the trained generator is obtained through continuous confrontation and iterative optimization between the generator and the discriminator during the training process.
4. The method according to claim 1, wherein The loss function used by the anomaly detection model during training is: in, is the loss function, For expectations, Indicates the distribution of the real data sample x. is the discriminator function, is a generator function.
5. A time series anomaly detection device based on fast Fourier transform and masked convolution, characterized in that: include: A data acquisition module is used to acquire time series data to be detected; the time series data to be detected is data in the SMD public data set; An anomaly score acquisition module is used to input the time series data to be detected into the trained anomaly detection model to obtain an anomaly score; the anomaly detection model includes a generator and an anomaly score calculation module, the generator includes multiple data reconstruction modules using residual connections, the generator is used to output reconstructed data based on the time series data to be detected; the anomaly score calculation module is used to calculate the error between the reconstructed data and the time series data to be detected to obtain an anomaly score; A judgment module is used to judge whether the abnormal score is greater than a discrimination threshold, if so, the time series data to be detected is abnormal data, if not, the time series data to be detected is normal data; The data reconstruction module includes a fast Fourier transform module, n feature extraction branches and a reconstruction unit, each of the feature extraction branches includes a first shaping unit, a feature extraction unit and a second shaping unit; The fast Fourier transform module is used to perform a fast Fourier transform on the input data to obtain frequency domain data, and determine n significant frequencies and their corresponding n amplitudes in the frequency domain data; determine n period values based on the n significant frequencies, each period value corresponding to a feature extraction branch; The first shaping unit is used to shape the input data into two-dimensional data according to the corresponding period value; The feature extraction unit is used to extract features from the two-dimensional data to obtain two-dimensional feature data; The second shaping unit is used to shape the two-dimensional feature data into one-dimensional feature data; The reconstruction unit is used to convert the n amplitudes into n weights based on a Softmax function; and performing weighted summation on all one-dimensional feature data obtained by the n feature extraction branches based on the n weights to generate a reconstruction result; The feature extraction unit is a self-supervised prediction convolution attention block, which includes a mask convolution module and a channel attention module; the mask convolution module is used to perform a mask convolution operation on the two-dimensional data to obtain mask data; the channel attention module is used to automatically learn the correlation between different channels in the feature based on the mask data; the feature extraction unit is also used to multiply the mask data and the output of the channel attention module to obtain the two-dimensional feature data.
6. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the time series anomaly detection method based on fast Fourier transform and mask convolution according to any one of claims 1 to 4.
7. A computer program product, characterized in that The invention comprises a computer program / instruction, which, when executed by a processor, implements the time series anomaly detection method based on fast Fourier transform and mask convolution according to any one of claims 1 to 4.
Citation Information
Patent Citations
Image processing method and image processing device
CN113538273A
Industrial image anomaly detection method based on fast Fourier convolution
CN114862803A