Traffic flow anomaly detection method and device based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling, equipment and medium

CN122888796APending Publication Date: 2026-10-09CENT SOUTH UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610990169.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-03
Publication Date
2026-10-09

AI Technical Summary

Technical Problem

[0005]本申请目的在于提供一种基于周期残差解耦与记忆增强时空图建模的交通流异常检测方法、装置、设备及介质,旨在解决如何在正常周期波动与异常扰动混杂的交通状态数据中识别节点级交通异常的技术问题

Benefits of technology

首先,获取交通状态窗口和交通图结构,交通状态窗口用于表示多个交通监测节点在连续时间片内的交通状态变化,交通图结构用于表示多个交通监测节点之间的邻接关系,由此为后续基于时间变化和节点关系进行异常检测提供数据基础;然后,根据各时间片的日型类别、日内时间位置以及各交通监测节点的节点自适应参数,生成窗口级周期基准序列,该窗口级周期基准序列用于表征对应时间片和对应交通监测节点下的正常周期状态,有利于后续从交通状态数据中分离正常周期成分;接着,根据交通状态窗口和窗口级周期基准序列生成周期残差序列,周期残差序列用于表示实际交通状态相对于正常周期状态的偏离情况,能够减少早晚高峰、工作日与周末差异等正常周期波动对异常识别的干扰;进一步,根据邻接矩阵对周期残差序列进行空间图传播,并对空间图传播结果进行时间依赖编码,得到周期残差时空编码表示,使周期残差中的节点关联信息和连续时间变化信息能够被共同表征;随后,将周期残差时空编码表示与原型记忆库进行匹配,得到记忆增强特征序列,并基于记忆增强特征序列重构周期残差序列,得到最终重构误差,使重构结果能够围绕正常残差模式形成,并保留偏离正常残差模式的误差信息;最后,根据最终重构误差计算异常分数,并根据异常分数和节点异常阈值输出异常检测结果,使异常检测结果能够对应到具体交通监测节点和时间片,因此本申请能够在正常周期波动与异常扰动混杂的交通状态数据中识别节点级交通异常。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122888796A_ABST
    Figure CN122888796A_ABST
Patent Text Reader

Abstract

The application discloses a traffic flow anomaly detection method and device based on period residual decoupling and memory-enhanced space-time graph modeling, equipment and medium, relates to the intelligent transportation technical field, and the method comprises the steps that the traffic state window and the corresponding traffic graph structure of a plurality of traffic monitoring nodes are acquired; a window-level period reference sequence is generated according to the day type category, the intraday time position and the node adaptive parameter; a period residual sequence is obtained from the traffic state window and the window-level period reference sequence; the period residual sequence is subjected to space graph propagation and time-dependent coding based on an adjacency matrix, and a period residual space-time coding representation is formed; the representation is matched with a prototype memory library to obtain a memory-enhanced feature sequence, and the period residual sequence is reconstructed to obtain a final reconstruction error; an anomaly score is calculated according to the final reconstruction error, and an anomaly detection result is output in combination with a node anomaly threshold. The application can identify node-level traffic anomalies in traffic state data mixed with normal period fluctuations and abnormal disturbances.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of intelligent transportation technology, and in particular to a method, device, equipment and medium for traffic flow anomaly detection based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling. Background Technology

[0002] With the development of intelligent transportation systems, a large number of traffic detection devices have been deployed in urban roads, highways, and regional road networks to continuously collect traffic status data such as traffic flow, average speed, and road occupancy. Traffic management platforms need to use this data to promptly identify abnormal traffic events such as accidents, sudden congestion, road construction, severe weather effects, and sensor malfunctions.

[0003] Existing methods for detecting traffic flow anomalies typically employ fixed thresholds, sliding statistics, traditional machine learning, time series prediction errors, autoencoder reconstruction errors, or spatiotemporal graph neural networks. Among these, spatiotemporal graph neural networks can model the spatial relationships between different traffic monitoring nodes by incorporating road topology and characterize the process of traffic state changes by combining time series models.

[0004] However, real traffic flow exhibits significant daily, weekly, and nodal variations. Normal fluctuations, such as those occurring during morning and evening rush hours and differences between weekdays and weekends, can easily approximate anomalous disturbances numerically. Furthermore, ordinary reconstruction models may also produce good reconstructions of anomalous segments, leading to a decrease in the discriminative power of anomalous scores. Existing methods, when directly modeling based on the original traffic conditions, struggle to simultaneously distinguish between normal cyclical components, anomalous disturbance components, and the propagation relationships of anomalous disturbances between nodes. Therefore, identifying node-level traffic anomalies in traffic state data mixed with normal cyclical fluctuations and anomalous disturbances has become a pressing problem. Summary of the Invention

[0005] The purpose of this application is to provide a traffic flow anomaly detection method, device, equipment and medium based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling, aiming to solve the technical problem of how to identify node-level traffic anomalies in traffic state data mixed with normal periodic fluctuations and abnormal disturbances.

[0006] To achieve the above objectives, this application proposes a traffic flow anomaly detection method based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling, the method comprising: Obtain a traffic state window and a traffic graph structure. The traffic state window includes traffic state vectors of multiple traffic monitoring nodes in multiple consecutive time slices, and the traffic graph structure includes an adjacency matrix corresponding to the multiple traffic monitoring nodes. A window-level periodic baseline sequence is generated based on the day type, intraday time location, and node adaptive parameters of each traffic monitoring node for each time slice. Generate a periodic residual sequence based on the traffic state window and the window-level periodic reference sequence; The periodic residual sequence is propagated spatially using the adjacency matrix, and the propagation result is time-dependently encoded to obtain a spatiotemporal encoded representation of the periodic residual. The periodic residual spatiotemporal encoded representation is matched with the prototype memory to obtain a memory-enhanced feature sequence, and the periodic residual sequence is reconstructed based on the memory-enhanced feature sequence to obtain the final reconstruction error; The anomaly score is calculated based on the final reconstruction error, and the anomaly detection result is output based on the anomaly score and the node anomaly threshold.

[0007] Furthermore, to achieve the above objectives, this application also proposes a traffic flow anomaly detection device based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling, the device comprising: The data acquisition module is used to acquire a traffic state window and a traffic graph structure. The traffic state window includes traffic state vectors of multiple traffic monitoring nodes in multiple consecutive time slices, and the traffic graph structure includes an adjacency matrix corresponding to the multiple traffic monitoring nodes. The benchmark generation module is used to generate a window-level periodic benchmark sequence based on the day type, intraday time location, and node adaptive parameters of each traffic monitoring node for each time slice. The sequence decoupling module is used to generate a periodic residual sequence based on the traffic state window and the window-level periodic reference sequence; The spatiotemporal coding module is used to perform spatial graph propagation on the periodic residual sequence according to the adjacency matrix, and to perform time-dependent coding on the spatial graph propagation result to obtain the spatiotemporal coded representation of the periodic residual; The sequence reconstruction module is used to match the periodic residual spatiotemporal encoded representation with the prototype memory to obtain a memory-enhanced feature sequence, and reconstruct the periodic residual sequence based on the memory-enhanced feature sequence to obtain the final reconstruction error; The result output module is used to calculate the anomaly score based on the final reconstruction error, and output the anomaly detection result based on the anomaly score and the node anomaly threshold.

[0008] Furthermore, to achieve the above objectives, this application also proposes a traffic flow anomaly detection device based on periodic residual decoupling and memory-enhanced spatiotemporal map modeling. The device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor. The computer program is configured to implement the steps of the traffic flow anomaly detection method based on periodic residual decoupling and memory-enhanced spatiotemporal map modeling as described above.

[0009] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements the steps of the traffic flow anomaly detection method based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling as described above.

