A Multivariate Time Series Anomaly Detection Method Based on Decoupled Spatiotemporal Prototype Networks

By decoupling the spatiotemporal prototype network to model the temporal evolution and variable interaction patterns respectively, the problems of overgeneralization and variable dependency ignoring in multivariate time series anomaly detection are solved, and efficient detection of interval-level and structural anomalies is achieved.

CN123069006APending Publication Date: 2026-11-10MINJIANG UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611242893.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-17
Publication Date
2026-11-10

AI Technical Summary

Technical Problem

Existing multivariate time series anomaly detection methods suffer from overgeneralization and lack of explicit modeling of inter-variable dependency patterns when dealing with complex spatiotemporal anomalies, resulting in insufficient detection capabilities for interval-level and structural mismatch anomalies.

Method used

A method based on decoupled spatiotemporal prototype networks is adopted, which models the temporal evolution mode and variable interaction mode through temporal prototype branches and spatial prototype branches respectively, introduces spatiotemporal dual prototype constraints, and uses Transformer encoder and graph convolutional network to learn temporal and spatial features, adaptively fuses reconstruction results, and calculates the final anomaly score.

Benefits of technology

It effectively alleviates the overgeneralization problem of reconstruction methods, improves the detection capability of interval-level and structural anomalies, and enhances the accuracy and robustness of anomaly detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123069006A_ABST
    Figure CN123069006A_ABST
Patent Text Reader

Abstract

This invention relates to a multivariate time series anomaly detection method based on a decoupled spatiotemporal prototype network, belonging to the field of time series anomaly detection. The method involves segmenting multivariate time series data collected by sensors in an industrial system into non-overlapping sliding windows as input samples; inputting a temporal prototype branch and a spatial prototype branch: the temporal branch divides sequence patches through a patching mechanism, encodes them, and interacts with the temporal prototype memory pool, outputting a temporal dimension reconstruction result; the spatial branch constructs learned variable dependencies through a dynamic graph, encodes them through a graph convolutional network, and interacts with the spatial prototype memory pool, outputting a spatial dimension reconstruction result; the final reconstruction output is obtained through adaptive fusion, and anomaly scores are calculated by combining reconstruction bias and spatiotemporal prototype bias, comparing them against a preset threshold to determine the anomaly state at each time step. Model training employs a composite objective function of fusion reconstruction loss and entropy regularization loss, combined with a two-stage clustering initialization memory pool training strategy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of time series anomaly detection, and relates to a multivariate time series anomaly detection method based on a decoupled spatiotemporal prototype network. Background Technology

[0002] With the rapid development of the Internet of Things (IoT) and modern industrial systems, large-scale sensor networks have been widely applied in critical infrastructure, continuously generating high-dimensional, multi-source, and highly correlated multivariate time series data. In scenarios such as water treatment plants, power systems, and aerospace monitoring, system anomalies can lead to severe economic losses or even catastrophic consequences. Therefore, multivariate time series anomaly detection has become a fundamental research problem for ensuring the safe and reliable operation of complex industrial systems.

[0003] In practical applications, anomaly detection faces significant challenges. On the one hand, anomalous events are extremely rare in practice, resulting in a scarcity or even complete absence of anomalous samples during the training phase. On the other hand, anomalous patterns are highly uncertain: anomalies may manifest as sudden pointwise deviations, gradually evolving time drifts, or anomalous changes in the dependency structure between variables. In this context, most existing research treats multivariate time series anomaly detection as an unsupervised learning problem, where the model is trained only on normal data to learn normal system behavior and identify samples that deviate from normal behavior.

[0004] Among various methods, reconstruction-based anomaly detection methods are widely adopted due to their label-free nature, flexible modeling, and strong scalability. However, reconstruction-based methods generally suffer from overgeneralization. Specifically, powerful neural networks may achieve good reconstruction for both normal and anomalous samples, resulting in low reconstruction errors even for anomalous inputs, thus weakening the anomaly detection capability.

[0005] To alleviate this problem, recent studies have introduced memory mechanisms or prototype learning strategies, restricting the reconstruction space to a limited set of representative normal patterns, thereby improving robustness to unseen anomalies. However, existing memory-guided methods still have significant limitations when dealing with complex spatiotemporal anomalies:

[0006] First, existing memory-guided reconstruction methods rely on point-by-point memory modeling, neglecting local temporal context information. In real physical systems, anomalies typically occur as continuous evolutionary processes rather than isolated point-by-point deviations, making interval-level anomalies difficult to detect.

