Time series anomaly detection method based on shared autoencoder
Through the time series anomaly detection method based on shared autoencoders, using autoencoders and adversarial training technology, the problem of low accuracy of traditional methods in high-dimensional data processing is solved, and high accuracy on SWaT and WADI data sets is achieved. Sexual abnormality detection.
Patent Information
- Application Number
- CN202111002647.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-30
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2041-08-30
AI Technical Summary
Traditional outlier detection methods are difficult to capture the intrinsic properties of data when processing complex high-dimensional data, and deep learning methods require repeated parameter adjustments to reduce dimensions, which cannot meet the growing demand for data computing.
A time series anomaly detection method based on shared autoencoders is adopted. The D1 and D2 decoders share two encoders E1 and E2 to form an encoding, decoding and re-encoding network structure. Autoencoder training and adversarial training are performed, and the anomaly score of the data is calculated. Implement detection.
The accuracy of anomaly detection is improved, and the DAGMM, OmniAnomaly and USAD methods show higher accuracy in experiments on SWaT and WADI data sets.
Smart Images

Figure CN113780387B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of electronic digital data processing, and in particular to a time series anomaly detection method based on a shared autoencoder. Background Art
[0002] An outlier is defined as a data object that is significantly different from other data distributions. By analyzing the distribution characteristics of outlier data, we can mine abnormal information and extract interesting patterns from massive data. Therefore, outlier detection has become one of the research hotspots in the field of data mining. The purpose of outlier detection is to find outliers that are different from large-scale data through data mining methods and discover potential and meaningful knowledge. At present, it is widely used in fraud detection, medical treatment, public safety, environmental sanitation, image processing, abnormal behavior pattern detection, trajectory anomaly detection and other fields.
[0003] There are many traditional methods for detecting outliers. Generally, classic outlier detection methods are usually divided into four categories: statistics-based, clustering-based, classification-based, and proximity-based. Traditional detection technology mainly considers the time performance and accuracy performance in the detection process. However, with the development of cloud computing and big data technology, the traditional method of mining abnormal node information through single-node computing can no longer meet the growing data computing needs. Artificial intelligence technology represented by deep learning technology provides a new research direction for outlier detection. At present, the method of constructing a hybrid model by combining deep learning methods has been continuously applied to practical scenarios in recent years. Because it does not require the model to be trained in advance, it is a cost-effective method. However, for complex and high-dimensional data, this type of method is also difficult to capture the intrinsic properties of the data. In addition, when AE is used for dimensionality reduction, the degree of dimensionality reduction has a great impact on the final result, and repeated parameter adjustment is required. Summary of the invention
[0004] The purpose of the present invention is to provide a time series anomaly detection method based on a shared autoencoder, aiming to improve the accuracy of anomaly detection.
[0005] To achieve the above object, the present invention provides a time series anomaly detection method based on a shared autoencoder, comprising: using D1 and D2 decoders to share two encoders E1 and E2 respectively, forming two sets of encoding, decoding and re-encoding network structures;
[0006] Reconstruct and train the two network structures based on the autoencoder training method;
[0007] Train two network structures based on adversarial training;
[0008] Input the test data into the two network structures, calculate the anomaly score of the data, and obtain the anomaly detection results.
[0009] The encoder includes three linear layers, each of which uses ReLU as an activation function.
[0010] The decoder includes three linear layers, the first two layers use the ReLU activation function, and the last layer uses the Sigmoid function.
[0011] The specific method of using the D1 and D2 decoders to share the two encoders E1 and E2 respectively is: the decoder D1 and the encoders E1 and E2 form an EDE1 structure, and the decoder D2 shares the encoders E1 and E2 to form an EDE2 structure.
[0012] The specific method of reconstructing the two network structures based on the autoencoder training method is as follows:
[0013] Preprocess the time series data to obtain the first time window data;
[0014] The first time window data is sent to the encoder E1, and the first feature vector is obtained and stored after the linear layer feature extraction of the encoder E1;
[0015] The D1 and D2 decoders use the first feature vector as input to reconstruct the training set and obtain the second time window data and the third time window data;
[0016] The second time window data and the third time window data are input into the encoder E2 to obtain a first reconstructed feature vector and a second reconstructed feature vector.
[0017] The specific steps of training two network structures based on adversarial training are:
[0018] Input the second feature vector into the decoder D1 to obtain the fourth time window data;
[0019] Input the fourth time window data into the encoder E2 to obtain a third reconstructed feature vector;
[0020] Adversarial training is completed based on the loss function of the two EDE structures.
[0021] The loss functions of the two EDE structures include minimizing the difference between the original time window and the new time window and minimizing the difference between the two reconstructed feature vectors and .
[0022] The present invention discloses a time series anomaly detection method based on a shared autoencoder, comprising: using D1 and D2 decoders to share two encoders E1 and E2 respectively, forming two sets of encoding, decoding and re-encoding network structures; reconstructing and training the two network structures based on the autoencoder training method; training the two network structures based on the adversarial training method; inputting test data into the two network structures, calculating the anomaly score of the data, and obtaining anomaly detection results. By comparing the latest anomaly detection methods such as DAGMM, OmniAnomaly and USAD, experiments were conducted using multiple data sets such as SWaT and WADI, proving that the proposed method is more accurate in anomaly detection of time series. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0024] Figure 1 is a structural diagram of an encoder of the present invention;
[0025] Figure 2 is a block diagram of a decoder of the present invention;
[0026] Figure 3 It is a model structure diagram of two networks of the present invention;
[0027] Figure 4 is a flow chart of a time series anomaly detection method based on a shared autoencoder of the present invention;
[0028] Figure 5 is a flow chart of the present invention for performing reconstruction training on two network structures based on the first training method;
[0029] Figure 6 It is a flow chart of training two network structures based on adversarial training method of the present invention. DETAILED DESCRIPTION
[0030] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present invention, and should not be construed as limiting the present invention.
[0031] See also Figure 1 to Figure 6 The present invention provides a time series anomaly detection method based on a shared autoencoder, comprising:
[0032] S101 uses D1 and D2 decoders to share two encoders E1 and E2 respectively, forming a network structure with two sets of encoding, decoding and re-encoding;
[0033] The encoder includes three linear layers, each of which uses ReLU as an activation function. The decoder includes three linear layers, the first two layers use ReLU activation functions, and the last layer uses Sigmoid function.
[0034] The specific method of using the D1 and D2 decoders to share the two encoders E1 and E2 respectively is: the decoder D1 and the encoders E1 and E2 form an EDE1 structure, and the decoder D2 shares the encoders E1 and E2 to form an EDE2 structure.
[0035] S102 performs reconstruction training on two network structures based on the autoencoder training method;
[0036] The specific method is:
[0037] S201 preprocesses the time series data to obtain first time window data;
[0038] For time series data Preprocessing is performed and the sliding window W t The form of:
[0039] W t ={x t-K+1 , …, x t-1 , x t}
[0040] That is, a time window of length K at a given time t. This allows the original time series data to be Convert to a time window:
[0041] W={W1,…,W T}
[0042] Where W is used as the training data input. Given the label y = {0, 1}, assuming that y = 1 is abnormal, the original time window becomes:
[0043] W={(W1,y1),...,(W T ,y T )}
[0044] The problem of anomaly detection is transformed into finding a time window Indicates that an anomaly is detected at time t.
[0045] S202: sending the first time window data to the encoder E1, extracting the linear layer features of the encoder E1 to obtain the first feature vector and storing it;
[0046] The time window W is sent to the encoder E1. After the linear layer feature extraction of the encoder E1, each time window W is represented as the first feature vector Z = {(z 11 , y1),...(z 1T ,y T )} and save it.
[0047] S203D1 and D2 decoders use the first feature vector as input to reconstruct the training set to obtain the second time window data and the third time window data;
[0048] Decoders D1 and D2 take the first feature vector as input to reconstruct the training set, and output the reconstructed time window data respectively:
[0049] W1={(W 11 ,y1),...,(W 1m ,y m )}and
[0050] W2={(W 21 ,y1),...,(W 2m ,y m )}.
[0051] S204: Input the second time window data and the third time window data into the encoder E2 to obtain a first reconstructed feature vector and a second reconstructed feature vector.
[0052] Then the reconstructed data W1 and W2 are sent to the encoder E2 respectively to obtain two reconstructed feature vectors:
[0053] The first reconstructed eigenvector Z1 = {(z 11 ,y1),...,(z 1m ,y T )}
[0054] and the second reconstructed eigenvector Z2={(z 21 ,y1),...,(z 2m ,y T )}
[0055] And store it. The loss functions of this stage are
[0056]
[0057] and
[0058] Where α+β=1.
[0059] S103 trains two network structures based on adversarial training;
[0060] The specific steps are:
[0061] S301 inputs the second feature vector into the decoder D1 to obtain the fourth time window data;
[0062] After the first training method, the content of the first training method is repeated, and the obtained second feature vector Z2 is sent to the decoder D1 to obtain new fourth time window data:
[0063] W1′={(W 11 ′, y1), ..., (W 1m ′,y m )}
[0064] S302 inputs the fourth time window data into the encoder E2 to obtain a third reconstructed feature vector;
[0065] The fourth time window data W1′ is sent to the encoder E2 to obtain the third reconstructed feature vector
[0066] Z1′={(z 11 ′, y1), ..., (z 1m ′,y T )}.
[0067] S303 completes adversarial training based on the loss functions of the two EDE structures.
[0068] Design the loss functions of the two EDE structures to achieve the purpose of adversarial training. The loss function of the EDE1 structure needs to distinguish where the input data comes from, so two goals need to be achieved: the first goal is to maximize the difference between the original time window W and the fourth time window data W1′; the second goal is to maximize the difference between the first eigenvector Z and the third reconstructed eigenvector Z1′. On the contrary, the EDE2 structure needs to deceive EDE1 so that it cannot distinguish where the data comes from, so its loss function needs to: minimize the difference between the original time window W and the fourth time window data W1′; minimize the difference between the first eigenvector Z and the third reconstructed eigenvector Z1′. Therefore, the loss function of the second stage is:
[0069]
[0070] and
[0071] Where α+β=1.
[0072] Then the total loss function of the model is:
[0073]
[0074]
[0075] S104 inputs test data into the two network structures, calculates the anomaly score of the data, and obtains anomaly detection results.
[0076] After training is completed, the test data set is fed into the model. Following the above two steps, several parameters W, W1, W1′ and Z, Z1, Z1′ that define the anomaly score can be obtained, and the anomaly score formula is designed:
[0077]
[0078] Calculate the anomaly score of the test data to get the anomaly detection result.
[0079] The following is a comparison table of the algorithm of the present invention and other algorithms:
[0080]
[0081] By comparing with the latest anomaly detection methods such as DAGMM, OmniAnomaly and USAD, experiments are conducted using multiple datasets such as SWaT and WADI, which proves that the proposed method is more accurate in anomaly detection of time series.
[0082] What is disclosed above is only a preferred embodiment of the present invention, and it certainly cannot be used to limit the scope of rights of the present invention. Ordinary technicians in this field can understand that all or part of the processes of the above embodiment and equivalent changes made according to the claims of the present invention still fall within the scope of the invention.
Claims
1. A time series anomaly detection method based on shared autoencoder, It is characterized in that It includes: using D1 and D2 decoders to share two encoders E1 and E2 respectively, forming two sets of encoding, decoding and re-encoding network structures; Reconstruct and train the two network structures based on the autoencoder training method; Train two network structures based on adversarial training; Input test data into the two network structures, calculate the anomaly score of the data, and obtain the anomaly detection results; Wherein, the input test data is derived from image processing; The specific manner of using the D1 and D2 decoders to share the two encoders E1 and E2 respectively is: the decoder D1 and the encoders E1 and E2 form an EDE1 structure, and the decoder D2 shares the encoders E1 and E2 to form an EDE2 structure; The specific method of reconstructing the two network structures based on the autoencoder training method is: Preprocess the time series data to obtain the first time window data; The first time window data is sent to the encoder E1, and the first feature vector is obtained and stored after the linear layer feature extraction of the encoder E1; The D1 and D2 decoders use the first feature vector as input to reconstruct the training set and obtain the second time window data and the third time window data; Input the second time window data and the third time window data into the encoder E2 to obtain a first reconstructed feature vector and a second reconstructed feature vector; The specific steps of training two network structures based on the adversarial training method are: Input the second reconstructed feature vector into the decoder D1 to obtain the fourth time window data; Input the fourth time window data into the encoder E2 to obtain a third reconstructed feature vector; Complete adversarial training based on the loss function of two EDE structures; The loss function of the EDE1 structure includes maximizing the difference between the data of the first time window and the fourth time window; maximizing the difference between the first eigenvector and the third reconstructed eigenvector, and the loss function of the EDE2 structure includes minimizing the difference between the data of the first time window and the fourth time window; minimizing the difference between the first eigenvector and the third reconstructed eigenvector.
2. A time series anomaly detection method based on a shared autoencoder as claimed in claim 1, characterized in that: The encoder consists of three linear layers, each of which uses ReLU as the activation function.
3. A time series anomaly detection method based on a shared autoencoder as claimed in claim 2, characterized in that: The decoder includes three linear layers, the first two layers use ReLU activation function, and the last layer uses Sigmoid function.