[0010] One or more technical solutions proposed in this application have at least the following technical effects: First, traffic state windows and traffic map structures are obtained. The traffic state window represents the traffic state changes of multiple traffic monitoring nodes within a continuous time slice, and the traffic map structure represents the adjacency relationships between these nodes. This provides a data foundation for subsequent anomaly detection based on time changes and node relationships. Then, a window-level periodic baseline sequence is generated based on the day type, intraday time location, and node adaptive parameters of each traffic monitoring node for each time slice. This window-level periodic baseline sequence characterizes the normal periodic state under the corresponding time slice and traffic monitoring node, facilitating the subsequent separation of normal periodic components from the traffic state data. Next, a periodic residual sequence is generated based on the traffic state window and the window-level periodic baseline sequence. This periodic residual sequence represents the deviation of the actual traffic state from the normal periodic state, reducing normal periodic fluctuations such as morning / evening rush hours and differences between weekdays and weekends. To mitigate interference with anomaly identification, this paper further describes a method for propagating the periodic residual sequence using a spatial graph based on the adjacency matrix, and then performing time-dependent encoding on the propagation results to obtain a spatiotemporal encoded representation of the periodic residual. This allows for the joint representation of node association information and continuous time variation information within the periodic residual. Subsequently, the spatiotemporal encoded representation of the periodic residual is matched with a prototype memory to obtain a memory-enhanced feature sequence. Based on this memory-enhanced feature sequence, the periodic residual sequence is reconstructed to obtain the final reconstruction error. This ensures that the reconstruction result revolves around the normal residual pattern while retaining error information that deviates from the normal residual pattern. Finally, an anomaly score is calculated based on the final reconstruction error, and the anomaly detection result is output based on the anomaly score and node anomaly threshold. This allows the anomaly detection result to be mapped to a specific traffic monitoring node and time slice. Therefore, this application can identify node-level traffic anomalies in traffic state data that is a mixture of normal periodic fluctuations and anomalous disturbances. Attached Figure Description

[0011] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0012] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0013] Figure 1 This is a flowchart illustrating the first embodiment of the traffic flow anomaly detection method based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling in this application. Figure 2 This is a flowchart illustrating the second embodiment of the traffic flow anomaly detection method based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling in this application. Figure 3 This is a schematic diagram of the module structure of the traffic flow anomaly detection device based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling according to an embodiment of this application. Figure 4 This is a schematic diagram of the equipment structure of the hardware operating environment involved in the traffic flow anomaly detection method based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling in the embodiments of this application.

[0014] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0015] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.

[0016] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.

[0017] It should be noted that the executing entity of this application embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or an electronic device or anomaly detection system capable of performing the above functions. The following description uses an anomaly detection system as an example to illustrate this embodiment and the subsequent embodiments.

[0018] The traffic status data, traffic map structure data, and anomaly detection result data involved in this application can all be obtained from authorized traffic detection equipment, traffic management platforms, or roadside sensing equipment. The collection, use, and processing of the relevant data comply with applicable laws, regulations, and data management requirements.

[0019] Based on this, the first embodiment of this application provides a traffic flow anomaly detection method based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling, referring to... Figure 1 , Figure 1This is a flowchart illustrating the first embodiment of the traffic flow anomaly detection method based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling in this application.

[0020] In this embodiment, the traffic flow anomaly detection method based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling includes steps S10 to S60: Step S10: Obtain the traffic state window and traffic graph structure. The traffic state window includes traffic state vectors of multiple traffic monitoring nodes in multiple consecutive time slices. The traffic graph structure includes the adjacency matrix corresponding to the multiple traffic monitoring nodes. It should be noted that a traffic state window refers to a data segment composed of traffic state vectors from multiple traffic monitoring nodes within a continuous time slice. A traffic state vector is a set of variables characterizing the traffic operation state of a single traffic monitoring node within a time slice, and may include traffic flow, average speed, and road occupancy. A traffic graph structure refers to graph data used to characterize the road connectivity or spatial relationships between traffic monitoring nodes. An adjacency matrix is ​​a matrix used to record the connection strength or association strength between traffic monitoring nodes.

[0021] In one example, the traffic map structure can be represented as: in, Represents the set of traffic monitoring nodes. A represents the road connection relationship or spatial association relationship between nodes, and A represents the adjacency matrix.

[0022] The traffic state vector of traffic monitoring node i in time slice t can be represented as: in, Indicates traffic flow. Indicates average speed. F represents the road occupancy rate, and F represents the traffic variable dimension.

[0023] Understandably, this involves acquiring traffic status data from multiple traffic monitoring nodes within consecutive time slices and arranging them into traffic status windows according to sampling time and node number. Traffic monitoring nodes can be fixed detectors, geomagnetic sensors, video detection equipment, roadside sensing devices, or the detection locations corresponding to vehicle-to-everything (V2X) terminals. If missing data exists in the same time slice, it can be filled using data from adjacent time slices, historical data from the same time location within the same day, or data from adjacent nodes. If there are discrepancies in the upload times of different devices, time alignment can be achieved using a unified sampling interval. The traffic map structure can be constructed based on road topology connections, upstream and downstream relationships, road segment distances, or traffic function similarities. Elements in the adjacency matrix are used to indicate whether there is a connection or association between two traffic monitoring nodes.

[0024] During the model training phase, historical traffic state data can be divided into training, validation, and test sets. The training set is used to learn shared periodic templates, node adaptive parameters, spatiotemporal coding parameters, prototype memory parameters, decoder parameters, and anomaly scoring parameters. The validation set is used to determine node anomaly thresholds. The test set or online real-time data is used for anomaly detection and does not participate in model parameter updates. In scenarios without reliable anomaly labels, training samples can be constructed based on historical traffic state windows, intraday time locations, and daily pattern categories. The spatiotemporal coding parameters, prototype memory parameters, and decoder parameters are trained using the periodic residual sequence as the reconstruction target, and the node anomaly threshold is determined based on the reconstruction error distribution on the validation set. This step, by acquiring the traffic state window and traffic map structure, provides a unified data input for subsequent periodic benchmark construction, periodic residual decoupling, and spatial map propagation, ensuring that traffic state data corresponds to the road network node relationships.

[0025] Step S20: Generate a window-level periodic benchmark sequence based on the day type, intraday time location, and node adaptive parameters of each traffic monitoring node for each time slice. It should be noted that "day type category" refers to the data category used to distinguish traffic patterns on different dates, which can include weekdays, weekends, holidays, the day before a holiday, and the day after a holiday. "Intraday time location" refers to the sampling location corresponding to a time slice within a day. "Node adaptive parameters" refers to the periodic baseline adjustment parameters set separately for different traffic monitoring nodes, which can include node scaling vectors and node bias vectors. "Window-level periodic baseline sequence" refers to the normal periodic state sequence corresponding to the traffic state window on the time slice and traffic monitoring node.

[0026] Understandably, the day type and intraday time location corresponding to each time slice are determined based on the timestamp, and the corresponding shared cycle prototype is obtained from the shared cycle template. The shared cycle template is used to store the basic traffic cycle status under different day type and intraday time locations. The shared cycle template can be represented as: in, This represents the shared periodic template, C represents the number of daily types, P represents the number of sampling time periods within a day, and F represents the traffic variable dimension.

[0027] For time slice t, according to day type category and intraday time position Extract the shared cycle prototype: in, This represents the shared period prototype corresponding to time slice t.

[0028] For each traffic monitoring node, the shared periodic prototype is adjusted using node adaptive parameters to obtain the node-level periodic benchmark for the corresponding time slice. The node-level periodic benchmark can be expressed as: in, This represents the node-level periodic reference for traffic monitoring node i in time slice t. This represents the node scaling vector of traffic monitoring node i. Let i represent the node bias vector of traffic monitoring node i. This indicates element-wise multiplication.

[0029] The node-level periodic reference matrix corresponding to time slice (t) can be represented as: Subsequently, the node-level periodic benchmarks of each traffic monitoring node are combined in time slice order to form a window-level periodic benchmark sequence. The preset sampling interval can be determined based on the data reporting cycle of the traffic detection equipment, such as 5 minutes or 1 minute; the preset daily pattern category set can be determined based on the calendar data used by the traffic management platform. This step generates the window-level periodic benchmark sequence through daily pattern category, intraday time location, and node adaptive parameters, combining the normal traffic cycle state at the same time location with the local differences of different traffic monitoring nodes, providing a data basis for distinguishing periodic components and aperiodic disturbances.

[0030] Step S30: Generate a periodic residual sequence based on the traffic state window and the window-level periodic reference sequence; It should be noted that the periodic residual sequence refers to the difference sequence between the traffic state window and the window-level periodic reference sequence, used to represent the part of the traffic state that is not represented by the normal periodic reference. The periodic residual vector refers to the difference vector between the traffic state vector of a single traffic monitoring node within a time slice and the corresponding node-level periodic reference.