[0007] Second, existing methods lack explicit modeling or memory of dependency patterns between variables; variable relationships are either ignored or implicitly aggregated into the latent representation. In industrial systems, stable physical coupling or causal relationships often exist between variables. When such interaction patterns are violated, the system may have entered an anomalous state, even if individual variable values ​​remain within the normal range. However, reconstruction models that focus on value-level reconstruction but lack explicit structural constraints or memory of dependency patterns between variables are often insensitive to such structural anomalies. Summary of the Invention

[0008] The purpose of this invention is to provide a multivariate time series anomaly detection method based on decoupled spatiotemporal prototype networks, which can model time evolution patterns and variable interaction patterns separately, and introduce spatiotemporal dual prototype constraints to effectively alleviate the overgeneralization problem of reconstruction methods, thereby accurately detecting interval-level anomalies and structural mismatch anomalies.

[0009] To achieve the above objectives, the technical solution of the present invention is: a multivariate time series anomaly detection method based on a decoupled spatiotemporal prototype network, comprising:

[0010] Step S1: Acquire multivariate time series data collected by sensors in the industrial system, and divide the multivariate time series data into multiple non-overlapping sliding windows as input samples;

[0011] Step S2: Input the input sample into the time prototype branch, divide the input sample into non-overlapping patches through the patching mechanism, encode it through the Transformer encoder, and interact with the time prototype memory pool to obtain the reconstruction result of the time dimension.

[0012] Step S3: Input the input sample into the spatial prototype branch, learn the dependencies between variables through the dynamic graph construction method, encode it through the graph convolutional network, and interact with the spatial prototype memory pool to obtain the reconstruction result of the spatial dimension.

[0013] Step S4: The reconstruction results of the temporal prototype branch and the spatial prototype branch are fused through an adaptive fusion mechanism to obtain the final reconstruction output of the input sample.

[0014] Step S5: Calculate the final anomaly score of the input sample based on the reconstruction bias, temporal prototype bias, and spatial prototype bias of the input sample;

[0015] Step S6: Compare the final anomaly score with the preset threshold to determine the anomaly status of the input sample at the corresponding time step.

[0016] Furthermore, the specific implementation process of the time prototype branch in step S2 is as follows:

[0017] Step S201: Patch embedding; given the first Input window Divide it into Flatten out non-overlapping patches to get ; through two linear layers Projecting onto the latent space, we get:

[0018] Add learnable positional embeddings The patch embedding representation is obtained as follows:

[0019]

[0020] in Represents the space of real numbers. For window length, For the number of variables, For patch length, For the number of patches, The hidden dimension of the model, weights bias Weight bias , This is a hidden dimension in the middle. Representation layer normalization is used to standardize features. It is a non-linear activation function;

[0021] Step S202, Time Encoding: Input the embedded patch into the Transformer encoder to generate a context query sequence:

[0022]

[0023] in ;

[0024] Step S203, Time Prototype Memory Update: Maintain a learnable time prototype memory pool. Each memory item Represents a temporal archetype. The number of time prototypes in the time prototype memory pool; for each memory item and each query in the query sequence Calculate the attention required to remember the query conditions:

[0025]

[0026] Generate aggregate update candidates:

[0027]

[0028] The learnable gating mechanism controls the update ratio:

[0029]

[0030] The memory item has been updated to:

[0031]

[0032] in This is the gate value, and its range is (0,1). For the Sigmoid function, and The weight matrix is ​​a learnable matrix. This represents element-wise multiplication (Hadamard product). For temperature parameters;

[0033] Step S204, Query Reconstruction: After memory update, attention is calculated for each query in the memory pool. The attention for the memory condition query is:

[0034]

[0035] The reconstruction features are:

[0036]

[0037] The original query and the prototype-based reconstructed features are concatenated as follows: , obtain fusion features ;in This represents the inner product operation. This represents a vector concatenation operation;

[0038] Step S205, Decoding: merging features Input a lightweight MLP decoder to produce the reconstructed output of this branch:

[0039] Subsequently, to restore the original temporal resolution of the time series, each patch-level reconstruction is uniformly expanded along the time dimension, with the patch length denoted as . The final reconstruction output of this branch is ,in .

[0040] Furthermore, the specific implementation process of the spatial prototype branch in step S3 is as follows:

[0041] Step S301: Dynamic graph construction; for each input window Treating variables as graph nodes, and using learnable projection matrices... and Map node features to query embeddings. and key embedding :

[0042]

[0043] in For the number of variables, For window length, For the first There are 1 input window, where R represents the real number space; , To query the embedded matrix, The two sets of embedding matrices are used to calculate the similarity between variables. Each row of the matrix corresponds to the query representation and key representation of a variable in the latent space, respectively. These are the query projection matrix and the key projection matrix, respectively. Both are learnable parameters that transform the observed features of variables in the original time domain to the graph embedding space, enabling the model to adaptively learn the dependencies between variables. The embedding dimension of graph nodes controls the expressive power of modeling relationships between variables; the dense adjacency matrix is ​​calculated by scaling the dot product similarity.

