Traffic flow escape attack identification method and related device
Through the self-attention mechanism, the weight distribution of historical and real-time traffic flow data is compared, and the problem of escape attacks in traffic flow is identified and solved, and the accuracy of traffic flow prediction is improved.
Patent Information
- Application Number
- CN202510208897.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-25
- Publication Date
- 2025-05-30
AI Technical Summary
The prior art is difficult to identify escape attacks in traffic flow, resulting in a decrease in traffic flow prediction accuracy.
By acquiring historical and real-time traffic network traffic data, the first and second self-attention weight distributions are determined using the self-attention mechanism, and the differences between the two are compared to identify escape attacks.
Accurate identification of traffic flow escape attacks is achieved, the accuracy of traffic flow prediction is improved, and wrong traffic prediction and traffic signal management interference is avoided.
Smart Images

Figure CN120071613A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of traffic flow prediction, and specifically relates to a method for identifying traffic flow escape attacks and related devices. Background Art
[0002] Traffic flow prediction technology aims to optimize traffic management to alleviate urban traffic congestion and improve road traffic efficiency through accurate traffic flow prediction. The spatio-temporal graph neural network model can process the spatial structure and dynamic changes of traffic flow, and provide accurate data support for traffic management and prediction according to the traffic flow changes at different times and roads.
[0003] Although current traffic flow prediction technologies, such as spatio-temporal graph neural network models, have shown high accuracy and adaptability in traffic flow prediction, in traffic flow prediction tasks, it is difficult to identify escape attacks in traffic flow. Once there is a traffic flow escape attack, it can mislead the prediction of the traffic flow model by introducing small perturbations into the spatio-temporal characteristics of traffic flow data, resulting in incorrect traffic flow prediction, interfering with traffic signal management, and affecting public transportation scheduling. Summary of the Invention
[0004] To solve the technical problem in the prior art that in traffic flow prediction tasks, escape attacks that may exist in traffic flow are difficult to identify, resulting in a decrease in the accuracy of traffic flow prediction, the embodiments of this application provide a method for identifying traffic flow escape attacks and related devices. The first aspect of the embodiments of this application provides a method for identifying traffic flow escape attacks, and the method includes:
[0005] Obtain historical traffic network flow data and real-time traffic network flow data;
[0006] Determine a first self-attention weight distribution according to the historical traffic network flow data;
[0007] Determine a second self-attention weight distribution according to the real-time traffic network flow data;
[0008] Determine the escape attack identification result of the real-time traffic network flow data according to the first self-attention weight distribution and the second self-attention weight distribution.
[0009] Further, the determining a first self-attention weight distribution according to the historical traffic network flow data includes:
[0010] Determine a spatial feature sequence according to the historical traffic network flow data by using a spatial attention mechanism;
[0011] Determine spatio-temporal dependence relationship node features according to the spatial feature sequence by using a temporal self-attention mechanism;
[0012] Determine the first self-attention weight distribution according to the spatio-temporal dependence relationship node features.
[0013] Further, the determining the spatial feature sequence by using the spatial attention mechanism according to the historical traffic network flow data includes:
[0014] Determine the node features and the adjacency matrix according to the historical traffic network flow data;
[0015] Determine the spatial attention feature vector by using the spatial attention mechanism according to the node features and the adjacency matrix;
[0016] Determine the self-attention score according to the spatial attention feature vector through the attention vector and the LeakyReLU activation function;
[0017] Perform normalization processing on the self-attention score by using the first exponential function to obtain the first spatial attention weight distribution;
[0018] Enhance the first spatial attention weight distribution by using the similarity metric function, the second exponential function, and the projection matrix to obtain the second spatial attention weight distribution;
[0019] Perform spatial feature aggregation on the second spatial attention weight distribution by using the multi-head self-attention mechanism to obtain the spatial node feature sequence;
[0020] Summarize the spatial node feature sequence to obtain the spatial feature sequence.
[0021] Further, the determining the spatio-temporal dependence relationship node features by using the temporal self-attention mechanism according to the spatial feature sequence includes:
[0022] Determine the short-term trend feature and the long-term trend feature according to the spatial feature sequence;
[0023] Dynamically fuse the short-term trend feature and the long-term trend feature to obtain the temporal self-attention weight matrix;
[0024] Fuse the spatial feature sequence and the temporal self-attention weight matrix to obtain the fusion result;
[0025] Perform non-linear activation function mapping on the fusion result to obtain the spatio-temporal dependence relationship node features.
[0026] Further, the determining the short-term trend feature and the long-term trend feature according to the spatial feature sequence includes:
[0027] Perform linear transformation processing on the spatial feature sequence to obtain the short-term trend feature;
[0028] Perform weighted aggregation processing on the short-term trend features to obtain long-term trend features.
[0029] Further, determining the first self-attention weight distribution according to the spatio-temporal dependence relationship node features includes:
[0030] Transform the spatio-temporal dependence relationship node features through three linear transformation weight matrices to obtain a query matrix, a key matrix, and a value matrix;
[0031] Use the exp exponential function to normalize the query matrix, the key matrix, and the value matrix to obtain the first self-attention weight distribution.
[0032] Further, determining the escape attack recognition result of the real-time traffic network traffic data according to the first self-attention weight distribution and the second self-attention weight distribution includes:
[0033] Extract the difference between the first self-attention weight distribution and the second self-attention weight distribution to obtain an attention weight deviation value;
[0034] Compare the attention weight deviation value with a preset threshold to obtain a comparison result;
[0035] Determine the escape attack recognition result of the real-time traffic network traffic data according to the comparison result.
[0036] In this example, first obtain historical traffic network traffic data and real-time traffic network traffic data to obtain a second attention weight distribution, then determine the first self-attention weight distribution according to the historical traffic network traffic data, determine the second self-attention weight distribution according to the real-time traffic network traffic data, and then determine the escape attack recognition result of the real-time traffic network traffic data based on the first self-attention weight distribution and the second self-attention weight distribution, that is, by comparing the difference in self-attention weights between the real-time traffic data and the normal historical traffic data, so as to identify the behavior of attackers trying to disrupt the model decision-making with abnormal data, thereby accurately identifying the escape attack, and solving the technical problem that the existing traffic flow escape attack is difficult to be identified, resulting in a reduction in the accuracy of traffic flow prediction.
[0037] The second aspect of the embodiments of the present application provides an identification device for traffic flow escape attacks, and the device includes:
[0038] An acquisition unit for acquiring historical traffic network traffic data and real-time traffic network traffic data;
[0039] A first processing unit for determining a first self-attention weight distribution according to the historical traffic network traffic data;
[0040] A second processing unit for determining a second self-attention weight distribution according to the real-time traffic network traffic data;
[0041] A determining unit for determining an escape attack recognition result of the real-time traffic network traffic data according to the first self-attention weight distribution and the second self-attention weight distribution.
[0042] Further, in terms of obtaining historical traffic network traffic data and real-time traffic network traffic data, the first processing unit is used for:
[0043] Determining a spatial feature sequence by using a spatial attention mechanism according to the historical traffic network traffic data;
[0044] Determining spatio-temporal dependence relationship node features by using a temporal self-attention mechanism according to the spatial feature sequence;
[0045] Determining a first self-attention weight distribution according to the spatio-temporal dependence relationship node features.
[0046] Further, in terms of determining a spatial feature sequence by using a spatial attention mechanism according to the historical traffic network traffic data, the first processing unit is used for:
[0047] Determining node features and an adjacency matrix according to the historical traffic network traffic data;
[0048] Determining a spatial attention feature vector by using a spatial attention mechanism according to the node features and the adjacency matrix;
[0049] Determining a self-attention score through an attention vector and a LeakyReLU activation function according to the spatial attention feature vector;
[0050] Normalizing the self-attention score by using a first exponential function to obtain a first spatial attention weight distribution;
[0051] Enhancing the first spatial attention weight distribution by using a similarity metric function, a second exponential function, and a projection matrix to obtain a second spatial attention weight distribution;
[0052] Performing spatial feature aggregation on the second spatial attention weight distribution by using a K-head self-attention mechanism to obtain a spatial node feature sequence;
[0053] Summarizing the spatial node feature sequence to obtain a spatial feature sequence.
[0054] Further, in terms of determining spatio-temporal dependence relationship node features by using a temporal self-attention mechanism according to the spatial feature sequence, the first processing unit is used for:
[0055] Determine short-term trend features and long-term trend features according to the spatial feature sequence;
[0056] Dynamically fuse the short-term trend features and long-term trend features to obtain a temporal self-attention weight matrix;
[0057] Fuse the spatial feature sequence and the temporal self-attention weight matrix to obtain a fusion result;
[0058] Perform a non-linear activation function mapping on the fusion result to obtain spatio-temporal dependence relationship node features.
[0059] Further, in the aspect of determining short-term trend features and long-term trend features according to the spatial feature sequence, the first processing unit is used for:
[0060] Perform a linear transformation process on the spatial feature sequence to obtain short-term trend features;
[0061] Perform a weighted aggregation process on the short-term trend features to obtain long-term trend features.
[0062] Further, in the aspect of determining the first self-attention weight distribution according to the spatio-temporal dependence relationship node features, the first processing unit is used for:
[0063] Change the spatio-temporal dependence relationship node features through three linear transformation weight matrices to obtain a query matrix, a key matrix, and a value matrix;
[0064] Use the exp exponential function to normalize the query matrix, the key matrix, and the value matrix to obtain the first self-attention weight distribution.
[0065] Further, in the aspect of determining the escape attack recognition result of the real-time traffic network traffic data according to the first self-attention weight distribution and the second self-attention weight distribution, the first processing unit is used for:
[0066] Extract the difference between the first self-attention weight distribution and the second self-attention weight distribution to obtain an attention weight deviation value;
[0067] Compare the attention weight deviation value with a preset threshold to obtain a comparison result;
[0068] Determine the escape attack recognition result of the real-time traffic network traffic data according to the comparison result.
[0069] A third aspect of the embodiments of the present application provides a terminal, including a processor, an input device, an output device, and a memory. The processor, the input device, the output device, and the memory are interconnected. Among them, the memory is used to store a computer program, the computer program includes program instructions, and the processor is configured to call the program instructions to execute the step instructions of the traffic flow evasion attack recognition method in the first aspect of the embodiments of the present application.
[0070] A fourth aspect of the embodiments of the present application provides a computer-readable storage medium. Among them, the computer-readable storage medium stores a computer program for electronic data exchange. Among them, the computer program enables a computer to execute some or all of the steps described in the traffic flow evasion attack recognition method in the first aspect of the embodiments of the present application.
[0071] A fifth aspect of the embodiments of the present application provides a computer program product. Among them, the computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to enable a computer to execute some or all of the steps described in the traffic flow evasion attack recognition method in the first aspect of the embodiments of the present application. This computer program product can be a software installation package. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0073] Figure 1 FIG. is a schematic diagram of the overall process of a traffic flow evasion attack recognition method provided by an embodiment of the present application;
[0074] Figure 2 FIG. is a schematic diagram of the specific process of determining the first self-attention weight distribution step of a traffic flow evasion attack provided by an embodiment of the present application;
[0075] Figure 3 FIG. is a schematic diagram of the specific process of determining the spatial feature sequence step of the spatial attention mechanism of a traffic flow evasion attack provided by an embodiment of the present application;
[0076] Figure 4 FIG. is a schematic diagram of the specific process of determining the spatio-temporal dependence relationship node feature step of a traffic flow evasion attack using the temporal self-attention mechanism provided by an embodiment of the present application;
[0077] Figure 5This application provides a schematic diagram of the specific process of determining the first self-attention weight distribution according to the node features of spatio-temporal dependence in traffic flow evasion attacks;
[0078] Figure 6 This application provides a schematic diagram of the specific process of determining the evasion attack recognition result of real-time traffic network flow data according to the first self-attention weight distribution and the second self-attention weight distribution in traffic flow evasion attacks;
[0079] Figure 7 This application provides a schematic diagram of the structure of an identification device for traffic flow evasion attacks;
[0080] Figure 8 This application provides a schematic diagram of the structure of a terminal;
[0081] Reference numerals:
[0082] 100 - acquisition unit, 200 - first processing unit, 300 - second processing unit, 400 - determination unit. Detailed implementation manners
[0083] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0084] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally further include unlisted steps or units, or may optionally further include other steps or units inherent to these processes, methods, products or devices.
[0085] Referring to "embodiments" in the present application means that specific features, structures or characteristics described in conjunction with the embodiments may be included in at least one embodiment of the present application. The phrase appears in various positions in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art explicitly and implicitly understand that the embodiments described in the present application may be combined with other embodiments.
[0086] To better understand a method for identifying traffic flow evasion attacks provided by an embodiment of the present application, the scenarios where the method for identifying traffic flow evasion attacks is applied will be briefly introduced below. Existing traffic flow prediction technologies generally train an artificial intelligence model and then use the trained artificial intelligence model to predict traffic flow. However, during the process of training the artificial intelligence model with traffic flow data, there may be traffic flow that has suffered an evasion attack. Since the model training mainly relies on the local spatial topological structure and structural change status in the traffic flow data, the traffic flow that has suffered an evasion attack may mislead the model training. Moreover, the local perturbations of the training data of the model suffering from an evasion attack will gradually amplify, making the evasion attack effect significant, resulting in insufficient model robustness and a decrease in the accuracy of traffic flow prediction.
[0087] The method for identifying traffic flow evasion attacks is applied to a device for identifying traffic flow evasion attacks. Figure 1 The overall flowchart of a method for identifying traffic flow evasion attacks is shown. As Figure 1 shown, it includes:
[0088] S1. Obtain historical traffic network flow data and real-time traffic network flow data.
[0089] In this example, the historical traffic network flow data is obtained by connecting to the traffic management system, and the real-time traffic network flow data is obtained by deploying acquisition devices such as cameras, radars, GPS, and sensor arrays in the target traffic network area to be predicted.
[0090] It should be noted that the historical traffic network flow data is historical data that has not been subjected to an evasion attack, and the real-time traffic network flow data is real-time collected data, and it is temporarily unknown whether it has been subjected to an evasion attack and needs to be determined by the method provided by the present invention.
[0091] S2. Determine the first self-attention weight distribution according to the historical traffic network flow data.
[0092] In this example, first, according to the historical traffic network flow data, the spatial feature sequence of the historical traffic network flow data is determined through the spatial self-attention mechanism. Then, according to the spatial feature sequence of the historical traffic network flow data, the spatio-temporal dependence relationship node features of the historical traffic network flow data are determined by using the temporal self-attention mechanism. Finally, according to the spatio-temporal dependence relationship node features of the historical traffic network flow data, the first self-attention weight distribution of the historical traffic network flow data is determined.
[0093] S3. Determine the second self-attention weight distribution according to the real-time traffic network flow data.
[0094] In this example, the method for determining the second self-attention weight distribution is the same as the method for determining the first self-attention weight distribution in step S2. The difference is that the second self-attention weight distribution uses real-time traffic network flow data.
[0095] S4. Determine the evasion attack recognition result of the real-time traffic network flow data according to the first self-attention weight distribution and the second self-attention weight distribution.
[0096] In this example, first, historical traffic network flow data and real-time traffic network flow data are obtained to obtain the second attention weight distribution. Then, according to the historical traffic network flow data, the first self-attention weight distribution is determined. According to the real-time traffic network flow data, the second self-attention weight distribution is determined. Then, based on the first self-attention weight distribution and the second self-attention weight distribution, the evasion attack recognition result of the real-time traffic network flow data is determined, that is, by comparing the difference in self-attention weights between the real-time traffic data and the normal historical traffic data, the behavior of the attacker trying to disrupt the model decision using abnormal data is identified, so as to accurately identify the evasion attack and solve the technical problem that the existing traffic flow evasion attack is difficult to be identified, resulting in a decrease in the accuracy of traffic flow prediction.
[0097] Figure 2 The specific flowchart of the steps for determining the first self-attention weight distribution of a traffic flow evasion attack is shown, as Figure 2 shown. In a possible implementation manner, the determining the first self-attention weight distribution according to the historical traffic network flow data includes:
[0098] S2-1. Determine the spatial feature sequence according to the historical traffic network flow data by using the spatial attention mechanism.
[0099] S2-2. Determine the spatio-temporal dependence relationship node features according to the spatial feature sequence by using the temporal self-attention mechanism.
[0100] S2-3. Determine the first self-attention weight distribution according to the spatio-temporal dependence relationship node features.
[0101] In this example, first, according to the historical traffic network flow data, the spatial attention mechanism is used to determine the spatial feature sequence to capture the correlation between different sections or nodes in the historical traffic network flow data. Then, the key areas in the road network in the historical traffic network flow data are identified, and the self-attention weights are reasonably allocated according to the key areas. Then, the spatial dependence relationship and distribution law of the traffic flow between sections are extracted to obtain the spatial feature sequence.
[0102] Figure 3Shows a specific flowchart of the steps for determining the spatial feature sequence of the spatial attention mechanism for traffic flow evasion attacks, as Figure 3 shown. In a possible implementation manner, the determining the spatial feature sequence by using the spatial attention mechanism according to the historical traffic network flow data includes:
[0103] S2-1-1. Determine the node features and the adjacency matrix according to the historical traffic network flow data.
[0104] In this example, first, the historical traffic network flow data is subjected to a spatio-temporal graph transformation to obtain the historical traffic network flow data after the spatio-temporal graph transformation. During the transformation of the spatio-temporal graph, the road network in the historical traffic network flow data is mapped into a spatio-temporal graph structure, the sensor sites on the road are represented as nodes in the spatio-temporal graph, and the actual connection relationship between the roads constitutes the edges of the spatio-temporal graph, thereby obtaining the adjacency matrix describing the topological structure of the entire road network.
[0105] Furthermore, the historical traffic network flow data is encoded to obtain the node features of the historical traffic network flow data These node features will change dynamically with time to reflect the traffic conditions at that time corresponding to the historical traffic network flow data, thereby obtaining the node features and the adjacency matrix.
[0106] S2-1-2. Determine the spatial attention feature vector by using the spatial attention mechanism according to the node features and the adjacency matrix.
[0107] In this example, the node features and the adjacency matrix are used as inputs, and the spatial attention mechanism is used for calculation to obtain the spatial attention feature vector so as to effectively capture the spatial dependence relationships contained in the historical traffic network flow data.
[0108] S2-1-3. Determine the self-attention score according to the spatial attention feature vector through the attention vector and the LeakyReLU activation function.
[0109] Specifically, the specific calculation formula for the self-attention score is as follows:
[0110]
[0111] Among them, is the self-attention score, represents the feature vector of node i at time t, represents the feature vector of node j at time t, a T is the attention vector, and W (l) is the weight matrix.
[0112] In this example, the self-attention score calculation formula calculates the self-attention scores between node pairs in the spatio-temporal graph, which is used to quantify the correlation strength between different node features. Among them, and represent the feature vectors of node i and node j at time t respectively. These features are linearly transformed through the weight matrix to map the feature dimension from F to the F'-dimensional space. In the l-th layer of the network (where 1 ≤ l ≤ L), the trainable attention vector a T is responsible for learning the importance weights between nodes, while the LeakyReLU activation function ensures the effective propagation of gradients by maintaining small gradients in the negative value region, enhancing the non-linear expression ability of the model, and finally realizing the adaptive learning of the correlation between nodes.
[0113] S2-1-4. Use the first exponential function to normalize the self-attention score to obtain the first spatial attention weight distribution.
[0114] Specifically, the specific formula form of the first spatial attention weight distribution is as follows:
[0115]
[0116] Among them, is the first spatial attention weight distribution, exp(.) is the first exponential function, is the self-attention score, is the set of neighbor nodes of node i.
[0117] In this example, this formula uses the exponential function exp(.) to normalize the self-attention score between node i and its set of neighbor nodes to convert it into a probability distribution form, thereby obtaining the weight coefficient that quantifies the relative importance between nodes, that is, the first spatial attention weight distribution This softmax-based normalization not only ensures the comparability of attention weights but also enables the model to adaptively adjust the degree of attention to different neighbor nodes, providing a reasonable weight basis for subsequent feature aggregation. This softmax-based normalization not only ensures the comparability of attention weights but also enables the model to adaptively adjust the degree of attention to different neighbor nodes, providing a reasonable weight basis for subsequent feature aggregation.
[0118] S2-1-5. Use a similarity metric function, a second exponential function, and a projection matrix to enhance the first spatial attention weight distribution to obtain the second spatial attention weight distribution.
[0119] Specifically, the specific calculation formula of the second spatial attention weight distribution is as follows:
[0120]
[0121] Among them, is the second spatial attention weight distribution, is the first spatial attention weight distribution, exp(.) is the second exponential function, sim(.) is the similarity metric function, and W sim is the projection matrix.
[0122] In this example, the performance of the spatial self-attention mechanism is enhanced by introducing temporal similarity information. Specifically, by incorporating the similarity metric function sim(.), the second exponential function exp(.), and the projection matrix W into the original first spatial attention weight distribution sim , the model can evaluate the similarity between the node feature vectors after projection transformation. Such a setting enables the spatial self-attention mechanism to adaptively adjust the attention allocation according to the similarity of neighboring nodes: assigning greater attention weights to neighbor nodes with high similarity while reducing the influence of those abnormal and low-similarity nodes, thereby significantly improving the model's robustness to noise and outliers.
[0123] S2-1-6. Use the K-head self-attention mechanism to perform spatial feature aggregation on the second spatial attention weight distribution to obtain a spatial node feature sequence.
[0124] Specifically, the calculation formula for the spatial node feature sequence is as follows:
[0125]
[0126] Among them, is the spatial node feature sequence, is the spatial self-attention weight calculated by the k-th attention head, and W (l),k is the linear transformation weight matrix corresponding to the l-th layer of the network and the -th attention head, and σ(.) is the non-linear activation function.
[0127] In this example, the results independently calculated by each attention head are combined through the concatenation operator to generate the updated feature representation of the node, realizing multi-perspective information fusion based on the similarity of neighbor nodes. In this process, represents the spatial self-attention weight calculated by the k-th attention head, and W (l),kis the weight matrix of the linear transformation corresponding to the l-th layer network and the k-th attention head, and the non-linear activation function σ(.) maps the calculation result to the interval (0,1), ensuring the numerical stability of feature aggregation. This multi-head design enables the model to capture the complex relationships between nodes from different representation subspaces, significantly enhancing the comprehensiveness and robustness of feature extraction.
[0128] S2-1-7. Aggregate the spatial node feature sequences to obtain a spatial feature sequence.
[0129] In this example, the spatial node feature sequences obtained by calculating the K-head layer are aggregated to obtain a spatial feature sequence H r [1 ≤ t ≤ T].
[0130] Figure 4 shows a specific flowchart of the steps for determining spatio-temporal dependency relationship node features using a time self-attention mechanism for a traffic flow evasion attack, as Figure 4 shown. In a possible implementation manner, the determining spatio-temporal dependency relationship node features according to the spatial feature sequence using a time self-attention mechanism includes:
[0131] S2-2-1. Determine short-term trend features and long-term trend features according to the spatial feature sequence. Specifically, it includes:
[0132] S2-2-1-1. Perform a linear transformation on the spatial feature sequence to obtain short-term trend features.
[0133] Specifically, the specific calculation formula for the short-term trend features is as follows:
[0134] H tem1 [t] = H r [t] × W tem1 ∈R N×T×Q
[0135] where, H tem1 [t] is the short-term trend feature, H r [t] is the spatial feature sequence, W tem1 is the weight matrix, and N × T × Q is the dimension of the transformed feature tensor, corresponding to the number of nodes, time steps, and feature dimensions.
[0136] In this example, taking the feature sequence H r [1 ≤ t ≤ T] output by the spatial self-attention module as the input, a short-term trend feature representation is generated through the linear transformation of the weight matrix W tem1 , where the dimension of the transformed feature tensor is N × T × Q, corresponding to the number of nodes, time steps, and feature dimensions respectively. This linear mapping operation enables the present invention to extract a representation form from the original features that is more suitable for capturing short-term time series patterns.
[0137] S2-2-1-2. Aggregate the short-term trend features with weights to obtain long-term trend features.
[0138] Specifically, the specific calculation formula for the long-term trend features is as follows:
[0139]
[0140] where H tem2 [t] is the long-term trend feature, W tem2 [t - τ] is the linear transformation weight matrix, and N×1×Q is the number of nodes × single time step × the dimension of the output node features of the time self-attention module.
[0141] In this example, the long-term trend features are captured by aggregating the historical data within the time window ts ≤ τ ≤ t with weights. Specifically, the module applies the time-dependent linear transformation weight matrix W r [1 ≤ t ≤ T] to the input sequence H tem2 [t - τ], and generates the long-term trend representation through weighted averaging Here, the max and min functions are used to ensure the legality of the time window, effectively avoiding the boundary problems that may occur when processing the start and end positions of the sequence, enabling the long-term trend extraction process to run stably throughout the time series.
[0142] S2-2-2. Dynamically fuse the short-term trend features and the long-term trend features to obtain the time self-attention weight matrix.
[0143] Specifically, the calculation formula for the time self-attention weight matrix is as follows:
[0144]
[0145] where α tem is the time self-attention weight matrix, H tem1 is the short-term trend feature, is the long-term trend feature, and N×T×T is the three dimensions of the number of nodes, source time step, and target time step.
[0146] In this example, by performing the matrix dot product operation e on the short-term trend feature H tem1 and the long-term trend feature , the dynamic fusion of the long-term and short-term time series features is achieved. This fusion operation transforms the traffic flow change patterns at different time scales into the time self-attention weight matrix α tem ∈R N×T×T , where the dimension of the weight matrix reflects the time series dependence relationship of the model in the three dimensions of the number of nodes, source time step, and target time step.
[0147] S2-2-3. Fuse the spatial feature sequence and the temporal self-attention weight matrix to obtain a fusion result.
[0148] S2-2-4. Map the fusion result through a non-linear activation function to obtain the spatio-temporal dependence relationship node features.
[0149] Specifically, the calculation formula for the spatio-temporal dependence relationship node features is as follows:
[0150] H tem = σ(H r + α(H r W tem )) ∈ R T×N×Q
[0151] where H tem is the spatio-temporal dependence relationship node feature, H r is the spatial feature sequence, α(H r W tem ) is the temporal self-attention weight matrix, H r + α(H r W tem ) is the fusion result, σ(.) is the non-linear activation function, and T×N×Q are the three dimensions of the total number of time steps × the number of nodes × the number of node features.
[0152] In this example, by fusing the node features H r that retain spatial information with their temporal features α(H r W tem ) transformed by the temporal self-attention weights, and through the mapping of the non-linear activation function σ(.), a node feature representation H tem that comprehensively encodes the spatio-temporal dependence relationship is generated. In this process, the linear transformation weight matrix W tem plays a key role in the adaptive aggregation of spatio-temporal features, ensuring the effective integration of spatial and temporal dimension information.
[0153] In this example, first, based on the spatial feature sequence, the short-term trend features and long-term trend features in the historical traffic flow data are captured, and the short-term trend features and long-term trend features are dynamically fused to obtain a temporal self-attention weight matrix. Then, the temporal self-attention weight matrix and the spatial feature sequence are fused again to obtain a fusion result. Finally, the fusion result is mapped through a non-linear activation function to obtain spatio-temporal dependence relationship node features. Through the specific steps of the temporal self-attention mechanism, it is possible to simultaneously focus on the long-term trends and short-term fluctuations in the historical traffic flow data, and then weigh and integrate the temporal information at different time scales, so as to effectively identify the periodic patterns in the historical traffic flow, such as morning and evening rush hours, differences between weekdays and weekends, and sudden changes such as traffic accidents and temporary control, etc., providing a comprehensive and accurate temporal feature representation for traffic flow prediction on the time scale.
[0154] Figure 5 The following shows a specific flowchart of the step of determining the first self-attention weight distribution according to the spatio-temporal dependence relationship node features for a traffic flow evasion attack, as Figure 5 shown. In a possible implementation manner, determining the first self-attention weight distribution according to the spatio-temporal dependence relationship node features includes:
[0155] 2-3-1. Transform the spatio-temporal dependence relationship node features through three linear transformation weight matrices to obtain a query matrix, a key matrix, and a value matrix.
[0156] 2-3-2. Use the exp exponential function to normalize the query matrix, the key matrix, and the value matrix to obtain the first self-attention weight distribution.
[0157] Specifically, the specific calculation formula for the first self-attention weight distribution is as follows:
[0158]
[0159] Where, is the first self-attention weight distribution, where i and j are the indexes of the source node and the target node respectively, Q i ∈Q is the query matrix for node i, K i ∈K is the key matrix for capturing the relevance of node j, and V is the value matrix carrying the spatio-temporal information of the node.
[0160] In this example, by comparing and analyzing the real-time traffic flow and the normal traffic flow data, the self-attention mechanism is used to effectively amplify the abnormal features in H tem . Specifically, this module respectively passes the input spatio-temporal features H tem through three linear transformation weight matrices W Q , W K , W VProjection is the query matrix Key matrix Sum matrix Subsequently, normalization is performed through the exponential function exp to generate self-attention weight scores Used to quantify the degree of abnormality of traffic flow
[0161] Figure 6 Shows a specific flowchart of the steps for identifying the escape attack recognition result of real-time traffic network traffic data based on the first self-attention weight distribution and the second self-attention weight distribution, as Figure 6 Shown, in a possible implementation manner, determining the escape attack recognition result of the real-time traffic network traffic data according to the first self-attention weight distribution and the second self-attention weight distribution includes:
[0162] S4-1. Extract the difference between the first self-attention weight distribution and the second self-attention weight distribution to obtain an attention weight deviation value
[0163] S4-2. Compare the attention weight deviation value with a preset threshold to obtain a comparison result
[0164] S4-3. Determine the escape attack recognition result of the real-time traffic network traffic data according to the comparison result
[0165] Specifically, the calculation formula of the attention weight deviation value is as follows:
[0166]
[0167] Where S anomaly Is the attention weight deviation value, α δ Is the first self-attention weight distribution, Is the second self-attention weight distribution
[0168] In this example, by calculating the self-attention weights of real-time traffic flow data and normal traffic flow data respectively Potential escape attacks are detected by comparing the differences between the two. When the attention weight deviation value S anomaly Between the self-attention weights generated by real-time data and the normal flow benchmark weights exceeds the preset threshold γ, the system will identify and mark this abnormal pattern as a potential escape attack, thus realizing timely early warning and defense against abnormal traffic flow patterns
[0169] Consistent with the above, please refer to Figure 7 , Figure 7 This application embodiment provides a structural schematic diagram of an identification device for traffic flow escape attacks. As Figure 7 Shown, the device includes:
[0170] An acquisition unit for acquiring historical traffic network traffic data and real-time traffic network traffic data;
[0171] A first processing unit for determining a first self-attention weight distribution according to the historical traffic network traffic data;
[0172] A second processing unit for determining a second self-attention weight distribution according to the real-time traffic network traffic data;
[0173] A determination unit for determining an escape attack recognition result of the real-time traffic network traffic data according to the first self-attention weight distribution and the second self-attention weight distribution.
[0174] In a possible implementation manner, in terms of acquiring the historical traffic network traffic data and the real-time traffic network traffic data, the first processing unit is configured to:
[0175] Determine a spatial feature sequence according to the historical traffic network traffic data by using a spatial attention mechanism;
[0176] Determine spatio-temporal dependence relationship node features according to the spatial feature sequence by using a temporal self-attention mechanism;
[0177] Determine a first self-attention weight distribution according to the spatio-temporal dependence relationship node features.
[0178] In a possible implementation manner, in terms of determining a spatial feature sequence according to the historical traffic network traffic data by using a spatial attention mechanism, the first processing unit is configured to:
[0179] Determine node features and an adjacency matrix according to the historical traffic network traffic data;
[0180] Determine a spatial attention feature vector according to the node features and the adjacency matrix by using a spatial attention mechanism;
[0181] Determine a self-attention score according to the spatial attention feature vector through an attention vector and a LeakyReLU activation function;
[0182] Perform normalization processing on the self-attention score by using a first exponential function to obtain a first spatial attention weight distribution;
[0183] Enhance the first spatial attention weight distribution by using a similarity metric function, a second exponential function, and a projection matrix to obtain a second spatial attention weight distribution;
[0184] Use the K - head self - attention mechanism to perform spatial feature aggregation on the second - space attention weight distribution to obtain a spatial node feature sequence;
[0185] Summarize the spatial node feature sequence to obtain a spatial feature sequence.
[0186] In a possible implementation manner, in the aspect of determining the spatio - temporal dependence relationship node features according to the spatial feature sequence, the first processing unit is used for:
[0187] Determine short - term trend features and long - term trend features according to the spatial feature sequence;
[0188] Dynamically fuse the short - term trend features and long - term trend features to obtain a time self - attention weight matrix;
[0189] Fuse the spatial feature sequence and the time self - attention weight matrix to obtain a fusion result;
[0190] Perform a non - linear activation function mapping on the fusion result to obtain spatio - temporal dependence relationship node features.
[0191] In a possible implementation manner, in the aspect of determining short - term trend features and long - term trend features according to the spatial feature sequence, the first processing unit is used for:
[0192] Perform a linear transformation on the spatial feature sequence to obtain short - term trend features;
[0193] Perform a weighted aggregation on the short - term trend features to obtain long - term trend features.
[0194] In a possible implementation manner, in the aspect of determining the first self - attention weight distribution according to the spatio - temporal dependence relationship node features, the first processing unit is used for:
[0195] Transform the spatio - temporal dependence relationship node features through three linear transformation weight matrices to obtain a query matrix, a key matrix, and a value matrix;
[0196] Use the exp exponential function to perform normalization on the query matrix, the key matrix, and the value matrix to obtain the first self - attention weight distribution.
[0197] In a possible implementation manner, in the aspect of determining the escape attack recognition result of the real - time traffic network traffic data according to the first self - attention weight distribution and the second self - attention weight distribution, the first processing unit is used for:
[0198] Extract the difference between the first self - attention weight distribution and the second self - attention weight distribution to obtain an attention weight deviation value;
[0199] Compare the attention weight deviation value with a preset threshold to obtain a comparison result;
[0200] Determine the escape attack recognition result of the real-time traffic network flow data according to the comparison result.
[0201] For those consistent with the above embodiments, please refer to Figure 8 , Figure 8 which is a schematic structural diagram of a terminal provided by an embodiment of the present application. As shown in the figure, it includes a processor, an input device, an output device, and a memory. The processor, input device, output device, and memory are interconnected. Among them, the memory is used to store a computer program, the computer program includes program instructions, and the processor is configured to call the program instructions. The above program includes instructions for performing the following steps;
[0202] Obtain historical traffic network flow data and real-time traffic network flow data;
[0203] Determine the first self-attention weight distribution according to the historical traffic network flow data;
[0204] Determine the second self-attention weight distribution according to the real-time traffic network flow data;
[0205] Determine the escape attack recognition result of the real-time traffic network flow data according to the first self-attention weight distribution and the second self-attention weight distribution.
[0206] In this example, by first obtaining historical traffic network flow data and real-time traffic network flow data to obtain the second attention weight distribution, then determining the first self-attention weight distribution according to the historical traffic network flow data, determining the second self-attention weight distribution according to the real-time traffic network flow data, and then determining the escape attack recognition result of the real-time traffic network flow data based on the first self-attention weight distribution and the second self-attention weight distribution, that is, by comparing the difference in self-attention weights between real-time traffic data and normal historical traffic data, to identify the behavior of attackers trying to disrupt model decisions using abnormal data, so as to accurately identify escape attacks and solve the technical problem that existing traffic flow escape attacks are difficult to identify and reduce the accuracy of traffic flow prediction.
[0207] The present invention also provides a warning method for traffic flow escape attacks. By continuously evaluating the abnormal traffic flow detected by the anomaly recognition module, it distinguishes real attack behaviors from random noise or temporary anomalies. Specifically, this method accumulatively calculates the anomaly scores within a continuous time window. Only when the cumulative anomaly score S anomalyWhen it exceeds the preset alarm threshold γ, it will be determined as a potential escape attack, and then a warning signal will be sent to the traffic management system immediately. This decision-making mechanism based on cumulative anomaly scores significantly improves the robustness of the system, effectively reduces the false alarm rate, and ensures the accuracy and reliability of the warning.
[0208]
[0209] In the warning mechanism, Ano(t) represents the cumulative anomaly score at time t. By introducing a decay coefficient a dynamically balanced evaluation system is constructed. This design cleverly uses the decay mechanism to make the historical anomaly scores decay exponentially over time, which not only maintains the sensitivity to persistent anomaly patterns but also effectively reduces the interference of short-term fluctuations and occasional anomalies on the system's judgment, thus achieving a good balance between real-time monitoring and stability.
[0210] The warning module has two operations according to different cumulative anomaly scores Ano:
[0211] (1) Adversarial training: When the cumulative anomaly score Ano does not exceed the warning threshold γ, the system uses these abnormal data samples for the adversarial training of the STGAN-PW model. By introducing a regularization term λ task into the model loss function Loss 1 to dynamically adjust the self-attention weights of abnormal traffic flow data. This adaptive training strategy not only improves the model's adaptability to abnormal patterns but also ensures that the model can still maintain a high prediction accuracy when facing escape attacks through regularization constraints, thus significantly enhancing the robustness of the system.
[0212]
[0213] In the regularization mechanism of adversarial training, characterizes the self-attention weight correlation strength between node i and node j at time t. The weights are constrained by the L2 regularization term ‖.‖ 2 and at the same time, is introduced to quantify the relative change in centrality of node i from time t - 1 to t. This multi-dimensional regularization design can not only effectively control the influence of abnormal patterns on the attention distribution but also, by considering the dynamic change of node centrality, enable the model to better capture the temporal evolution characteristics of the network topology while maintaining the prediction accuracy.
[0214] (2) Warning: When the cumulative anomaly score Ano exceeds the preset threshold γ, the warning module will identify that these data may significantly interfere with the training process of the STGAN-PW model, thereby leading to a serious decline in the traffic flow prediction accuracy. In this case, the warning module will immediately trigger the alarm mechanism to timely remind the system administrator to pay attention to the potential threat of evasion attacks, so as to protect the model from malicious data intrusion and maintain the reliability and stability of the prediction system.
[0215] The above mainly introduces the solution of the embodiment of the present application from the perspective of the execution process on the method side. It can be understood that in order for the terminal to implement the above functions, it includes the corresponding hardware structure and / or software module for executing each function. Those skilled in the art should easily realize that, combining the units and algorithm steps of each example described in the embodiments provided in this article, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed in the way of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.
[0216] The embodiment of the present application can divide the functions of the terminal according to the above method examples. For example, each function unit can be divided corresponding to each function, or two or more functions can be integrated into one processing unit. The above integrated unit can be implemented in the form of hardware or in the form of a software function unit. It should be noted that the division of units in the embodiment of the present application is illustrative, only a logical function division, and there may be other division methods in actual implementation.
[0217] The embodiment of the present application also provides a computer storage medium, wherein the computer storage medium stores a computer program for electronic data exchange, and the computer program enables the computer to execute some or all of the steps of any one of the traffic flow evasion attack recognition methods recorded in the above method embodiments.
[0218] The embodiment of the present application also provides a computer program product, the computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program enables the computer to execute some or all of the steps of any one of the traffic flow evasion attack recognition methods recorded in the above method embodiments.
[0219] It should be noted that, for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that this application is not limited by the described action sequence, because according to this application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0220] In the above embodiments, the descriptions of the respective embodiments have their own focuses. For the parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0221] In the several embodiments provided by this application, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of the devices or units can be in electrical or other forms.
[0222] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place, or can be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0223] In addition, in each embodiment of the application, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated units can be implemented in the form of hardware or in the form of software program modules.
[0224] If the integrated unit is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on such an understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of this application. The aforementioned memory includes various media that can store program codes, such as USB flash drives, read-only memories (ROMs), random access memories (RAMs), external hard drives, magnetic disks, or optical discs.
[0225] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing relevant hardware through a program. This program can be stored in a computer-readable memory, and the memory can include: USB flash drives, read-only memories, random access memories, magnetic disks, or optical discs, etc.
[0226] The above has introduced the embodiments of this application in detail. Specific examples are used in this article to elaborate on the principles and implementation manners of this application. The description of the above embodiments is only used to help understand the method and its core idea of this application; at the same time, for those of ordinary skill in the art, according to the idea of this application, there will be changes in the specific implementation manners and application scopes. In summary, the content of this specification should not be construed as a limitation to this application.
Claims
1. A method for identifying traffic flow escape attacks, characterized in that: include: Obtain historical traffic network flow data and real-time traffic network flow data; Determining a first self-attention weight distribution according to the historical traffic network flow data; Determining a second self-attention weight distribution according to the real-time traffic network flow data; An escape attack identification result of the real-time traffic network flow data is determined according to the first self-attention weight distribution and the second self-attention weight distribution.
2. The method for identifying traffic flow evasion attacks according to claim 1, characterized in that: The determining, according to the historical traffic network flow data, a first self-attention weight distribution comprises: According to the historical traffic network flow data, a spatial feature sequence is determined using a spatial attention mechanism; According to the spatial feature sequence, a temporal self-attention mechanism is used to determine the spatiotemporal dependency node features; Determine a first self-attention weight distribution based on the spatiotemporal dependency node characteristics.
3. The method for identifying traffic flow escape attacks according to claim 2, characterized in that: The method of determining a spatial feature sequence by using a spatial attention mechanism according to the historical traffic network flow data includes: Determining node characteristics and an adjacency matrix based on the historical traffic network flow data; Determine a spatial attention feature vector using a spatial attention mechanism according to the node features and the adjacency matrix; Determine a self-attention score according to the spatial attention feature vector by using an attention vector and a LeakyReLU activation function; Normalizing the self-attention score using a first exponential function to obtain a first spatial attention weight distribution; The first spatial attention weight distribution is enhanced by using a similarity measurement function, a second exponential function and a projection matrix to obtain a second spatial attention weight distribution; Using a K-head self-attention mechanism to perform spatial feature aggregation on the second spatial attention weight distribution to obtain a spatial node feature sequence; The spatial node feature sequences are aggregated to obtain a spatial feature sequence.
4. The method for identifying traffic flow escape attacks according to claim 2, characterized in that: The step of determining the spatiotemporal dependency node features by using a temporal self-attention mechanism according to the spatial feature sequence includes: Determining short-term trend characteristics and long-term trend characteristics according to the spatial feature sequence; Dynamically merge the short-term trend features and the long-term trend features to obtain a temporal self-attention weight matrix; Fusing the spatial feature sequence and the temporal self-attention weight matrix to obtain a fusion result; The fusion result is mapped with a nonlinear activation function to obtain spatiotemporal dependency node features.
5. The method for identifying traffic flow escape attacks according to claim 4 is characterized in that: Determining short-term trend characteristics and long-term trend characteristics according to the spatial feature sequence includes: Performing linear change processing on the spatial feature sequence to obtain short-term trend features; The short-term trend features are weighted and aggregated to obtain long-term trend features.
6. The method for identifying traffic flow evasion attacks according to claim 2, characterized in that: The determining, according to the spatiotemporal dependency node feature, a first self-attention weight distribution comprises: The spatiotemporal dependency node features are transformed through three linear transformation weight matrices to obtain a query matrix, a key matrix and a value matrix; The query matrix, key matrix and value matrix are normalized using the exp exponential function to obtain a first self-attention weight distribution.
7. The method for identifying traffic flow evasion attacks according to claim 1, characterized in that: The step of determining the escape attack identification result of the real-time traffic network flow data according to the first self-attention weight distribution and the second self-attention weight distribution includes: Extracting the difference between the first self-attention weight distribution and the second self-attention weight distribution to obtain an attention weight deviation value; Compare the attention weight deviation value with a preset threshold to obtain a comparison result; According to the comparison result, an evasion attack identification result of the real-time traffic network flow data is determined.
8. A device for identifying traffic flow escape attacks, characterized in that: The device comprises: An acquisition unit, used for acquiring historical traffic network flow data and real-time traffic network flow data; A first processing unit, configured to determine a first self-attention weight distribution according to the historical traffic network flow data; A second processing unit, configured to determine a second self-attention weight distribution according to the real-time traffic network flow data; A determination unit is used to determine an escape attack identification result of the real-time traffic network flow data according to the first self-attention weight distribution and the second self-attention weight distribution.
9. A terminal, characterized in that: It includes a processor, an input device, an output device and a memory, which are interconnected, wherein the memory is used to store a computer program, the computer program includes program instructions, and the processor is configured to call the program instructions to execute the method for identifying traffic flow escape attacks as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the method for identifying a traffic flow escape attack according to any one of claims 1 to 7.