[0031] Understandably, the traffic state window and window-level periodic reference sequence are aligned according to the dimensions of time slice, traffic monitoring node, and traffic variable. For the same time slice and the same traffic monitoring node, the traffic state vector is subtracted from the corresponding node-level periodic reference to obtain the periodic residual vector. The periodic residual matrix of time slice t can be expressed as: in, This represents the traffic state matrix for time slice t. The node-level periodic reference matrix represents time slice t. This represents the periodic residual matrix for time slice t.

[0032] The periodic residual vectors of each traffic monitoring node within the same time slice are arranged in node order to obtain the periodic residual matrix; then, the periodic residual matrices of multiple consecutive time slices are arranged in chronological order to obtain the periodic residual sequence. The periodic residual sequence can be represented as: in, This represents a periodic residual sequence consisting of continuous time slices of length L, where L represents the length of the traffic state window.

[0033] This step generates a periodic residual sequence, which transforms the original traffic state into a deviation representation relative to the normal periodic benchmark, reducing the interference of morning and evening peak hours, weekday and weekend differences, and node size differences on subsequent anomaly scoring.

[0034] Step S40: Perform spatial graph propagation on the periodic residual sequence according to the adjacency matrix, and perform time-dependent encoding on the spatial graph propagation result to obtain the spatiotemporal encoded representation of the periodic residual; It should be noted that spatial graph propagation refers to the processing of transmitting and aggregating periodic residual information between traffic monitoring nodes based on the adjacency matrix. Time-dependent encoding refers to the processing of temporal representation of spatial propagation results within continuous time slices. Periodic residual spatiotemporal encoding representation refers to residual features that simultaneously contain node spatial correlation information and temporal variation information.

[0035] Understandably, the residual information transmission relationship between each traffic monitoring node is first determined based on the adjacency matrix. In one example, the identity matrix is ​​added to the adjacency matrix to obtain a self-connected adjacency matrix: Where A represents the adjacency matrix. Represents an N-order identity matrix. This represents a self-connected adjacency matrix.

[0036] Generate the degree matrix based on the self-join adjacency matrix: Where D represents the degree matrix, This represents the i-th diagonal element in the degree matrix.

[0037] Symmetric normalization of the self-join adjacency matrix yields the normalized adjacency matrix: in, This represents the normalized adjacency matrix.

[0038] The periodic residual matrix corresponding to each time slice in the periodic residual sequence is weighted and aggregated between nodes to obtain the spatial propagation result. This spatial propagation result is then subjected to linear transformation and nonlinear activation to form a spatially encoded sequence. The spatially encoded representation corresponding to time slice t can be expressed as: in, This represents the periodic residual matrix for time slice t. Represents the parameters of the linear transformation. Represents a non-linear activation function. This represents the spatial encoding of time slice t.

[0039] Subsequently, the spatially encoded sequence is converted into a query matrix, a key matrix, and a value matrix: in, Represents a spatially encoded sequence. Represents the query matrix. Represents the key matrix. Represents a value matrix, , and This represents the corresponding linear mapping parameters (learnable parameter matrix).

[0040] The time-coded sequence can be represented as: in, Represents a time-coded sequence. Represents the dimension of the latent space.

[0041] Finally, the spatial and temporal encoded sequences are concatenated along the feature dimension, and a linear transformation is performed to obtain the spatiotemporal encoded representation of the periodic residuals. This step, through spatial graph propagation and temporal dependency encoding, transforms the node association changes and continuous temporal changes in the periodic residual sequence into a unified feature representation, providing a spatiotemporal feature foundation for subsequent prototype matching and residual reconstruction.

[0042] Step S50: Match the periodic residual spatiotemporal encoding representation with the prototype memory to obtain a memory-enhanced feature sequence, and reconstruct the periodic residual sequence based on the memory-enhanced feature sequence to obtain the final reconstruction error; It should be noted that the prototype memory refers to a feature set composed of multiple normal residual pattern prototypes. A normal residual pattern prototype is a vector used to represent common periodic residual features under historical normal traffic conditions. The memory-enhanced feature sequence refers to the feature sequence formed after matching the spatiotemporal encoded representation of periodic residuals with normal residual pattern prototypes. The final reconstruction error refers to the error between the periodic residual sequence and the final reconstructed residual sequence.

[0043] Understandably, this involves extracting the latent vectors corresponding to each time slice and each traffic monitoring node from the spatiotemporal encoding representation of the periodic residuals, and calculating the distance between the latent vectors and the normal residual pattern prototypes in the prototype memory. The prototype memory can be represented as: Where M represents the prototype memory, This represents the prototype of the k-th normal residual pattern. Indicates the number of prototypes.

[0044] When using Euclidean distance, the distance between the latent vector and the normal residual model prototype can be expressed as: in, This represents the latent vector corresponding to time slice t and traffic monitoring node i. Representing implicit vectors Compared with the k-th normal residual pattern prototype The distance between them.

[0045] Select a matching prototype from the prototype distance set: Memory enhancement representation can be expressed as: in, This indicates the prototype number corresponding to the matched prototype. Representing implicit vectors The corresponding memory enhancement representation.

[0046] Next, the memory-enhanced representations are arranged according to the time slices and traffic monitoring nodes to obtain the memory-enhanced feature sequence. The periodic residual sequence is reconstructed based on the memory-enhanced feature sequence to obtain the reconstructed residual sequence. The final reconstruction error is then obtained based on the periodic residual sequence and the reconstructed residual sequence. The number of prototypes in the prototype memory can be determined based on the number of prototype activations in the historical training data; for example, the preset number of prototypes can be selected between 8 and 128. When there are many road network nodes or many types of traffic state fluctuations, a larger preset number of prototypes can be used. This step matches the spatiotemporal encoding representation of the periodic residuals using the prototype memory, enabling the reconstruction process to generate the reconstructed residual sequence based on the feature representation corresponding to the normal residual pattern, and ensuring that inputs deviating from the normal residual pattern contribute to the difference in the final reconstruction error.

[0047] Step S60: Calculate the anomaly score based on the final reconstruction error, and output the anomaly detection result based on the anomaly score and the node anomaly threshold.

[0048] It should be noted that the anomaly score refers to a numerical value used to characterize the degree to which a traffic monitoring node deviates from normal traffic conditions within a time slice. The node anomaly threshold is a preset threshold used to determine whether a traffic monitoring node is in an abnormal state, and can be determined based on the anomaly score quantiles of historical normal samples, validation set statistical results, or traffic management business rules. The anomaly detection result refers to the output information obtained based on the anomaly score and the node anomaly threshold, which may include anomaly nodes, anomaly times, and anomaly alarm information.

[0049] Understandably, the multivariate error vector for each traffic monitoring node in each time slice is extracted from the final reconstruction error, and anomaly scores are calculated based on these multivariate error vectors. The anomaly score can be calculated using the multivariate Gaussian negative log-likelihood value; for simplification, the Mahalanobis distance term in the multivariate Gaussian negative log-likelihood function can also be used. When using the multivariate Gaussian negative log-likelihood value, the anomaly score can be expressed as: in, This represents the anomaly score of traffic monitoring node i in time slice t. This represents the multivariate error vector of traffic monitoring node i in time slice t. This represents the preset error mean vector. Let F represent the preset error covariance matrix, and let F represent the dimension of the traffic variable.

[0050] To avoid the default error covariance matrix being non-invertible, a default regularization term can be added to the diagonal of the default error covariance matrix to obtain a regularized covariance matrix: in, Describes the regularized covariance matrix. This indicates the preset regular expression terms. This represents an F-order identity matrix, where F represents the dimension of the traffic variables. Preset regularization terms can be used... to The values ​​can be taken from between, and the specific values ​​can be determined according to the variable scale of the multivariate error vector.

[0051] Node anomaly thresholds can be set individually for each node. For example, a preset quantile threshold can be determined based on the distribution of anomaly scores for the corresponding traffic monitoring node in historical normal samples. The preset quantile threshold can be selected between 90% and 99.9%, and adjusted according to actual false alarm control requirements. After comparing the anomaly scores with the corresponding node anomaly thresholds, the anomaly discrimination result is obtained, and the anomaly detection result is output. This step generates node-level anomaly detection results through the final reconstruction error and node anomaly thresholds, enabling the anomaly detection results to be mapped to specific traffic monitoring nodes and specific time slices, facilitating subsequent traffic operation monitoring, anomaly alarms, and event analysis.