[0044]

[0045] in It is a dense adjacency matrix, where the (i,j)th element represents the connection strength between variable i and variable j; is a scaling factor used to prevent the gradient from vanishing due to excessively large dot product values; to reduce noise and computational overhead, only the top-K strongest connections of each node are retained, resulting in a sparse graph A, where K is the number of strongest connections retained for each node;

[0046] Step S302, Graph Convolutional Encoding: Input the learned sparse graph into a multi-layer GCN (Graph Convolutional Network), and aggregate neighbor node information through a message passing mechanism:

[0047]

[0048] in To add a self-loop adjacency matrix, For an identity matrix, add self-loops so that each node retains its own characteristics when aggregating neighbor information; for The corresponding degree matrix is ​​a diagonal matrix, and its diagonal elements are... The sum of the elements in each row is used to perform symmetric normalization on the adjacency matrix to prevent information overload caused by differences in node degree. is the learnable weight matrix of the l-th layer GCN, used to transform node features from one layer to the next; For GCN layer indexing; initial node features This refers to the transpose of the input window; The activation function used here is ReLU; K is the number of GCN layers, which controls the depth of the neighbor hierarchy where each node can aggregate information. The more layers, the wider the range that each node can perceive; after K layers of GCN encoding, the node representation... It aggregates information from its top-K neighbor nodes, capturing rich structural context information; Transpose and rename to query representation ;

[0049] Step S303, Spatial Prototype Memory Update: Define the Spatial Prototype Memory Pool , The number of temporal prototypes in the spatial prototype memory pool; employing the same gating incremental update strategy as the temporal prototype branch, for each memory item. And each spatial query feature in the query representation Calculate query condition memory attention:

[0050]

[0051] Learnable gating control update ratio:

[0052]

[0053] in and This is a learnable weight matrix, applied to the current memory item and the aggregate query features, respectively;

[0054] Spatial memory item updated to:

[0055]

[0056] Step S304, Query Reconstruction: Calculate memory-conditional query attention.

[0057]

[0058] in For temperature parameters;

[0059] Obtain reconstructed features:

[0060]

[0061] Concatenate the original spatial query with the reconstructed features: , obtain fusion features ;

[0062] Step S305: Decode; fuse features Input to a lightweight decoder to produce a spatial reconstruction output:

[0063]

[0064] Here, Decoder represents the decoder, which is used to map latent features back to the original data space. This is the reconstruction result of the spatial branch;

[0065] Furthermore, the specific implementation of adaptive fusion in step S4 is as follows:

[0066] The final reconstruction output is obtained by adaptively fusing the reconstruction results of the temporal prototype branch and the spatial prototype branch:

[0067]

[0068] in The learnable fusion weights are generated using the Sigmoid function. and These are the reconstructed outputs of the temporal prototype branch and the spatial prototype branch, respectively.

[0069] Furthermore, the calculation process for the anomaly score in step S5 is as follows:

[0070] Step S501: Calculate reconstruction deviation For the s-th input window and its reconstruction output Calculate the point-by-point reconstruction error:

[0071]

[0072] in The length of the window;

[0073] Step S502: Calculate the time prototype deviation ; Patch-level representation of the output of the time prototype branch encoder Assign to all time steps it covers; let For time step Index of the patch For the corresponding patch-level representation, the time prototype deviation is defined as follows: Euclidean distance between it and the nearest prototype in the temporal memory pool:

[0074]

[0075] in This is the j-th time prototype in the time prototype memory pool;

[0076] Step S503: Calculate the spatial prototype deviation The graph convolutional encoder of the spatial prototype branch directly generates pointwise feature representations. For windows Given time step GCN output is denoted as Spatial prototype deviation is defined as Euclidean distance between it and the nearest prototype in the spatial memory pool:

[0077]

[0078] in The j-th spatial prototype in the spatial prototype memory pool;

[0079] Step S504, Fusion and Modulation: The potential biases are fused and normalized, and then used for modulation to reconstruct the biases, resulting in the final anomaly score.

[0080]

[0081] in Contribution weights used to control spatial prototype deviations.

[0082] Furthermore, the model training employs a composite objective function, including reconstruction loss and entropy regularization loss:

[0083] Reconstruction losses Defined as the Frobenius norm between the input time series and the final fused output:

[0084]

[0085] For the s-th input window , This is the corresponding reconstruction output;

[0086] Entropy loss and Regularization is applied to the memory similarity weights of the temporal prototype branch and the spatial prototype branch respectively:

[0087]

