Multivariate time series anomaly detection method for intelligent internet of things system
Through the end-to-end hierarchical spatiotemporal variational autoencoder framework, the problem of difficult to capture temporal randomness and spatial randomness in multivariate time series anomaly detection is solved, highly robust anomaly detection is achieved, and the accuracy of detection is significantly improved. and recall rate.
Patent Information
- Application Number
- PCT/CN2023/103251
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-04-03
- Filing Date
- 2023-06-28
- Publication Date
- 2024-10-10
AI Technical Summary
Existing multivariate time series anomaly detection methods are difficult to effectively capture temporal randomness and spatial randomness, resulting in insufficient robustness of anomaly detection and high misjudgment rate.
An end-to-end hierarchical spatiotemporal variational autoencoder framework is proposed, which models latent graph relationships and temporal dependencies through spatial encoders and temporal encoders, combines reconstruction decoders and predictive decoders, uses stochastic gradient descent algorithms to update parameters, and adopts Anomaly scoring mechanism combining history and future is used for detection.
It achieves highly robust anomaly detection for multivariate time series, significantly improves the accuracy and recall rate of detection, and performs particularly well in capturing complex graph relationships and time dependencies.
Smart Images

Figure CN2023103251_10102024_PF_FP_ABST
Abstract
Description
A multivariate time series anomaly detection method for intelligent IoT systems Technical Field
[0001] The present application relates to the field of Internet of Things, and specifically to a multivariate time series anomaly detection method for intelligent Internet of Things systems. Background Art
[0002] Multivariate time series anomaly detection aims to monitor systems in various real-world scenarios, promptly detect deviations from normal patterns, and issue early warnings to help administrators make informed decisions and perform system maintenance. In recent years, with the widespread adoption of various sensing devices in smart IoT infrastructure, smart grids, smart transportation, smart industry, and other systems, multivariate time series anomaly detection has become a hot research topic in both academia and industry. Anomalies are typically considered unexpected values that significantly deviate from the normal pattern. Therefore, existing methods focus on learning the normal pattern of time series and identifying data that deviates from it as outliers. Common deep learning anomaly detection methods primarily include prediction-based and reconstruction-based approaches. Prediction-based approaches often use long short-term memory networks (LSTMs), transformers, and graph neural networks (GNNs) to model the temporal dependencies and inter-sequence relationships of time series, and consider points with prediction errors greater than a threshold as outliers. Reconstruction-based approaches often use autoencoders (AEs), variational autoencoders (VAEs), and generative adversarial networks (GANs) to learn robust latent representations and identify points with reconstruction errors greater than a threshold as outliers. Learning robust representations of normal patterns from multivariate time series is crucial for anomaly detection, yet the robustness of anomaly detection is highly constrained by the temporal and spatial randomness of multivariate time series. Specifically, temporal randomness indicates that the temporal dependence patterns of a sequence are quite variable. Normal temporal fluctuations are common in multivariate time series, but these normal fluctuations can easily be misclassified as anomalies. Therefore, various variational autoencoder-based methods have been proposed to model temporal randomness in multivariate time series by introducing latent variables to learn robust representations, such as OmniAnomaly. Furthermore, some work, such as GRELEN, has significantly improved anomaly detection performance by considering the latent spatial relationships in multivariate time series. Most existing methods, such as GDN, aim to learn graph structures by measuring the similarity between the embeddings of individual sequences and selecting the top-K most similar sequences as neighboring sequences. Clearly, the top-K strategy cannot effectively model the randomness of graph relationships, namely spatial randomness, which leads to information loss and weakens anomaly detection capabilities.
[0003] Summary of the Invention
[0004] Based on the above problems, a highly robust multivariate time series anomaly detection method for intelligent IoT systems is proposed to solve the two major problems of temporal randomness and spatial randomness in multivariate time series anomaly detection. An end-to-end hierarchical spatiotemporal variational autoencoder framework is proposed. Its technical solution is as follows:
[0005] A multivariate time series anomaly detection method for an intelligent IoT system includes the following steps:
[0006] S1. The spatial encoder adopts a graph learning strategy to model the latent graph relationship between sequences;
[0007] S2. The temporal encoder uses a multi-head self-attention mechanism and a graph attention network to capture the latent time series representation;
[0008] S3. The reconstruction decoder uses a multi-head self-attention network based on the latent time series representation to reconstruct the input sequence. The prediction decoder uses a multi-head self-attention network based on the latent time series representation to achieve multi-step prediction of future time series.
[0009] S4. Use the stochastic gradient descent algorithm to reversely update the parameters of the hierarchical variational autoencoder composed of the spatial encoder, temporal encoder, reconstruction decoder, and prediction decoder to obtain a model that learns the normal pattern of the time series;
[0010] S5. Use the history-future combined anomaly scoring mechanism for anomaly detection.
[0011] Preferably, in step S1, the spatial encoder adopts a graph learning strategy based on a self-attention mechanism to model the potential graph relationship between multivariate time series. The specific steps are as follows:
[0012] S11. Use a linear network to transform any two original time series x i 、x j Map to high dimension and extract high-dimensional time features g i 、g j ,Right now in, is the learnable parameter matrix;
[0013] S12. Extract the time feature g i 、g j Mapped into vectors q in different subspaces i 、k i and q j 、k j , that is, q i =g i W q , k i =g i W k ,qj =g i W q , k j =g j W k , where W q and W k is the learnable parameter matrix;
[0014] S13. Assuming that the potential graph relation random variable follows Bernoulli distribution, then the variational distribution Connection vector q i and k j , and then a probability value between 0 and 1 is obtained through the multi-layer perceptron (MLP) network, which is used as the probability parameter π of the Bernoulli distribution i,j , that is, π i,j =MLP(W s [q i ,k j ]), where W s is the learnable parameter matrix;
[0015] S14. Use Gumbel-Softmax distribution to resample and obtain the continuous approximation of Bernoulli random variables, thereby obtaining the latent graph relationship representation variable e i,j ,Right now in are the probabilities of there being a correlation and no correlation between time series i and j, respectively; τ is the temperature coefficient, which controls the smoothness of the Gumbel-Softmax distribution; are independent and identically distributed samples drawn from a standard Gumbel distribution;
[0016] S15. Execute S11-S14 in parallel on any two sequences among the N input time series to obtain the adjacency matrix E.
[0017] Preferably, in step S2, the temporal encoder combines the multi-head self-attention mechanism and the GAT network to capture the potential time series representation to model time-dependent randomness. The specific steps are as follows:
[0018] S21. For each time series, use an embedding layer module containing "position encoding" to transform the input value at timestamp t of the i-th time series Convert the input embedding vector to d dimensions As the input of the multi-head self-attention module, Among them, emb is a linear layer, and pos represents position encoding;
[0019] S22. For each time series i, the time dependency is modeled through a multi-head self-attention network. The multi-head self-attention network fuses the time series data within a time window and performs weighted average according to the importance of the time series data in the time window to obtain the time feature representation. Right now Among them, h is the number of heads in the multi-head attention network, W o is a learnable parameter matrix, for the mth head, Q, K, and V represent the query, key value, and data value, respectively, and are represented by h i After linear mapping, we can get: in are different linear mapping matrices;
[0020] S23. The temporal feature representations of all sequences are fed into the GAT network, and the neighbor information is aggregated according to the potential graph adjacency matrix learned by the spatial encoder to obtain the updated temporal feature representation of each sequence. Right now Where Relu is the activation function, N(i)={j|e j,i =1}, W is a trainable parameter matrix, α j,i represents the attention coefficient, in LeakyRelu is the activation function, and a is the learning coefficient of the attention mechanism;
[0021] S24. Assuming that the underlying time series random variable follows a Gaussian distribution, the variational distribution Will Obtain the mean and variance of the Gaussian distribution through a linear network Right now
[0022] S25. Use the reparameterization technique to obtain the potential time series representation of the i-th time series at time t Right now in s is the time window length, d z The dimension of the latent time series representation vector for each moment of each sequence.
[0023] Preferably, in step S3, the decoder network modeling distribution is reconstructed Reconstruct the input sequence. The specific steps are as follows: for each time series i, its potential time series representation As the input of the multi-head self-attention network, the multi-head self-attention network learns the temporal dependencies between different moments in the potential time series representation and obtains the feature representation Then pass through an MLP network to get the reconstructed output Reconstruct the input sequence.
[0024] Preferably, in step S3, the predictive decoder model is The specific steps for multi-step prediction are as follows: for each time series i, its prediction decoder consists of two layers of attention networks: the first layer of self-attention network layer takes a randomly generated token vector as the original input, and in the prediction process, autoregressively uses the prediction output of the previous moment as the input of the current moment to obtain the feature The second layer is the encoder-decoder attention network layer. The query comes from the output of the first layer of the self-attention network, and the key and value come from the potential time series representation z. i , which enables each moment in the decoder to pay attention to the information of all moments in the input sequence, thereby realizing multi-step prediction of future time series and obtaining the predicted value y i .
[0025] Preferably, in step S4, the Gaussian prior distribution is set to p(z i )=N(0,1), the Bernoulli prior distribution is Ber(b), where b is a hyperparameter that controls the sparsity of the graph; the variational lower bound ELBO of the variational autoencoder is used as the loss function, and the stochastic gradient descent algorithm is used to reversely update the parameters φ of the hierarchical variational autoencoder e ,φ z ,θ r ,θ f ; Specifically, the loss is:
[0026] φ e are the parameters of the spatial encoder, φ z The parameters of the time encoder, θ r Reconstruct the decoder parameters, θ f are the parameters of the prediction decoder, X is the input data of the spatial encoder and the temporal encoder; where the first term is the reconstruction loss, which represents the ability of the reconstruction decoder to reconstruct the historical input, the second term is the prediction loss, which represents the prediction accuracy of the prediction decoder, and the last two terms represent the use of KL divergence to control the difference between the variational distribution and the prior distribution to be as small as possible.
[0027] Preferably, in step S5,
[0028] S51. Input the test set data into the trained model to obtain the reconstructed and predicted values. For each time series i, for historical moments i = (i - s, …, i - 1), take the reconstructed value and the true value of the mean squared error as the reconstruction error For future moments i = (i, …, t + s), take the predicted value and the true value of the mean squared error as the prediction error
[0029] S52. For each moment i, take the mean of the reconstruction errors of all sequences at that moment as the reconstruction error Err r (i), and take the mean of the prediction errors of all sequences at that moment as the prediction error Err f (i);
[0030] S53. Select the maximum reconstruction error in the historical time window (i - s, …, i - 1) as the historical anomaly factor A h (i), select the maximum prediction error in the future time window (i, …, t + s) as the future anomaly factor A f (i), and the prediction error at that moment i as the current anomaly factor A c (i);
[0031] S54. Perform coefficient weighting on the historical anomaly factor A h (i), the current anomaly factor A c (i), and the future anomaly factor A f (i) to obtain the anomaly score A1(i) = A c (i) + γ·A h (i) + η·A f (i), where γ and η are the proportionality coefficients of A h (i) and A<062>(i), respectively, obtained by the grid search algorithm;
[0032] S55. Take the average number of neighbors of all sequences as the anomaly score based on graph sparsity where D i represents the number of neighbors of the i-th sequence;
[0033] S56.If A(i) > thr1 or A2(i) < thr2, it is considered that an anomaly has occurred at moment i, and the anomaly label a t = 1, where the thresholds thr1 and thr2 can be obtained by the grid search algorithm.
[0034] Compared with the prior art, this application has the following advantages:
[0035] 1. A hierarchical spatiotemporal variational autoencoder (HSTVAE) is proposed to simultaneously model the temporal and spatial randomness of multivariate time series in a unified end-to-end framework.
[0036] 2. In the spatial encoder, the existence of a relationship between sequences is modeled as a binary random variable, and the graph structure can be automatically learned through a graph learning strategy. The temporal encoder then embeds the highly structured time series into a latent random variable to capture complex temporal dependencies and neighborhood information. Furthermore, the combined historical-future anomaly scoring mechanism weights historical anomaly factors, future anomaly factors, and the prediction error of the current timestamp to achieve anomaly detection that is more sensitive to the current timestamp. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] FIG1 is a schematic flow diagram of the method of the present invention;
[0038] Figure 2 is a probabilistic graphical model of a hierarchical variational autoencoder;
[0039] Figure 3 is the overall framework diagram of the hierarchical variational autoencoder;
[0040] Figure 4 is a flowchart of anomaly detection. DETAILED DESCRIPTION
[0041] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0042] Graph attention networks (GAT)
[0043] Hierarchical Spatio-Temporal Variational Autocoder (HSTVAE)
[0044] Example 1:
[0045] This embodiment provides a highly robust multivariate time series anomaly detection method for intelligent IoT systems and proposes an end-to-end hierarchical spatiotemporal variational autoencoder framework. The process is shown in Figure 1.
[0046] First, from a theoretical analysis, the probabilistic graph model of the hierarchical spatiotemporal variational autoencoder HSTVAE is shown in Figure 2. The graph represents the dependency between the latent graph relationship and the latent time series variables. Each node represents a random variable, the shaded nodes represent the observed data, and the arrows represent the dependency between the variables. The black dotted line represents the inference model of the variational autoencoder, and the black solid line represents the generation model of the variational autoencoder. If the latent graph relationship variable e ij = 1, then there is an edge from node i to node j, that is, time series i and time series j are related. ij =0, indicating that there is no edge from node j to node k.
[0047] The specific implementation steps are as follows:
[0048] Step S01: Normalize three publicly available multivariate time series anomaly detection datasets to obtain the input for the hierarchical variational autoencoder. The details are as follows:
[0049] S02 selected datasets and conducted extensive experiments on three real-world, public multivariate time series datasets: SWaT (Safe Water Treatment Testbed), WADI (Water Distribution Testbed), and SMD (Internet Company Server Dataset). The time series in SWaT and WADI represent metrics such as water pressure recorded by sensors in the intelligent water treatment platform. The time series in SMD represent the time-varying changes in metrics such as CPU load, network usage, and memory usage in the server. Table 1 summarizes the statistics of these three datasets.
[0050] Table 1 Dataset attribute statistics
[0051] S03. Divide the dataset: The training set contains only normal data, while the test set contains abnormal data. In the normal dataset, the ratio of training set data to validation set data is 8:2.
[0052] S04. Normalization: Perform minimum and maximum scaling on each data set, scaling it to a number between 0 and 1. The formula is Among them, X is the input of the spatial encoder and the temporal encoder, and X′ is the original dataset data without normalization.
[0053] Steps S1-S5 mainly illustrate the training process of the hierarchical spatiotemporal variational autoencoder, in which the spatial encoder and temporal encoder are used to learn the latent graph relationship and the latent time series representation respectively. Then, based on the latent time series representation, the reconstruction decoder and prediction decoder are used to reconstruct the historical sequence and predict the future sequence respectively. Finally, the ELBO of the hierarchical spatiotemporal variational autoencoder is used as the loss to reversely update the model parameters.
[0054] As shown in Figures 1-4, a multivariate time series anomaly detection method for an intelligent IoT system includes the following steps:
[0055] In step S1, the spatial encoder uses a graph learning strategy based on the self-attention mechanism to model the potential graph relationship between multivariate time series. The specific steps are as follows:
[0056] S11. Use a linear network to transform any two original time series x i 、x j Map to high dimension and extract high-dimensional time features g i 、g j ,Right now in, is the learnable parameter matrix;
[0057] S12. Extract the time feature g i 、g j Mapped into vectors q in different subspaces i 、k i and q j , k j , that is, q i =g i W q , k i =g i W k ,q j =g j W q , k j =g j W k , where W q and W k is the learnable parameter matrix;
[0058] S13. Assuming that the potential graph relation random variable follows Bernoulli distribution, then the variational distribution Connection vector q i and k j , and then a probability value between 0 and 1 is obtained through the multi-layer perceptron (MLP) network, which is used as the probability parameter π of the Bernoulli distribution i,j , that is, π i,j =MLP(W s [q i ,k j ]), where W s is the learnable parameter matrix;
[0059] S14. Use Gumbel-Softmax distribution to resample and obtain the continuous approximation of Bernoulli random variables, thereby obtaining the latent graph relationship representation variable ei,j ,Right now in are the probabilities of correlation and non-correlation between sequences i and j, respectively, and τ is the temperature coefficient, which controls the smoothness of the Gumbel-Softmax distribution. is an independent and identically distributed sample sampled from the standard Gumbel distribution, specifically, g = -log(-logu), where the uniform distribution u ~ Uniform(0,1);
[0060] S15. Execute S11-S14 in parallel on any two sequences among the N input sequences to obtain the adjacency matrix E.
[0061] In step S2, the temporal encoder combines the multi-head self-attention mechanism and the GAT network to capture the potential time series representation to model time-dependent randomness. The specific steps are as follows:
[0062] S21. For each time series, use an embedding layer module to embed the input value at timestamp i of the i-th series Convert the input embedding vector to d dimensions As the input of the multi-head self-attention module, Where emb is a linear layer, pos represents sine-cosine position encoding;
[0063] S22. For each time series i, the time dependency is modeled through a multi-head self-attention network. The multi-head self-attention network fuses the time series data within a time window and performs weighted average according to the importance of the time series data within the time window to obtain the time feature representation Right now Among them, h is the number of heads in the multi-head attention network, W o is a learnable parameter matrix, for the mth head, Q, K, and V represent the query, key value, and data value, respectively, and are represented by h i After linear mapping, we can get: in are different linear mapping matrices;
[0064] S23. The temporal feature representations of all sequences are fed into the GAT network, and the neighbor information is aggregated according to the potential graph relationship adjacency matrix E learned by the spatial encoder to obtain the updated temporal feature representation of each sequence. Right now Where Relu is the activation function, N(i)={j|e j,i =1}, W is a trainable parameter matrix, α j,irepresents the attention coefficient, in LeakyRelu is the activation function, and a is the learning coefficient of the attention mechanism;
[0065] S24. Assuming that the underlying time series random variable follows a Gaussian distribution, the variational distribution Will Obtain the mean and variance of the Gaussian distribution through a linear network Right now
[0066] S25. Use the reparameterization technique to obtain the potential time series representation of the i-th time series at time i Right now in s is the time window length, d z is the dimension of the potential time series representation vector for each moment of each sequence, and R is a real number.
[0067] In step S3, the decoder network modeling distribution is reconstructed Reconstruct the input sequence. The specific steps are as follows: For each sequence i, its potential time series representation As the input of the multi-head self-attention network, the multi-head self-attention network learns the temporal dependencies between different moments in the potential time series representation and obtains the feature representation Then the reconstructed value is obtained through the MLP network Reconstruct the input sequence.
[0068] In step S3, the predictive decoder model is Perform multi-step prediction. The specific steps are as follows: for each time series i, its prediction decoder consists of two layers of attention networks: the first layer of self-attention network layer takes a randomly generated token vector as the original input, and in the prediction process, autoregressively uses the prediction output of the previous moment as the input of the current moment to obtain the feature The second layer is the encoder-decoder attention network layer. The query comes from the output of the first layer of the self-attention network, and the key and value come from the potential time series representation z. i , which enables each moment in the decoder to pay attention to the information of all moments in the input sequence, thereby realizing multi-step prediction of future time series and obtaining the predicted value y i .
[0069] In step S4, the parameters of the hierarchical variational autoencoder composed of the two encoders and two decoders are reversely updated using the stochastic gradient descent algorithm to train a model that has learned the normal pattern of the time series. The specific steps are as follows: Set the Gaussian prior distribution to p(z i )=N(0,1), the Bernoulli prior distribution is Ber(b), where b is a hyperparameter that controls the sparsity of the graph. The variational lower bound ELBO of the variational autoencoder is used as the loss function, and the stochastic gradient descent algorithm is used to reversely update the parameters φ of the hierarchical variational autoencoder. e ,φ z ,θ r ,θ f Specifically, the loss is:
[0070] φ e are the parameters of the spatial encoder, φ z The parameters of the time encoder, θ r Reconstruct the decoder parameters, θ f are the parameters of the predictive decoder, and X represents the input data of the spatial encoder and temporal encoder. The first term is the reconstruction loss, which represents the ability of the reconstruction decoder to reconstruct historical inputs, and the second term is the prediction loss, which represents the prediction accuracy of the predictive decoder. The last two terms use KL divergence to minimize the difference between the variational distribution and the prior distribution.
[0071] In step S5, anomaly detection is performed using a history-future combined anomaly scoring mechanism, as shown in Figure 4. The specific steps are as follows:
[0072] S51. Input the test set data into the trained model to obtain the reconstruction and prediction values. For each time series i, for the historical moment t=(ts,…,i-1), the reconstruction value and the true value The mean square error is taken as the reconstruction error For the future time i=(i,…t+w), the predicted value and the true value The mean square error is taken as the prediction error
[0073] S52. For each time t, the mean of the reconstruction errors of all sequences at that time is taken as the reconstruction error Err at time t r (t), the mean of the prediction errors of all sequences at that moment is taken as the prediction error Err at moment t f (i).
[0074] S53. Select the maximum reconstruction error in the historical time window (ts,…,t-1) as the historical anomaly factor A at time th (t), select the maximum prediction error in the future time window (t, … t + s) as the future anomaly factor A at time t f (t), the prediction error at this time t is used as the anomaly factor A c (t).
[0075] S54. Coefficient-weight the historical anomaly factor A h (t), the current anomaly factor A c (t), and the future anomaly factor A f (t) to obtain the anomaly score A1(t) = A c (t) + γ · A h (t) + η · A f (t), where γ and η are the proportionality coefficients of A h (t) and A f (t), respectively, obtained by the grid search algorithm.
[0076] S55. Take the average number of neighbors of all sequences as the anomaly score based on graph sparsity where, D i represents the number of neighbors of the i-th time series.
[0077] S56. If A1(t) > thr1 or A2(t) < thr2, it is considered that an anomaly has occurred at time t, and the anomaly label a t = 1; where, the thresholds thr1 and thr2 can be obtained by the grid search algorithm.
[0078] According to the anomaly labels detected by the hierarchical variational autoencoder and the true labels of the dataset, calculate the values of anomaly detection performance evaluation metrics: accuracy, recall, and F1 score, where the F1 score is the harmonic mean of accuracy and recall. Conduct a series of experiments such as performance comparison and ablation study step by step.
[0079] Table 2 shows the anomaly detection performance of the proposed HSTVAE method and other existing techniques on the SWaT, WADI, and SMD datasets in terms of precision, recall, and F1 score. The best performance values are highlighted in bold, and the suboptimal ones are underlined. The proposed HSTVAE significantly outperforms all other methods on the three datasets, particularly in terms of recall and F1. HSTVAE's F1 score and recall outperform all baselines, and its performance in terms of precision and recall is quite balanced. In particular, the proposed method achieves the best F1 scores of 0.8955 for SWaT, 0.8401 for WADI, and 0.8963 for SMD. To achieve higher recall, unlike other combined reconstruction and prediction methods such as DVGCRN and MTAD-GAT, which only use reconstruction and prediction errors to calculate anomaly scores, the proposed method also uses the sparsity of the learned graph as a detection metric. If the sparsity of the obtained relationship graph falls below a certain threshold, the moment is also classified as an anomaly. Compared with the second-best model, HSTVAE improves the recall by 2.50%, 1.34%, and 0.64% on the three datasets, respectively.
[0080] Table 2 Comparison of anomaly detection performance of different methods
[0081] To validate the effectiveness of the various modules of our proposed hierarchical variational autoencoder, we conducted ablation experiments, the results of which are shown in Table 3. Removing the GAT module significantly reduces recall, demonstrating that aggregating appropriate neighbor information through graph learning can help the model learn a more effective latent time series representation. Removing the reconstruction or prediction decoders also leads to a decrease in anomaly detection accuracy and recall, demonstrating that the reconstruction and prediction decoders also play an important role in modeling temporal and spatial randomness.
[0082] Table 3 Experimental results of ablation study
[0083] The foregoing description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Those skilled in the art will readily appreciate that various modifications and variations of the present invention are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention shall be included within the scope of protection of the present invention.
Claims
1. A multivariate time series anomaly detection method for intelligent IoT system, characterized in that: The following steps are included: S1. The spatial encoder adopts a graph learning strategy to model the latent graph relationship between sequences; S2. The temporal encoder uses a multi-head self-attention mechanism and a graph attention network to capture the latent time series representation; S3. The reconstruction decoder uses a multi-head self-attention network based on the potential time series representation to achieve the reconstruction of the input sequence; the prediction decoder uses a multi-head self-attention network based on the potential time series representation to achieve multi-step prediction of future time series; S4. Using the stochastic gradient descent algorithm, the parameters of the hierarchical variational autoencoder composed of the spatial encoder, the temporal encoder, the reconstruction decoder, and the prediction decoder are reversely updated to obtain a model that learns the normal pattern of the time series; S5. Use the history-future combined anomaly scoring mechanism for anomaly detection.
2. The multivariate time series anomaly detection method for intelligent IoT system according to claim 1 is characterized in that: In step S1, The spatial encoder uses a graph learning strategy based on the self-attention mechanism to model the potential graph relationship between multivariate time series. The specific steps are as follows: S11. Use a linear network to transform any two original time series x i 、x j Map to high dimension and extract high-dimensional time features g i , g j ,Right now in, is the learnable parameter matrix; S12. Extract the time feature g i , g j Mapped to vectors q in different subspaces i , k i and q j , k j , that is, q i =g i W q , k i =g i W k ,q j =g j W q , k j =g j W k , where W q and W k is the learnable parameter matrix; S13. Assuming that the potential graph relation random variable follows a Bernoulli distribution, then the variational distribution Connection vector q i and k j , and then a probability value between 0 and 1 is obtained through a multi-layer perceptron (MLP) network, which is used as the probability parameter π of the Bernoulli distribution i,j , which is π i,j =MLP(W s [q i ,k j ]), where W s is the learnable parameter matrix; S14. Use Gumbel-Softmax distribution to resample and obtain the continuous approximate Bernoulli random variable Similar to the above, we can get the potential graph relationship representation variable e i,j ,Right now in are the probabilities of correlation and non-correlation between time series i and j, respectively. τ is the temperature coefficient, which controls the smoothness of the Gumbel-Softmax distribution. are independent and identically distributed samples drawn from a standard Gumbel distribution; S15. Execute S11-S14 in parallel on any two sequences among the N input time series to obtain the adjacency matrix E.
3. The multivariate time series anomaly detection method for intelligent IoT system according to claim 1 is characterized in that: In step S2, the temporal encoder combines the multi-head self-attention mechanism and the GAT network to capture the potential time series representation to model time-dependent randomness. The specific steps are as follows: S21. For each time series, use an embedding layer module containing "position encoding" to embed the input value at timestamp t of the i-th time series Convert the input embedding vector to d dimensions As the input of the multi-head self-attention module, Among them, emb is a linear layer, and pos represents position encoding; S22. For each time series i, the time dependency is modeled through a multi-head self-attention network. The multi-head self-attention network fuses the time series data in a time window and performs weighted average according to the importance of the time series data in the time window to obtain the time feature representation. Right now Among them, h is the number of heads of the multi-head attention network, W o is a learnable parameter matrix, for the mth head, Q, K, and V represent the query, key value, and data value, respectively, and are generated by h i After linear mapping, we get: in are different linear mapping matrices; S23. The temporal feature representations of all sequences are fed into the GAT network, and the neighbor information is aggregated according to the potential graph relationship adjacency matrix learned by the spatial encoder to obtain the updated temporal feature representation of each sequence. Right now Where Relu is the activation function, N(i)={j|e j,i =1}, W is a trainable parameter matrix, α j,i represents the attention coefficient, in LeakyRelu is the activation function, a is the attention machine The learning coefficient of the system; S24. Assuming that the underlying time series random variable follows a Gaussian distribution, then the variational distribution Will Get the mean and variance of Gaussian distribution through linear network Right now S25. Use the reparameterization technique to obtain the potential time series representation of the i-th time series at time t Right now in s is the time window length, d z The dimension of the latent time series representation vector for each time instant of each sequence.
4. The multivariate time series anomaly detection method for intelligent IoT system according to claim 1, characterized in that: In step S3, the decoder network modeling distribution is reconstructed Reconstruct the input sequence. The specific steps are as follows: For each time series i, its potential time series representation As the input of the multi-head self-attention network, the multi-head self-attention network learns the temporal dependencies between different moments in the potential time series representation and obtains the feature representation Then, the reconstructed output is obtained through an MLP network. Reconstruct the input sequence.
5. The multivariate time series anomaly detection method for intelligent IoT system according to claim 1, characterized in that: In step S3, the predictive decoder model is The specific steps for multi-step prediction are as follows: for each time series i, its prediction decoder consists of two layers of attention networks: the first layer of self-attention network layer takes a randomly generated token vector as the original input, and autoregressively takes the prediction output of the previous moment as the input of this moment in the prediction process to obtain the feature The second layer is the encoder-decoder attention network layer. The query query comes from the output of the first layer of the self-attention network. The key key and value value come from the potential time series representation z i , which enables each moment in the decoder to pay attention to the information of all moments in the input sequence, thereby realizing multi-step prediction of future time series and obtaining the predicted value y i .
6. The multivariate time series anomaly detection method for intelligent IoT system according to claim 1, characterized in that: In step S4, the Gaussian prior distribution is set to p(z i )=N(0,1), the Bernoulli prior distribution is Ber(b), where b is a hyperparameter that controls the sparsity of the graph; the variational lower bound ELBO of the variational autoencoder is used as the loss function, and the stochastic gradient descent algorithm is used to reversely update the parameters φ of the hierarchical variational autoencoder e ,φ z ,θ r ,θ f ; Specifically, the loss is: φ e is the parameter of the spatial encoder, φ z The parameters of the time encoder, θ r Reconstruct the decoder parameters, θ f are the parameters of the prediction decoder, X is the input data of the spatial encoder and the temporal encoder; where the first term is the reconstruction loss, which indicates the ability of the reconstruction decoder to reconstruct the historical input, the second term is the prediction loss, which indicates the prediction accuracy of the prediction decoder, and the last two terms indicate the use of KL divergence to control the difference between the variational distribution and the prior distribution to be as small as possible.
7. The multivariate time series anomaly detection method for intelligent IoT system according to claim 1 is characterized in that: In step S5, S51. Input the test set data into the trained model to obtain the reconstruction and prediction values. For each time series i, for the historical moment t = (ts,…,t-1), the reconstruction value and the true value The mean square error is taken as the reconstruction error For the future time t=(t,…t+s), the predicted value and the true value The mean square error is taken as the prediction error S52. For each time t, the mean of the reconstruction errors of all sequences at that time is taken as the reconstruction error Err at time t r (t), the mean of the prediction errors of all sequences at that moment is taken as the prediction error Err at moment t f (t); S53. Select the maximum reconstruction error in the historical time window (ts,…,t-1) as the historical anomaly factor A at time t h (t), select the maximum prediction error in the future time window (t,…t+s) as the future anomaly factor A at time t f (t), the prediction error at this time t is used as the current abnormal factor A c (t); S54. The historical anomaly factor A h (t), current abnormal factor A c (t), future abnormal factor A f (t) is weighted by coefficients to obtain anomaly score A1(t)=A based on reconstruction and prediction errors c (t)+γ·A h (t)+η·A f (t), where γ and η are A h (t), A f (t) The proportionality coefficient is obtained by the grid search algorithm; S55. The average number of neighbors of all sequences is used as an anomaly score based on graph sparsity Among them, D i represents the number of neighbors of the i-th sequence; S56. If A1(t) > thr1 or A2(t) < thr2, it is considered that an anomaly has occurred at time t, and the anomaly label a t = 1, where the thresholds thr1 and thr2 can be obtained by the grid search algorithm.
Citation Information
Patent Citations
Prediction method and device of taxi-taking demand quantity and traffic flow combined prediction model
CN112819222A
Network traffic matrix prediction method based on self-attention mechanism
CN114553718A
Remote examination abnormal state pre-judgment method, system and device and storage medium
CN114882570A
Examination room abnormal behavior monitoring method and system based on self-attention network architecture
CN115601710A
Unified Vision and Dialogue Transformer with BERT
US20210232773A1
Cited By
Method, medium and system for estimating filter screen replacement time in ABS (Acrylonitrile Butadiene Styrene) production process
CN119066369A
Cable cover plate anomaly detection method and system based on variational auto-encoder
CN119089363A
Intelligent temperature control lead-free tin bar production method and device
CN119089367A
Multi-channel data monitoring range adjusting method based on graph anomaly detection
CN119089935A
Multi-site water quality prediction method based on spatio-temporal feature fusion
CN119168176A