[0052] This embodiment represents the normal periodic traffic state through a window-level periodic benchmark sequence, extracts the residual portion deviating from the normal periodic state through a periodic residual sequence, obtains the spatiotemporal encoded representation of the periodic residual through spatial graph propagation and time-dependent encoding, and calculates anomaly scores using a prototype memory and reconstruction error. This forms a processing flow from traffic state acquisition, periodic residual decoupling, spatiotemporal feature extraction, normal residual pattern constraint to node-level anomaly output. This flow reduces the interference of normal periodic fluctuations on anomaly detection, improves the stability of node-level traffic anomaly identification, and provides detection results that correspond to nodes and time slices for traffic anomaly alarms.

[0053] As an example, the node adaptive parameters include a node scaling vector and a node bias vector. The step of generating a window-level periodic reference sequence based on the day type category, intraday time position, and node adaptive parameters of each traffic monitoring node for each time slice includes: determining the day type category of each time slice based on the timestamp of each time slice and a preset day type category set; determining the intraday time position of each time slice based on the timestamp of each time slice and a preset sampling interval; extracting the shared period prototype corresponding to each time slice from the shared period template based on the day type category and intraday time position of each time slice; for each traffic monitoring node, multiplying the node scaling vector of the corresponding traffic monitoring node element-wise with the shared period prototype to obtain the node scaling result; adding the node scaling result to the node bias vector of the corresponding traffic monitoring node to obtain the node-level periodic reference of each traffic monitoring node in each time slice; and combining the node-level periodic references in the order of the time slices to obtain the window-level periodic reference sequence.

[0054] It should be noted that node adaptive parameters refer to parameters used to adjust the shared cycle prototype to adapt to the normal traffic conditions of different traffic monitoring nodes. Node scaling vectors refer to vectors used to adjust the amplitude ratios of traffic variables such as traffic flow, average speed, and road occupancy. Node bias vectors refer to vectors used to adjust the baseline levels of traffic variables. Shared cycle templates refer to basic cycle traffic state templates stored according to daily type and intraday time location. Shared cycle prototypes refer to the basic cycle traffic state vectors extracted from the shared cycle templates, corresponding to the daily type and intraday time location of a time slice. The preset daily type set can be weekdays and weekends, or it can include holidays, the day before a holiday, and the day after a holiday; the preset daily type set can be determined based on the calendar information used by the traffic management platform. The preset sampling interval can be 1 minute, 5 minutes, 15 minutes, or 30 minutes; the specific value can be determined based on the data reporting cycle of the traffic detection equipment.

[0055] Understandably, the first step is to determine the date attribute based on the timestamp of each time slice, and then match the date attribute with a preset set of day type categories to obtain the day type category for each time slice. For example, if the date corresponding to the timestamp is from Monday to Friday and is not a holiday, the day type category can be determined as a weekday; if the date corresponding to the timestamp is a Saturday, Sunday, or a holiday, the day type category can be determined as a weekend or holiday.

[0056] Based on the timestamps of each time slice and the preset sampling interval, the intraday time position corresponding to each time slice within a day is determined. For example, when the preset sampling interval is 5 minutes, there can be 288 sampling positions per day, and the hours and minutes corresponding to the time slices can be converted into corresponding sampling positions.

[0057] Next, based on the daily pattern category and intraday time location of each time slice, the corresponding shared cycle prototype is extracted from the shared cycle template. The shared cycle prototype has the same variable dimension as the traffic state vector, enabling the shared cycle prototype to correspond to traffic variables such as traffic flow, average speed, and road occupancy.

[0058] For each traffic monitoring node, the node scaling vector of the corresponding traffic monitoring node is multiplied element-wise with the shared periodic prototype to obtain the node scaling result. The node scaling result is used to represent the variable scaling result of the shared periodic prototype at that traffic monitoring node.

[0059] The node scaling result is added to the node bias vector of the corresponding traffic monitoring node to obtain the node-level periodic reference for each traffic monitoring node in each time slice. The node-level periodic reference corresponds one-to-one with the traffic state vector of the corresponding time slice and the corresponding traffic monitoring node in terms of variable dimensions.

[0060] Finally, the node-level periodic references of all traffic monitoring nodes under each time slice are combined according to the time slice order to obtain the window-level periodic reference sequence. The window-level periodic reference sequence has the same time slice order and traffic monitoring node arrangement order as the traffic status window.

[0061] This example extracts a shared cycle prototype by day type and intraday time location, and uses node scaling vector and node bias vector to perform node-level adjustments on the shared cycle prototype, so that the window-level cycle benchmark sequence can simultaneously reflect the normal cycle status of different date types, different intraday time locations and different traffic monitoring nodes, thereby improving the pertinence of subsequent cycle residual decoupling.

[0062] As an example, the step of generating a periodic residual sequence based on the traffic state window and the window-level periodic reference sequence includes: aligning the traffic state vector in the traffic state window and the node-level periodic reference in the window-level periodic reference sequence according to time slices and traffic monitoring nodes; subtracting the node-level periodic reference from the traffic state vector corresponding to the same time slice and the same traffic monitoring node to obtain a periodic residual vector; arranging the periodic residual vectors corresponding to the same time slice according to the traffic monitoring nodes to obtain a periodic residual matrix; and combining the periodic residual matrix according to the time slice order to obtain a periodic residual sequence.

[0063] It should be noted that the node-level periodic baseline refers to the normal periodic state reference vector corresponding to a single traffic monitoring node and a single time slice. The periodic residual vector is the deviation vector of the traffic state vector relative to the node-level periodic baseline. The periodic residual matrix is ​​the matrix formed by arranging the periodic residual vectors of each traffic monitoring node in the same time slice according to node order. The periodic residual sequence is the data sequence composed of the periodic residual matrices of multiple consecutive time slices in chronological order.

[0064] Understandably, when generating the periodic residual sequence, the traffic state vector in the traffic state window is first established to correspond with the node-level periodic reference in the window-level periodic reference sequence according to the time slice identifier and the traffic monitoring node identifier. The time slice identifier can be determined by the sampling timestamp, and the traffic monitoring node identifier can be determined by the detector number, road segment number, or node number.

[0065] Next, for the same time slice and the same traffic monitoring node, the traffic state vector is subtracted from the corresponding node-level periodic baseline to obtain the periodic residual vector. The variable dimensions of the periodic residual vector are consistent with those of the traffic state vector. For example, when the traffic state vector includes traffic flow, average speed, and road occupancy, the periodic residual vector also includes the corresponding three residual components.

[0066] Based on the node arrangement order of traffic monitoring nodes in the traffic map structure, multiple periodic residual vectors corresponding to the same time slice are arranged to obtain the periodic residual matrix. The node arrangement order is kept consistent throughout the same detection task, so that subsequent spatial map propagation can read the periodic residual matrix according to the node order corresponding to the adjacency matrix.

[0067] Based on this, multiple periodic residual matrices are combined according to the time slice sequence to obtain a periodic residual sequence. The periodic residual sequence has the same time length as the traffic state window and serves as the input for subsequent spatial graph propagation and time-dependent encoding.

[0068] This example uses alignment processing between the traffic state window and the window-level periodic baseline sequence to form a periodic residual sequence based on traffic monitoring nodes and time slices. This process preserves the deviation between the normal periodic state and the actual traffic state, reducing the interference caused by normal periodic fluctuations when modeling directly based on the original traffic state.

[0069] As an example, the steps of performing spatial graph propagation on the periodic residual sequence based on the adjacency matrix and performing time-dependent encoding on the spatial graph propagation result to obtain the spatiotemporal encoded representation of the periodic residual include: adding the identity matrix to the adjacency matrix to obtain a self-connected adjacency matrix; generating a degree matrix based on the sum of the elements in each row of the self-connected adjacency matrix, and performing symmetric normalization on the self-connected adjacency matrix based on the degree matrix to obtain a normalized adjacency matrix; for each time slice of the periodic residual matrix corresponding to the periodic residual sequence, using each element in the normalized adjacency matrix as the inter-node residual transfer weight, and applying the weights to each element in the periodic residual matrix of the corresponding time slice. The periodic residual vectors of traffic monitoring nodes are weighted and summed to obtain the neighborhood aggregated residual matrix corresponding to each time slice. A linear transformation and nonlinear activation process are performed on the neighborhood aggregated residual matrix corresponding to each time slice to obtain a spatial encoding sequence. The spatial encoding sequence is converted into a query matrix, a key matrix, and a value matrix, respectively. Temporal attention weights are calculated based on the query matrix and the key matrix, and a temporal encoding sequence is obtained based on the temporal attention weights and the value matrix. The spatial encoding sequence and the temporal encoding sequence are concatenated along the feature dimension to obtain a concatenated encoding sequence. A linear transformation is performed on the concatenated encoding sequence to obtain the spatiotemporal encoding representation of the periodic residuals.