[0088]

[0089] in For window length, For the number of patches, Query attention for the memory conditions of the time prototype branch. Query attention for the memory conditions of the spatial prototype branch; and These represent the number of time prototypes in the time prototype memory pool and the spatial prototype memory pool, respectively.

[0090] The overall objective function is:

[0091]

[0092] in and The weight parameters that contribute to the balance entropy regularization.

[0093] Furthermore, a two-stage training strategy is adopted:

[0094] Phase 1: Randomly initialize memory terms, train the entire network once, enabling the encoder to learn temporal and structural representations, and collect the encoder outputs of the temporal prototype branch and the spatial prototype branch.

[0095] Phase 2: Perform K-means clustering on the encoder outputs extracted from the training set, with the number of clusters set to the number of memory prototypes. and The cluster centers are directly assigned to the time memory matrix. and spatial memory matrix Use these as initial values, and then continue training.

[0096] Furthermore, in step S301, the K value of top-K is a fixed proportion of C, and when calculating the dense adjacency matrix... The dimension is less than L.

[0097] The present invention also provides a non-volatile computer-readable storage medium storing a computer program thereon, which, when executed by a processor of an industrial monitoring server, an industrial edge computing node, or an industrial field control device, implements a multivariate time series anomaly detection method based on a decoupled spatiotemporal prototype network as described above.

[0098] The present invention also provides a computer program product comprising a computer program that, when executed by a processor, implements the multivariate time series anomaly detection method based on a decoupled spatiotemporal prototype network as described above.

[0099] To verify the effectiveness of the method of this invention, experiments were conducted on three publicly available benchmark datasets: MSL, SMAP, and SWAT. Precision, recall, and F1 score were used as evaluation metrics, defined as follows:

[0100]

[0101]

[0102]

[0103] Where TP is the true positive count, which is the number of abnormal samples correctly detected as abnormal; FP is the false positive count, which is the number of normal samples incorrectly detected as abnormal; FN is the false negative count, which is the number of abnormal samples incorrectly detected as normal; precision reflects the proportion of truly abnormal samples among those detected as abnormal by the model, measuring the model's ability to avoid false positives; recall reflects the proportion of actual abnormal samples correctly detected by the model, measuring the model's ability to avoid false negatives; and the F1 score is the harmonic mean of precision and recall, comprehensively measuring the model's anomaly detection performance. A higher F1 score indicates that the model has achieved a better balance between precision and recall.

[0104] Compared with the prior art, the present invention has the following beneficial effects:

[0105] (1) By decoupling time evolution modeling and variable interaction modeling through parallel dual-branch architecture, the introduction of spatiotemporal dual prototype constraints effectively alleviates the overgeneralization problem that is common in reconstruction methods;

[0106] (2) The patch-based temporal prototype learning mechanism captures interval-level temporal patterns from normal data, effectively overcoming the limitations of point-by-point memory modeling in detecting interval-level anomalies;

[0107] (3) The spatial prototype branch based on dynamic graph convolution explicitly learns and memorizes the interaction patterns between variables in the latent space, which enhances the model's ability to detect structural anomalies caused by dependency mismatch between variables;

[0108] (4) Experimental results on multiple real industrial benchmark datasets (see Table 1) show that the method of the present invention achieved the highest F1 scores on MSL, SMAP and SWAT datasets, reaching 95.89%, 96.75% and 96.63% respectively, which are superior to existing representative anomaly detection methods. Attached Figure Description

[0109] Figure 1 This is a schematic diagram of the method flow of the present invention. Detailed Implementation

[0110] The technical solution of the present invention will be described in detail below with reference to the accompanying drawings.

[0111] like Figure 1 The present invention provides a multivariate time series anomaly detection method based on a decoupled spatiotemporal prototype network, comprising:

[0112] Step S1: Acquire multivariate time series data collected by sensors in the industrial system, and divide the multivariate time series data into multiple non-overlapping sliding windows as input samples;

[0113] Step S2: Input the input sample into the time prototype branch, divide the input sample into non-overlapping patches through the patching mechanism, encode it through the Transformer encoder, and interact with the time prototype memory pool to obtain the reconstruction result of the time dimension.

[0114] Step S3: Input the input sample into the spatial prototype branch, learn the dependencies between variables through the dynamic graph construction method, encode it through the graph convolutional network, and interact with the spatial prototype memory pool to obtain the reconstruction result of the spatial dimension.

[0115] Step S4: The reconstruction results of the temporal prototype branch and the spatial prototype branch are fused through an adaptive fusion mechanism to obtain the final reconstruction output of the input sample.

[0116] Step S5: Calculate the final anomaly score of the input sample based on the reconstruction bias, temporal prototype bias, and spatial prototype bias of the input sample;