[0070] It should be noted that a self-join adjacency matrix is ​​a matrix formed by adding the self-connection relationships of nodes to an adjacency matrix. A degree matrix is ​​a diagonal matrix formed by summing the connection weights of each node in a self-join adjacency matrix. A normalized adjacency matrix is ​​a node propagation weight matrix formed by normalizing the self-join adjacency matrix based on the degree matrix. A neighborhood aggregation residual matrix is ​​a matrix obtained by aggregating the periodic residual vectors of adjacent nodes within the same time slice based on the normalized adjacency matrix. A spatial coding sequence is a sequence formed by performing feature transformation on the neighborhood aggregation residual matrices of multiple time slices. The query matrix, key matrix, and value matrix can be temporal attention calculation matrices obtained from the spatial coding sequence through different linear mappings. Temporal attention weights are weights used to represent the degree of correlation between different time slices. A concatenated coding sequence is a coding sequence formed by concatenating spatial and temporal coding sequences along the feature dimension.

[0071] Understandably, the identity matrix is ​​first added to the adjacency matrix to obtain a self-connected adjacency matrix. The order of the identity matrix is ​​consistent with the number of traffic monitoring nodes, ensuring that each traffic monitoring node retains its own periodic residual information during spatial graph propagation.

[0072] A degree matrix is ​​generated by summing the elements of each row in the self-join adjacency matrix. This degree matrix is ​​then used to symmetrically normalize the self-join adjacency matrix, resulting in a normalized adjacency matrix. The elements of the normalized adjacency matrix serve as weights for inter-node residual propagation, which are used for subsequent aggregation of periodic residual vectors between nodes.

[0073] Then, for the periodic residual matrix corresponding to each time slice in the periodic residual sequence, the periodic residual vectors of each traffic monitoring node and its adjacent traffic monitoring nodes are weighted and summed according to the node residual propagation weights recorded in the normalized adjacency matrix to obtain the neighborhood aggregated residual matrix corresponding to each time slice. The node order of the neighborhood aggregated residual matrix is ​​consistent with the node order of the periodic residual matrix.

[0074] Linear transformation and nonlinear activation are applied to the neighborhood aggregation residual matrix corresponding to each time slice to obtain the spatial encoding sequence. The linear transformation is used to map the neighborhood aggregation residual matrix to a preset latent space dimension. The nonlinear activation function can be ReLU (Rectified Linear Unit), LeakyReLU (Leaky Rectified Linear Unit), or GELU (Gaussian Error Linear Unit). The specific function can be determined based on the model training effect and the available computing power.

[0075] Furthermore, the spatial encoding sequence is converted into a query matrix, a key matrix, and a value matrix, respectively. The query matrix and key matrix are used to calculate the attention weights between time slices, and the value matrix is ​​used to generate the corresponding temporal encoding results.

[0076] The temporal attention weights are calculated based on the query matrix and key matrix, and the temporal encoded sequence is obtained based on the temporal attention weights and the value matrix. The temporal attention weights are used to reflect the correlation of periodic residuals between different time slices within the window. The temporal encoded sequence and the spatial encoded sequence have corresponding time slices and traffic monitoring node arrangements.

[0077] Based on this, the spatial and temporal encoded sequences are concatenated along the feature dimension to obtain a concatenated encoded sequence. A linear transformation is then performed on the concatenated encoded sequence to obtain the periodic residual spatiotemporal encoded representation. The preset latent space dimension can be set according to the number of traffic variables, the number of traffic monitoring nodes, and the size of the training samples; for example, it can be selected between 16 and 256.

[0078] This example uses a self-connected adjacency matrix and a normalized adjacency matrix to form residual propagation weights between nodes, and combines them with temporal attention weights to extract residual correlations between consecutive time slices. This enables the spatiotemporal encoding representation of periodic residuals to simultaneously contain node spatial correlations and temporal variation information, thereby improving the feature foundation stability of subsequent prototype matching and residual reconstruction.

[0079] As an example, the step of calculating anomaly scores based on the final reconstruction error and outputting anomaly detection results based on the anomaly scores and node anomaly thresholds includes: extracting multivariate error vectors for each traffic monitoring node in each time slice from the final reconstruction error; inputting the multivariate error vectors, preset error mean vectors, and preset error covariance matrices into a multivariate Gaussian negative log-likelihood function to obtain anomaly scores for each traffic monitoring node in each time slice, wherein the preset error mean vectors and the preset error covariance matrix are statistical parameters determined based on historical normal reconstruction error samples; comparing the anomaly scores with the node anomaly thresholds of the corresponding traffic monitoring nodes to obtain anomaly discrimination results; and outputting anomaly detection results based on the anomaly discrimination results, wherein the anomaly detection results include anomaly nodes, anomaly times, and anomaly alarm information.

[0080] It should be noted that the multivariate error vector refers to the vector composed of reconstruction errors corresponding to multiple traffic variables for the same traffic monitoring node in the same time slice. The preset error mean vector refers to the error mean obtained based on historical normal reconstruction error samples. The preset error covariance matrix refers to the multivariate error covariance obtained based on historical normal reconstruction error samples. The multivariate Gaussian negative log-likelihood function is a function that calculates the anomaly score based on the multivariate error vector, error mean, and error covariance. The node anomaly threshold is a threshold used to determine whether a single traffic monitoring node is abnormal within a time slice.

[0081] Understandably, the multivariate error vector for each traffic monitoring node in each time slice is first extracted from the final reconstruction error. If the traffic state vector includes traffic flow, average speed, and road occupancy, then the multivariate error vector includes the reconstruction error corresponding to these three traffic variables.

[0082] The preset error mean vector and preset error covariance matrix can be obtained statistically from historical normal reconstruction error samples. These historical normal reconstruction error samples can come from normal traffic segments in the training set or from traffic segments in the validation set whose anomaly scores are below a preset screening threshold. The preset screening threshold can be determined based on the distribution of anomaly scores in the validation set; for example, samples below a preset quantile threshold (90% to 99%) can be used as normal reconstruction error samples.

[0083] Then, the multivariate error vector, the preset error mean vector, and the preset error covariance matrix are input into the multivariate Gaussian negative log-likelihood function to obtain the anomaly score of each traffic monitoring node in each time slice. To avoid the preset error covariance matrix being non-invertible, a preset regularization term can be added to the diagonal of the preset error covariance matrix. The preset regularization term can take values ​​between 10^-6 and 10^-2, and the specific value can be determined according to the scale of the error variables.

[0084] The anomaly score is compared with the corresponding node anomaly threshold of the traffic monitoring node to obtain the anomaly identification result. The node anomaly threshold can be set separately for each traffic monitoring node, or grouped by road type or area type; the node anomaly threshold can be determined based on the distribution of anomaly scores of historical normal samples, for example, by taking a preset quantile threshold (90% to 99.9%), or it can be adjusted in conjunction with the false alarm control requirements of the traffic management platform.

[0085] After obtaining the anomaly identification result, the anomaly detection result is output. The anomaly detection result may include the anomaly node, the anomaly time, and the anomaly alarm information; the anomaly alarm information may include the traffic monitoring node number, the road number, the start and end time of the anomaly, and the anomaly score.

[0086] This example calculates anomaly scores using a multivariate error vector, a preset mean error vector, and a preset error covariance matrix, allowing the error correlation between traffic flow, average speed, and road occupancy to participate in anomaly detection. By outputting node-level anomaly detection results through node anomaly thresholds, the correspondence between traffic anomaly location results and traffic monitoring nodes can be improved.