[0117] Step S6: Compare the final anomaly score with the preset threshold to determine the anomaly status of the input sample at the corresponding time step.

[0118] The method of this invention employs a parallel dual-branch architecture to model temporal evolution patterns and variable interaction patterns separately. The temporal prototype branch learns interval-level normal prototypes from time series patches, enhancing the perception of continuity and contextual anomalies; the spatial prototype branch utilizes dynamic graph convolution to learn structure-aware latent prototypes, representing stable inter-variable dependencies. During the reconstruction process, the input samples are simultaneously constrained by both temporal and spatial prototypes, making it difficult to accurately reconstruct anomalous samples that deviate from normal spatiotemporal patterns, thereby improving anomaly detection capabilities and further mitigating the overgeneralization problem.

[0119] The specific implementation process of step S1 includes the following steps:

[0120] Given a multivariate time series ,in Indicates the sequence length. Indicates the number of variables. Divide it into... A length of Non-overlapping sliding windows, where . No. Each window is defined as a subsequence. .set up The parameter is The reconstruction model, for the input window The corresponding reconstruction sequence is defined as During the training phase, unsupervised training is performed using only normal data. For test sequences that may contain anomalous data... The reconstruction function generates a corresponding reconstruction sequence, from which the anomaly scoring sequence is obtained. Subsequently, by comparing the anomaly score with a preset threshold... Comparison to determine each time step Abnormal state: If but Indicates an abnormal state, otherwise Finally, a binary label sequence is obtained. .

[0121] The specific implementation process of step S2 includes the following steps:

[0122] Step S201: Patch embedding; given the first Input window First, divide it into Flatten out non-overlapping patches to get Secondly, through two linear layers... Projecting onto the latent space, we obtain... Finally, learnable positional embeddings are added to obtain the patch embedding representation. .in For window length, For the number of variables, For patch length, , , , , This is a hidden dimension in the middle.

[0123] Step S202: Time encoding; Input the embedded patch into the Transformer encoder to generate a context query sequence:

[0124]

[0125] in ;

[0126] Step S203: Time prototype memory update; To store normal time patterns, maintain a learnable time memory pool. Each memory item Represents a temporal prototype; during the training phase, memories are updated in a gated manner, using an incremental method; for each memory... and query The query condition memory attention calculation is as follows:

[0127]

[0128] Aggregate update candidates are:

[0129]

[0130] Learnable gating control update ratio:

[0131]

[0132] The memory item has been updated to:

[0133]

[0134] Step S204: Query Reconstruction; After memory update, attention is calculated for each query in the memory pool. The attention for the memory condition query is:

[0135]

[0136] The reconstruction features are:

[0137]

[0138] The original query and the prototype-based reconstructed features are concatenated as follows: , obtain fusion features ;

[0139] Step S205: Decode; fuse features Input a lightweight MLP decoder to produce the reconstructed output of this branch. Subsequently, to restore the original temporal resolution of the time series, each patch-level reconstruction is uniformly expanded along the time dimension, with the patch length denoted as... The final reconstruction output of this branch is ,in .

[0140] The specific implementation process of step S3 includes the following steps:

[0141] Step S301: Dynamic graph construction; for each input window Treating variables as graph nodes, embeddings are generated by mapping node features to the latent space using a projection matrix. and :

[0142]

[0143] in , ; Calculate the dense adjacency matrix by scaling the dot product similarity:

[0144]

[0145] in To reduce noise and computational overhead, only the top-ranking data of each node is retained. The strongest connections are used to obtain a sparse graph. ;

[0146] Step S302: Graph convolutional encoding; input the learned graph into a multi-layer GCN:

[0147]

[0148] in To add a self-loop adjacency matrix, This is the corresponding degree matrix. For the first Learnable weight matrix of layer GCN, initial node features Activation function Using ReLU; after After layer GCN encoding, the node representation It aggregates its top- Information about neighboring nodes captures rich structural context information; Transpose and rename to query representation ;

[0149] Step S303: Spatial prototype memory update; the spatial prototype does not remember the graph structure itself, but stores representative potential interaction states of variables after dynamic graph message passing; the memory pool is defined as... During the training phase, spatial memory items employ the same gated incremental update strategy as the temporal prototype branch; for each memory item... Spatial query features The query condition memory attention calculation is as follows:

[0150]

[0151] Learnable gating control update ratio:

[0152]

[0153] Spatial memory item updated to:

[0154]

[0155] Step S304: Query Reconstruction; After memory update, each spatial query performs attention calculation on the memory pool. The attention for memory conditional queries is:

[0156]

[0157] The reconstruction features are:

[0158]

[0159] Original spatial query and reconstructed features are stitched together as , obtain fusion features ;

[0160] Step S305: Decode; fuse features Input to a lightweight decoder to produce a spatial reconstruction output. .

[0161] The specific implementation process of step S4 is as follows:

[0162] The final reconstruction is obtained by adaptively fusing the outputs of the temporal prototype branch and the spatial prototype branch:

[0163]

[0164] in These are learnable fusion weights generated using the Sigmoid function.

[0165] The specific implementation process of step S5 includes the following steps:

[0166] Anomalies are detected by jointly considering reconstruction bias and deviation from the learned spatiotemporal prototype.

[0167] Step S501: Calculate reconstruction deviation ; For windows and its reconstruction The point-by-point reconstruction error is:

[0168]

[0169] Step S502: Calculate the time prototype deviation The encoder output patch level representation of the time prototype branch. To obtain pointwise anomaly scores, the representation of each patch is assigned to all time steps it covers; let... For time step Index of the patch For the corresponding patch-level representation, the time prototype deviation is defined as follows: Euclidean distance between it and the nearest prototype in the temporal memory pool:

[0170]

[0171] Step S503: Calculate the spatial prototype deviation The graph convolutional encoder of the spatial prototype branch directly generates pointwise feature representations. For windows Given time step GCN output is denoted as Spatial prototype deviation is defined as Euclidean distance between it and the nearest prototype in the spatial memory pool:

[0172]

[0173] Step S504: Fusion and Modulation; the latent bias is first fused and normalized, and then used to modulate and reconstruct the bias:

[0174]

[0175] in The contribution weight of spatial prototype deviation is controlled; ultimately, the anomaly score is compared with a preset threshold. Comparison to determine each time step Abnormal state: If If it is, it is considered abnormal; otherwise, it is considered normal.

[0176] The model training employs a composite objective function, including reconstruction loss and entropy regularization loss:

[0177] Reconstruction losses Defined as input time series With the final fusion output The Frobenius norm between:

[0178]

[0179] To encourage sparse and distinguishable prototype assignments, entropy regularization is applied to the memory similarity weights; for the temporal prototype branch, the entropy loss is defined as:

[0180]

[0181] Apply a similar entropy loss to the spatial prototype branch:

[0182]

[0183] The ultimate training objective is:

[0184]

[0185] in and Contribution to balancing entropy regularization.

[0186] The model training employs a two-stage training strategy:

[0187] Since memory networks learn normal prototypes in an unsupervised manner, the random initialization of memory terms in the early stages of training often leads to unstable optimization and poor convergence, potentially causing the model to get trapped in suboptimal local minima. Therefore, a two-stage training strategy is adopted, and K-means clustering is used to provide high-quality initialization for the memory prototypes:

[0188] Phase 1: Randomly initialize memory terms and train the entire network for one round; the purpose of this phase is to enable the encoder to learn meaningful temporal and structural representations; collect the encoder output, i.e., the temporal prototype branch. and the spatial prototype branch This is used for memory initialization in the next stage;

[0189] The second stage involves summarizing all encoder outputs extracted from the training set and performing K-means clustering on the query sets of both branches, with the number of clusters set to the number of time-memory prototypes. And the number of spatial memory prototypes ;Assign the cluster centers directly to the time memory matrix and spatial memory matrix As an initial value, this initialization method anchors the memory prototype in a high-density region of the normal data distribution, providing a clear starting point for subsequent training optimization, and then continues training.

[0190] Comparative experiment:

[0191] The method of this invention was compared with existing representative anomaly detection methods on the MSL, SMAP and SWaT datasets. The experimental results are shown in Table 1.

[0192] Table 1. Results of Anomaly Detection Experiment

[0193]

[0194] Table 1 shows that the DSTP-Net method of this invention achieved the highest F1 scores on the MSL, SMAP and SWaT datasets, reaching 95.89%, 96.75% and 96.63% respectively, which is better than existing representative anomaly detection methods.

[0195] The present invention also provides a non-volatile computer-readable storage medium storing a computer program thereon, which, when executed by a processor of an industrial monitoring server, an industrial edge computing node, or an industrial field control device, implements a multivariate time series anomaly detection method based on a decoupled spatiotemporal prototype network as described above.

[0196] The present invention also provides a computer program product comprising a computer program that, when executed by a processor, implements the multivariate time series anomaly detection method based on a decoupled spatiotemporal prototype network as described above.

[0197] The above are preferred embodiments of the present invention. Any changes made to the technical solution of the present invention that do not exceed the scope of the technical solution of the present invention shall fall within the protection scope of the present invention.

Claims