[0087] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to the first embodiment described above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 2 , Figure 2 This is a flowchart illustrating the second embodiment of the traffic flow anomaly detection method based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling of this application. Step S50 of the traffic flow anomaly detection method based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling includes steps S51 to S55: Step S51: Extract the latent vectors corresponding to each time slice and each traffic monitoring node in the periodic residual spatiotemporal coding representation; Step S52: Calculate the distance between the latent vector and each normal residual pattern prototype in the prototype memory bank to obtain the prototype distance set; Step S53: Determine the normal residual pattern prototype with the smallest distance value from the prototype distance set, and use it as the matching prototype corresponding to the latent vector. Step S54: Use the matching prototype as the memory-enhanced representation corresponding to the latent vector, and arrange the memory-enhanced representation according to the time slice and traffic monitoring node to obtain the memory-enhanced feature sequence; Step S55: Perform a two-stage reconstruction of the periodic residual sequence based on the memory-enhanced feature sequence to obtain the final reconstruction error.

[0088] It should be noted that the latent vector refers to the feature vector extracted from the spatiotemporal coding representation of the periodic residuals, corresponding to a time slice and a traffic monitoring node. The prototype distance set refers to the set of distance values ​​between a latent vector and multiple normal residual pattern prototypes in the prototype memory. The matching prototype refers to the normal residual pattern prototype with the smallest distance value in the prototype distance set. The memory-enhanced representation refers to the feature vector obtained by replacing or representing the latent vector with the matching prototype. In this example, the final reconstruction error refers to the error between the periodic residual sequence and the reconstructed periodic residual sequence.

[0089] Understandably, in the spatiotemporal encoding representation of periodic residuals, the corresponding latent vectors are extracted according to the time slice and the location index of the traffic monitoring node. Each latent vector corresponds to the spatiotemporal feature of the periodic residual of the traffic monitoring node in the next time slice, and the dimension of the latent vector is consistent with the dimension of the latent space in the spatiotemporal encoding representation of periodic residuals.

[0090] Then, the distances between the latent vectors and each normal residual pattern prototype in the prototype memory are calculated to obtain the prototype distance set. The distances can be Euclidean or cosine distances; when the latent vectors and normal residual pattern prototypes have been normalized, cosine distance can be used. The preset number of prototypes can be determined based on the complexity of the normal residual patterns in historical traffic data, for example, it can be selected between 8 and 128.

[0091] The normal residual pattern prototype with the smallest distance value is selected from the prototype distance set as the matching prototype corresponding to the latent vector. If multiple normal residual pattern prototypes correspond to the same distance value, one of the normal residual pattern prototypes can be selected according to the prototype number order or according to the prototype's historical matching count.

[0092] Next, the matching prototype is used as the memory-enhanced representation corresponding to the latent vector, and the memory-enhanced representations are combined according to the time slice and traffic monitoring node order to obtain the memory-enhanced feature sequence. The memory-enhanced feature sequence maintains the same time slice order and traffic monitoring node order as the periodic residual spatiotemporal coding representation.

[0093] The periodic residual sequence is reconstructed in two stages based on the memory-enhanced feature sequence to obtain the reconstructed residual sequence. The final reconstruction error is then obtained from the periodic residual sequence and the reconstructed residual sequence. The two-stage reconstruction can first generate an initial reconstruction result, and then generate the final reconstruction result based on the error information corresponding to the initial reconstruction result. The specific reconstruction method can be further explained in the two-stage reconstruction examples.

[0094] This embodiment uses a prototype memory to perform prototype matching on the spatiotemporal encoding representation of periodic residuals, so that the feature sequences entering the reconstruction stage correspond to the prototypes of normal residual patterns. This reduces the situation where abnormal disturbances are directly reconstructed as regular residual patterns, and improves the ability of the final reconstruction error to distinguish abnormal residuals.

[0095] As an example, the step of performing a two-stage reconstruction of the periodic residual sequence based on the memory-enhanced feature sequence to obtain the final reconstruction error includes: inputting the memory-enhanced feature sequence into a first-stage decoder to obtain a first reconstruction residual sequence; obtaining a first reconstruction error based on the periodic residual sequence and the first reconstruction residual sequence; aggregating and normalizing the first reconstruction error in the node dimension and variable dimension to obtain a temporal anomaly attention weight; aggregating and normalizing the first reconstruction error in the time dimension and variable dimension to obtain a spatial anomaly attention weight; generating a temporal bias matrix based on the temporal anomaly attention weight, and generating a spatial bias matrix based on the spatial anomaly attention weight; inputting the memory-enhanced feature sequence, the temporal bias matrix, and the spatial bias matrix into a second-stage decoder to obtain a second reconstruction residual sequence, wherein the first-stage decoder is a residual decoder that does not receive the temporal bias matrix and the spatial bias matrix; and obtaining the final reconstruction error based on the periodic residual sequence and the second reconstruction residual sequence.

[0096] It should be noted that the first-stage decoder refers to a residual decoder whose input is the memory-enhanced feature sequence, used to generate the first reconstructed residual sequence. The first reconstructed residual sequence refers to the periodic residual reconstruction result output by the first-stage decoder. The first reconstruction error refers to the error between the periodic residual sequence and the first reconstructed residual sequence. The temporal anomaly attention weight refers to the temporal weight obtained based on the distribution of the first reconstruction error across different time slices. The spatial anomaly attention weight refers to the node weight obtained based on the distribution of the first reconstruction error across different traffic monitoring nodes. The temporal bias matrix refers to the temporal bias information generated by the temporal anomaly attention weight and used in the second-stage decoder. The spatial bias matrix refers to the spatial bias information generated by the spatial anomaly attention weight and used in the second-stage decoder. The second-stage decoder refers to a residual decoder whose input includes the memory-enhanced feature sequence, the temporal bias matrix, and the spatial bias matrix, used to generate the second reconstructed residual sequence.

[0097] The first reconstructed residual sequence can be represented as: The first reconstruction error can be expressed as: The weight for time anomalies can be obtained by the following formula: The spatial anomaly attention weight can be obtained by the following formula: The time bias matrix and the spatial bias matrix can be expressed as: The second reconstructed residual sequence can be represented as: The final reconstruction error can be expressed as: in, Z represents the first-stage decoder, and Z represents the memory-enhanced feature sequence. Represents the first reconstructed residual sequence. Indicates the first reconstruction error. This indicates that time-related anomalies are given weight. Indicates the first The first reconstruction error aggregate value corresponding to each time slice This represents the first reconstructed error aggregate value corresponding to traffic monitoring node i; a and b represent time slice indices, and i and j represent traffic monitoring node indices. This indicates that the space is unusually focused on weights. Represents the temperature coefficient, and , Represents the time bias matrix. Represents the spatial bias matrix. This indicates the second-stage decoder. Let E represent the second reconstruction residual sequence, and E represent the final reconstruction error.

[0098] Understandably, the memory-enhanced feature sequence is first input into the first-stage decoder to obtain the first reconstructed residual sequence. The first-stage decoder does not receive the temporal bias matrix and spatial bias matrix; the decoding input mainly comes from the normal residual pattern features after prototype matching. The first reconstructed residual sequence has the same time slice order, traffic monitoring node order, and variable dimension as the periodic residual sequence.

[0099] The first reconstruction error is obtained based on the periodic residual sequence and the first reconstruction residual sequence. The first reconstruction error retains the error information corresponding to each time slice, each traffic monitoring node, and each traffic variable, and serves as the data basis for generating the temporal anomaly attention weight and the spatial anomaly attention weight.

[0100] Next, the first reconstruction error is aggregated at both the node and variable dimensions, and the aggregation result is normalized to obtain the time anomaly attention weight. The time anomaly attention weight corresponds to each time slice in the traffic state window and is used to represent the error distribution of each time slice in the first stage of reconstruction.

[0101] The first reconstruction error is aggregated along the time and variable dimensions, and the aggregation result is normalized to obtain the spatial anomaly attention weight. The spatial anomaly attention weight corresponds to each traffic monitoring node and is used to represent the error distribution of each traffic monitoring node in the first stage of reconstruction.

[0102] Subsequently, a temporal bias matrix is ​​generated based on the temporal anomaly attention weights, and a spatial bias matrix is ​​generated based on the spatial anomaly attention weights. The temporal bias matrix corresponds to the relationship between time slices, and the spatial bias matrix corresponds to the relationship between traffic monitoring nodes, enabling the second-stage decoder to receive temporal and spatial information from the reconstruction errors of the first stage.

[0103] The memory-enhanced feature sequence, temporal bias matrix, and spatial bias matrix are input into the second-stage decoder to obtain the second reconstructed residual sequence. The difference between the second-stage decoder and the first-stage decoder is that the first-stage decoder uses the memory-enhanced feature sequence as input to generate the reconstruction result, while the second-stage decoder uses the memory-enhanced feature sequence, temporal bias matrix, and spatial bias matrix as input to generate the reconstruction result. Specifically, the temporal bias matrix can be written into the temporal attention score term of the second-stage decoder, and the spatial bias matrix can be written into the spatial propagation weight term of the second-stage decoder.