1. A method for detecting multivariate time series anomalies based on decoupled spatiotemporal prototype networks, characterized in that, include: Step S1: Acquire multivariate time series data collected by sensors in the industrial system, and divide the multivariate time series data into multiple non-overlapping sliding windows as input samples; Step S2: Input the input sample into the time prototype branch, divide the input sample into non-overlapping patches through the patching mechanism, encode it through the Transformer encoder, and interact with the time prototype memory pool to obtain the reconstruction result of the time dimension. Step S3: Input the input sample into the spatial prototype branch, learn the dependencies between variables through the dynamic graph construction method, encode it through the graph convolutional network and interact with the spatial prototype memory pool to obtain the reconstruction result of the spatial dimension; Step S4: The reconstruction results of the temporal prototype branch and the spatial prototype branch are fused through an adaptive fusion mechanism to obtain the final reconstruction output of the input sample. Step S5: Calculate the final anomaly score of the input sample based on the reconstruction bias, temporal prototype bias, and spatial prototype bias of the input sample; Step S6: Compare the final anomaly score with the preset threshold to determine the anomaly status of the input sample at the corresponding time step.

2. The multivariate time series anomaly detection method based on a decoupled spatiotemporal prototype network according to claim 1, characterized in that, The specific implementation process of the time prototype branch in step S2 is as follows: Step S201: Patch embedding; given the first Input window Divide it into Flatten out non-overlapping patches to get ; through two linear layers Projected onto the latent space, we obtain ; Add learnable positional embeddings The patch embedding representation is obtained. ;in Represents the space of real numbers. For window length, For the number of variables, For patch length, For the number of patches, The hidden dimension of the model, weights bias Weight bias , This is a hidden dimension in the middle. Representation layer normalization, It is a non-linear activation function; Step S202, Time Encoding: Input the embedded patch into the Transformer encoder to generate a context query sequence: in ; Step S203, Time Prototype Memory Update: Maintain a learnable time prototype memory pool. Each memory item Represents a temporal archetype. The number of time prototypes in the time prototype memory pool; for each memory item and each query in the query sequence Calculate the attention required to remember the query conditions: Generate aggregate update candidates: The update ratio is controlled through a learnable gating mechanism: The memory item has been updated to: in This is the gate value. For the Sigmoid function, and For learnable weight matrix, This represents element-wise multiplication. For temperature parameters; Step S204, Query Reconstruction: Calculate the memory conditional query attention: Obtain reconstructed features: Concatenate the original query with the reconstructed features: , obtain fusion features ;in This represents the inner product operation. This represents a vector concatenation operation; Step S205, Decoding: merging features Input a lightweight MLP decoder to produce patch-level reconstruction output. ; Subsequently, to restore the original temporal resolution of the time series, each patch-level reconstruction is uniformly expanded along the time dimension, with the patch length denoted as . The final reconstruction output of this branch is ,in Decoder stands for decoder, which maps latent features back to the original data space; MLP stands for Multilayer Perceptron.

3. The multivariate time series anomaly detection method based on a decoupled spatiotemporal prototype network according to claim 1, characterized in that, The specific implementation process of the spatial prototype branch in step S3 is as follows: Step S301, Dynamic Graph Construction: Treat each variable as a graph node, and construct the graph using a learnable projection matrix. and Map node features to query embeddings. and key embedding : in For the number of variables, For window length, For the first One input window, Represents the space of real numbers; , and These are the query embedding matrix and the key embedding matrix, respectively, with each row corresponding to the representation of a variable in the latent space; These are the query projection matrix and the key projection matrix, respectively. Both are learnable parameters used to transform the original time-domain features into the graph embedding space. The embedding dimension of graph nodes controls the expressive power of modeling relationships between variables; the dense adjacency matrix is ​​calculated by scaling the dot product similarity. in It is a dense adjacency matrix, whose elements represent the connection strength between corresponding variable pairs; is a scaling factor used to prevent the gradient from vanishing due to excessively large dot product values; to reduce noise and computational overhead, only the top-K strongest connections of each node are retained, resulting in a sparse graph A, where K is the number of strongest connections retained for each node; Step S302, Graph Convolutional Encoding: Input the sparse graph into a multi-layer graph convolutional network (GCN): in To add a self-loop adjacency matrix, For an identity matrix, add self-loops so that each node retains its own characteristics when aggregating neighbor information; for The corresponding degree matrix is ​​a diagonal matrix, used to perform symmetric normalization on the adjacency matrix to prevent information overload caused by differences in node degree. Here is the learnable weight matrix for the l-th layer of the GCN, used to transform node features from one layer to the next; initial node features ; The activation function used here is ReLU; K is the number of GCN layers, which controls the depth of the neighbor hierarchy where each node can aggregate information. The more layers, the wider the range that each node can perceive; after K layers of GCN encoding, the node representation... It aggregates the information of its top-K neighbor nodes, transposes it, and renames it to a query representation. ; Step S303, Spatial Prototype Memory Update: Define the Spatial Prototype Memory Pool , The number of temporal prototypes in the spatial prototype memory pool; employing the same gating incremental update strategy as the temporal prototype branch, for each memory item. And each spatial query feature in the query representation Calculate query condition memory attention: Learnable gating control update ratio: in and This is a learnable weight matrix, applied to the current memory item and the aggregate query features, respectively; Spatial memory item updated to: Step S304, Query Reconstruction: Calculate memory-conditional query attention. in For temperature parameters; Obtain reconstructed features: Concatenate the original spatial query with the reconstructed features: , obtain fusion features ; Step S305, Decoding: Input the fused feature Zˉs into the lightweight decoder to generate the spatial reconstruction output. , where Decoder represents the decoder, which is used to map latent features back to the original data space.

4. The multivariate time series anomaly detection method based on a decoupled spatiotemporal prototype network according to claim 1, characterized in that, The specific implementation of adaptive fusion in step S4 is as follows: The final reconstruction output is obtained by adaptively fusing the reconstruction results of the temporal prototype branch and the spatial prototype branch: in The learnable fusion weights are generated using the Sigmoid function. and These are the reconstructed outputs of the temporal prototype branch and the spatial prototype branch, respectively.

5. The multivariate time series anomaly detection method based on a decoupled spatiotemporal prototype network according to claim 1, characterized in that, The calculation process for the anomaly score in step S5 is as follows: Step S501: Calculate reconstruction deviation For the s-th input window and its reconstruction output Calculate the point-by-point reconstruction error: in The length of the window; Step S502: Calculate the time prototype deviation ; Patch-level representation of the output of the time prototype branch encoder Assign to all time steps it covers; let For time step Index of the patch For the corresponding patch-level representation, the time prototype deviation is defined as Euclidean distance between it and the nearest prototype in the temporal memory pool: in This is the j-th time prototype in the time prototype memory pool; Step S503: Calculate the spatial prototype deviation The graph convolutional encoder of the spatial prototype branch directly generates pointwise feature representations. For windows Given time step GCN output is denoted as Spatial prototype deviation is defined as Euclidean distance between it and the nearest prototype in the spatial memory pool: in The j-th spatial prototype in the spatial prototype memory pool; Step S504, Fusion and Modulation: The potential biases are fused and normalized, and then used for modulation to reconstruct the biases, resulting in the final anomaly score. in Contribution weights used to control spatial prototype deviations.

6. The multivariate time series anomaly detection method based on a decoupled spatiotemporal prototype network according to claim 1, characterized in that, The model training uses a composite objective function, including reconstruction loss and entropy regularization loss: Reconstruction losses Defined as the Frobenius norm between the input time series and the final fused output: For the s-th input window , This is the corresponding reconstruction output; Entropy loss and Regularization is applied to the memory similarity weights of the temporal prototype branch and the spatial prototype branch respectively: in For window length, For the number of patches, Query attention for the memory conditions of the time prototype branch. Query attention for the memory conditions of the spatial prototype branch; and These represent the number of time prototypes in the time prototype memory pool and the spatial prototype memory pool, respectively. The overall objective function is: in and The weight parameters that contribute to the balance entropy regularization.

7. The multivariate time series anomaly detection method based on a decoupled spatiotemporal prototype network according to claim 1, characterized in that, A two-stage training strategy is adopted: Phase 1: Randomly initialize memory terms, train the entire network once, enabling the encoder to learn temporal and structural representations, and collect the encoder outputs of the temporal prototype branch and the spatial prototype branch. Phase 2: Perform K-means clustering on the encoder outputs extracted from the training set, with the number of clusters set to the number of memory prototypes. and The cluster centers are directly assigned to the time memory matrix. and spatial memory matrix Use these as initial values, and then continue training.

8. The multivariate time series anomaly detection method based on a decoupled spatiotemporal prototype network according to claim 3, characterized in that, In step S301, the K value of top-K is a fixed proportion of C, and when calculating the dense adjacency matrix... The dimension is less than L.

9. A non-volatile computer-readable storage medium, characterized in that, It stores a computer program, which, when executed by the processor of an industrial monitoring server, an industrial edge computing node, or an industrial field control device, implements a multivariate time series anomaly detection method based on a decoupled spatiotemporal prototype network as described in any one of claims 1 to 9.

10. A computer program product, characterized in that, The system includes a computer program that, when executed by a processor, implements a multivariate time series anomaly detection method based on a decoupled spatiotemporal prototype network as described in any one of claims 1 to 9.