[0104] Finally, the final reconstruction error is obtained based on the periodic residual sequence and the second reconstructed residual sequence. The final reconstruction error can be obtained by subtracting the periodic residual sequence and the second reconstructed residual sequence at the corresponding time slice, traffic monitoring node, and traffic variable dimensions, and is used for subsequent anomaly score calculation. The final reconstruction error can be expressed as: Where E represents the final reconstruction error, Represents a periodic residual sequence. This represents the second reconstructed residual sequence.

[0105] This example generates a first reconstruction error through a first-stage decoder, and forms a time bias matrix and a spatial bias matrix based on the first reconstruction error. Then, a second-stage decoder generates a second reconstruction residual sequence, so that the final reconstruction error simultaneously references the normal residual pattern characteristics after prototype matching and the time and spatial distribution information in the first-stage reconstruction error, thereby improving the ability of the final reconstruction error to distinguish between abnormal time slices and abnormal traffic monitoring nodes.

[0106] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the traffic flow anomaly detection method based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling. Any simple modifications based on this technical concept are within the scope of protection of this application.

[0107] This application also provides a traffic flow anomaly detection device based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling. Please refer to [reference needed]. Figure 3 The traffic flow anomaly detection device based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling includes: Data acquisition module 10 is used to acquire a traffic status window and a traffic graph structure. The traffic status window includes traffic status vectors of multiple traffic monitoring nodes in multiple consecutive time slices, and the traffic graph structure includes an adjacency matrix corresponding to the multiple traffic monitoring nodes. The benchmark generation module 20 is used to generate a window-level periodic benchmark sequence based on the day type, intraday time location, and node adaptive parameters of each traffic monitoring node for each time slice. The sequence decoupling module 30 is used to generate a periodic residual sequence based on the traffic state window and the window-level periodic reference sequence; The spatiotemporal coding module 40 is used to perform spatial graph propagation on the periodic residual sequence according to the adjacency matrix, and to perform time-dependent coding on the spatial graph propagation result to obtain the spatiotemporal coded representation of the periodic residual; The sequence reconstruction module 50 is used to match the periodic residual spatiotemporal coding representation with the prototype memory to obtain a memory-enhanced feature sequence, and reconstruct the periodic residual sequence based on the memory-enhanced feature sequence to obtain the final reconstruction error; The result output module 60 is used to calculate the anomaly score based on the final reconstruction error, and output the anomaly detection result based on the anomaly score and the node anomaly threshold.

[0108] The traffic flow anomaly detection device based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling provided in this application employs the traffic flow anomaly detection method based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling in the above embodiments. It can solve the technical problem of identifying node-level traffic anomalies in traffic state data mixed with normal periodic fluctuations and abnormal disturbances. Compared with the prior art, the beneficial effects of the traffic flow anomaly detection device based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling provided in this application are the same as those of the traffic flow anomaly detection method based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling provided in the above embodiments. Furthermore, other technical features in the traffic flow anomaly detection device based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.

[0109] This application provides a traffic flow anomaly detection device based on periodic residual decoupling and memory-enhanced spatiotemporal map modeling. The traffic flow anomaly detection device based on periodic residual decoupling and memory-enhanced spatiotemporal map modeling includes: at least one processor; and a memory communicatively connected to at least one processor; wherein the memory stores instructions executable by at least one processor, and the instructions are executed by at least one processor to enable at least one processor to execute the traffic flow anomaly detection method based on periodic residual decoupling and memory-enhanced spatiotemporal map modeling in the above embodiment 1.

[0110] The following is for reference. Figure 4 This document illustrates a structural schematic diagram of a traffic flow anomaly detection device suitable for implementing the embodiments of this application based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling. The traffic flow anomaly detection device based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling in the embodiments of this application may include, but is not limited to, mobile phones, laptops, digital radio receivers, PDAs (Personal Digital Assistants), tablets, PMPs (Portable Media Players), vehicle-mounted terminals, and fixed terminals such as digital televisions and desktop computers. Figure 4 The traffic flow anomaly detection device based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.

[0111] like Figure 4As shown, the traffic flow anomaly detection device based on periodic residual decoupling and memory-enhanced spatiotemporal map modeling may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to the program stored in ROM 1002 (Read-Only Memory) or the program loaded from storage device 1003 into RAM 1004 (Random Access Memory). RAM 1004 also stores various programs and data required for the operation of the traffic flow anomaly detection device based on periodic residual decoupling and memory-enhanced spatiotemporal map modeling. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via bus 1005. I / O interface 1006 is also connected to the bus. Typically, the following systems can be connected to I / O interface 1006: input devices 1007 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, LCDs (Liquid Crystal Displays), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. Communication device 1009 allows the traffic flow anomaly detection device based on periodic residual decoupling and memory-enhanced spatiotemporal map modeling to exchange data with other devices wirelessly or via wired communication. Although the figure shows a traffic flow anomaly detection device based on periodic residual decoupling and memory-enhanced spatiotemporal map modeling with various systems, it should be understood that it is not required to implement or possess all the systems shown. More or fewer systems can be implemented alternatively.

[0112] The traffic flow anomaly detection device based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling provided in this application employs the traffic flow anomaly detection method based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling in the above embodiments. It can solve the technical problem of identifying node-level traffic anomalies in traffic state data mixed with normal periodic fluctuations and abnormal disturbances. Compared with the prior art, the beneficial effects of the traffic flow anomaly detection device based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling provided in this application are the same as those of the traffic flow anomaly detection method based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling provided in the above embodiments. Furthermore, other technical features of this traffic flow anomaly detection device based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling are the same as those disclosed in the previous embodiment, and will not be repeated here.

[0113] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.

[0114] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0115] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, which are used to execute the traffic flow anomaly detection method based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling in the above embodiments.

[0116] The computer-readable storage medium provided in this application can be a tangible medium capable of storing computer programs, such as a hard disk, random access memory, read-only memory, flash memory, optical storage device, or magnetic storage device. When the computer program is executed by a processor, it implements the above-described traffic flow anomaly detection method based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling.

[0117] The aforementioned computer-readable storage medium may be included in a traffic flow anomaly detection device based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling; or it may exist independently and not be assembled into a traffic flow anomaly detection device based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling.

[0118] The aforementioned computer-readable storage medium carries one or more programs. When these programs are executed by a traffic flow anomaly detection device based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling, the device causes the following: it acquires a traffic state window and a traffic map structure, wherein the traffic state window includes traffic state vectors of multiple traffic monitoring nodes in multiple consecutive time slices, and the traffic map structure includes an adjacency matrix corresponding to the multiple traffic monitoring nodes; and it performs the following based on the daily type of each time slice, intraday time location, and node adaptive parameters of each traffic monitoring node. A window-level periodic baseline sequence is generated; a periodic residual sequence is generated based on the traffic state window and the window-level periodic baseline sequence; the periodic residual sequence is propagated spatially using the adjacency matrix, and the spatial graph propagation result is time-dependently encoded to obtain a spatiotemporal encoded representation of the periodic residual; the spatiotemporal encoded representation of the periodic residual is matched with a prototype memory to obtain a memory-enhanced feature sequence, and the periodic residual sequence is reconstructed based on the memory-enhanced feature sequence to obtain a final reconstruction error; an anomaly score is calculated based on the final reconstruction error, and anomaly detection results are output based on the anomaly score and a node anomaly threshold.

[0119] Computer program code for performing the operations of this application can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including LAN (Local Area Network) or WAN (Wide Area Network)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0120] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.

[0121] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the traffic flow anomaly detection method based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling described above. This method can solve the technical problem of identifying node-level traffic anomalies in traffic state data mixed with normal periodic fluctuations and abnormal disturbances. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the traffic flow anomaly detection method based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling provided in the above embodiments, and will not be repeated here.

[0122] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.

Claims

1. A traffic flow anomaly detection method based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling, characterized in that, The method includes: Obtain a traffic state window and a traffic graph structure. The traffic state window includes traffic state vectors of multiple traffic monitoring nodes in multiple consecutive time slices, and the traffic graph structure includes an adjacency matrix corresponding to the multiple traffic monitoring nodes. A window-level periodic baseline sequence is generated based on the day type, intraday time location, and node adaptive parameters of each traffic monitoring node for each time slice. Generate a periodic residual sequence based on the traffic state window and the window-level periodic reference sequence; The periodic residual sequence is propagated spatially using the adjacency matrix, and the propagation result is time-dependently encoded to obtain a spatiotemporal encoded representation of the periodic residual. The periodic residual spatiotemporal encoded representation is matched with the prototype memory to obtain a memory-enhanced feature sequence, and the periodic residual sequence is reconstructed based on the memory-enhanced feature sequence to obtain the final reconstruction error; The anomaly score is calculated based on the final reconstruction error, and the anomaly detection result is output based on the anomaly score and the node anomaly threshold.

2. The method as described in claim 1, characterized in that, The steps of matching the spatiotemporal encoded representation of the periodic residual with the prototype memory to obtain a memory-enhanced feature sequence, and reconstructing the periodic residual sequence based on the memory-enhanced feature sequence to obtain the final reconstruction error include: Extract the latent vectors corresponding to each time slice and each traffic monitoring node in the spatiotemporal encoding representation of the periodic residual; Calculate the distances between the latent vectors and the prototype normal residual patterns in the prototype memory to obtain the prototype distance set; The normal residual pattern prototype with the smallest distance value is determined from the prototype distance set and used as the matching prototype corresponding to the latent vector. The matching prototype is used as the memory-enhanced representation corresponding to the latent vector, and the memory-enhanced representation is arranged according to time slice and traffic monitoring node to obtain the memory-enhanced feature sequence; The periodic residual sequence is reconstructed in two stages based on the memory-enhanced feature sequence to obtain the final reconstruction error.

3. The method as described in claim 2, characterized in that, The step of performing a two-stage reconstruction of the periodic residual sequence based on the memory-enhanced feature sequence to obtain the final reconstruction error includes: The memory-enhanced feature sequence is input into the first-stage decoder to obtain the first reconstructed residual sequence; The first reconstruction error is obtained based on the periodic residual sequence and the first reconstructed residual sequence; The first reconstruction error is aggregated and normalized in the node dimension and variable dimension to obtain the time anomaly attention weight; The first reconstruction error is aggregated and normalized in the time dimension and the variable dimension to obtain the spatial anomaly attention weight; A time bias matrix is ​​generated based on the time anomaly attention weights, and a spatial bias matrix is ​​generated based on the spatial anomaly attention weights. The memory-enhanced feature sequence, the temporal bias matrix, and the spatial bias matrix are input into the second-stage decoder to obtain the second reconstructed residual sequence. The first-stage decoder is a residual decoder that does not receive the temporal bias matrix and the spatial bias matrix. The final reconstruction error is obtained based on the periodic residual sequence and the second reconstructed residual sequence.

4. The method as described in claim 1, characterized in that, The step of generating a periodic residual sequence based on the traffic state window and the window-level periodic reference sequence includes: Align the traffic state vector in the traffic state window with the node-level periodic reference in the window-level periodic reference sequence according to the time slice and traffic monitoring node; Subtract the traffic state vector corresponding to the same time slice and the same traffic monitoring node from the node-level periodic benchmark to obtain the periodic residual vector; The periodic residual matrix is ​​obtained by arranging the periodic residual vectors corresponding to the same time slice according to the traffic monitoring nodes. The periodic residual matrix is ​​combined according to the time slice order to obtain the periodic residual sequence.

5. The method as described in claim 1, characterized in that, The steps of performing spatial graph propagation on the periodic residual sequence based on the adjacency matrix and performing time-dependent encoding on the spatial graph propagation result to obtain the spatiotemporal encoded representation of the periodic residual include: Add the identity matrix to the adjacency matrix to obtain a self-connected adjacency matrix; A degree matrix is ​​generated based on the sum of the elements in each row of the self-connected adjacency matrix, and the self-connected adjacency matrix is ​​symmetrically normalized based on the degree matrix to obtain a normalized adjacency matrix. For the periodic residual matrix corresponding to each time slice in the periodic residual sequence, each element in the normalized adjacency matrix is ​​used as the residual transfer weight between nodes. The periodic residual vectors of each traffic monitoring node in the periodic residual matrix of the corresponding time slice are weighted and summed to obtain the neighborhood aggregation residual matrix corresponding to each time slice. The neighborhood aggregation residual matrix corresponding to each time slice is subjected to linear transformation and nonlinear activation processing to obtain the spatial coding sequence; The spatial encoding sequence is converted into a query matrix, a key matrix, and a value matrix, respectively. The temporal attention weights are calculated based on the query matrix and the key matrix, and the temporal encoding sequence is obtained based on the temporal attention weights and the value matrix. The spatial coding sequence and the temporal coding sequence are concatenated along the feature dimension to obtain the concatenated coding sequence; A linear transformation is performed on the spliced ​​coded sequence to obtain a periodic residual spatiotemporal coded representation.

6. The method as described in claim 1, characterized in that, The node adaptive parameters include the node scaling vector and the node bias vector; The step of generating a window-level periodic reference sequence based on the day type, intraday time location, and node adaptive parameters of each traffic monitoring node for each time slice includes: The day type category for each time slot is determined based on the timestamp of each time slot and the preset day type category set; Based on the timestamps of each time slice and the preset sampling interval, the intraday time position of each time slice is determined; Based on the day type category and intraday time position of each time slice, extract the shared cycle prototype corresponding to each time slice from the shared cycle template; For each traffic monitoring node, the node scaling vector of the corresponding traffic monitoring node is multiplied element-wise with the shared periodic prototype to obtain the node scaling result; The node scaling result is added to the node bias vector of the corresponding traffic monitoring node to obtain the node-level periodic reference of each traffic monitoring node in each time slice. By combining the node-level periodic references in time slice order, a window-level periodic reference sequence is obtained.

7. The method according to any one of claims 1 to 6, characterized in that, The step of calculating the anomaly score based on the final reconstruction error and outputting the anomaly detection result based on the anomaly score and the node anomaly threshold includes: Extract the multivariate error vector of each traffic monitoring node in each time slice from the final reconstruction error; The multivariate error vector, the preset error mean vector, and the preset error covariance matrix are input into the multivariate Gaussian negative log-likelihood function to obtain the anomaly score of each traffic monitoring node in each time slice. The preset error mean vector and the preset error covariance matrix are statistical parameters determined based on historical normal reconstruction error samples. The anomaly score is compared with the node anomaly threshold of the corresponding traffic monitoring node to obtain the anomaly discrimination result; Based on the anomaly identification result, the anomaly detection result is output, which includes the anomaly node, the anomaly time, and the anomaly alarm information.

8. A traffic flow anomaly detection device based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling, characterized in that, The device employs the traffic flow anomaly detection method based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling as described in any one of claims 1 to 7, and the device comprises: The data acquisition module is used to acquire a traffic state window and a traffic graph structure. The traffic state window includes traffic state vectors of multiple traffic monitoring nodes in multiple consecutive time slices, and the traffic graph structure includes an adjacency matrix corresponding to the multiple traffic monitoring nodes. The benchmark generation module is used to generate a window-level periodic benchmark sequence based on the day type, intraday time location, and node adaptive parameters of each traffic monitoring node for each time slice. The sequence decoupling module is used to generate a periodic residual sequence based on the traffic state window and the window-level periodic reference sequence; The spatiotemporal coding module is used to perform spatial graph propagation on the periodic residual sequence according to the adjacency matrix, and to perform time-dependent coding on the spatial graph propagation result to obtain the spatiotemporal coded representation of the periodic residual; The sequence reconstruction module is used to match the periodic residual spatiotemporal encoded representation with the prototype memory to obtain a memory-enhanced feature sequence, and reconstruct the periodic residual sequence based on the memory-enhanced feature sequence to obtain the final reconstruction error; The result output module is used to calculate the anomaly score based on the final reconstruction error, and output the anomaly detection result based on the anomaly score and the node anomaly threshold.

9. A traffic flow anomaly detection device based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling, characterized in that, The device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the traffic flow anomaly detection method based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling as described in any one of claims 1 to 7.

10. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the traffic flow anomaly detection method based on periodic residual decoupling and memory-enhanced spatiotemporal graph modeling as described in any one of claims 1 to 7.