Graph space-time neural network prediction method and system fusing adaptive global perception space attention mechanism

By introducing an adaptive global perception spatial attention mechanism into the spatiotemporal graph neural network, the problem that traditional models cannot handle global events is solved, and adaptive fusion of local and global features is achieved, improving the accuracy and robustness of traffic flow prediction.

CN121745154APending Publication Date: 2026-03-27CHANGAN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-10
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Existing spatiotemporal graph neural network models cannot effectively utilize global features when processing global events, and traditional spatial attention mechanisms cannot adaptively balance local spatial relationships and global trends, resulting in decreased prediction accuracy.

Method used

An adaptive global awareness spatial attention mechanism is introduced. Global attention is calculated through global feature extraction and independent parameter matrices. Combined with a learnable fusion mechanism, the local and global attention weights are adaptively adjusted. The local and global attention matrices are fused, and graph convolution and temporal convolution operations are performed to generate prediction results.

Benefits of technology

It significantly improves the prediction accuracy under global emergencies, enhances the accuracy and robustness of inferring the state of remote nodes, and can achieve an adaptive balance between local heterogeneity and global homogeneity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121745154A_ABST
    Figure CN121745154A_ABST
Patent Text Reader

Abstract

The invention discloses a graph spatio-temporal neural network prediction method and system fused with an adaptive global perception space attention mechanism. The method comprises the following steps: acquiring spatio-temporal graph data and constructing an adjacent matrix; constructing a graph space-time neural network model; inputting the time-space diagram data into a time attention layer, calculating an attention weight in a time dimension and processing the data to obtain data after time attention processing; executing local space attention calculation and global feature extraction in parallel to obtain global features representing the overall trend; calculating a global attention weight by using an independent parameter matrix based on the global feature, and expanding the global attention weight to a node space to generate a global attention matrix; performing weighted summation on the local space attention matrix and the global attention matrix to generate an enhanced attention matrix; and carrying out graph convolution operation on the node features by using the enhanced attention matrix, extracting spatial features, carrying out time convolution operation to extract time features, and finally outputting a prediction result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of spatiotemporal graph neural networks and relates to a graph spatiotemporal neural network prediction method and system that integrates an adaptive global perception spatial attention mechanism. Background Technology

[0002] Spatial-Temporal Graph Neural Networks (STGNNs) are used for traffic prediction, modeling spatial relationships through graph structures and temporal dependencies through temporal modules. ASTGCN (Attention-based Spatial-Temporal Graph Convolutional Network) introduces learnable attention weights into spatial attention to capture the dynamic relationships between nodes. Related research includes the ASTGCN model proposed by GuoS et al., and models such as STGCN. In existing technologies, spatial attention mechanisms mainly calculate attention weights based on local relationships between nodes. Taking ASTGCN as an example, its spatial attention calculation is as follows: The system first obtains the node feature matrix X, which stores the features of each node at different time steps. Then, it uses three learnable parameter matrices W1, W2, and W3 to transform these features: first, X is multiplied by the transpose of W1, then multiplied by W2, to obtain an intermediate result; simultaneously, X is transposed and multiplied by the transpose of W3 to obtain another intermediate result. Multiplying these two results together and adding the bias term bs yields a matrix representing the similarity between nodes. Next, the system uses the sigmoid function to compress the values ​​of this similarity matrix to between 0 and 1, obtaining a preliminary attention score. Then, a linear transformation is applied to this score using the mapping matrix Vs to further adjust the attention weights. Finally, each row is normalized using softmax, making the sum of each row equal to 1. This transforms the attention score into a probability distribution, representing the degree of attention each node pays to other nodes. The core of this mechanism is calculating attention weights through the interaction between node features, thereby capturing the local spatial relationships between nodes. In traffic flow prediction, spatiotemporal graph neural network models can automatically identify which monitoring points have correlated traffic states. For example, features such as flow rate and speed of adjacent monitoring points may influence each other, and this mechanism can capture this local spatial correlation. However, when encountering global events (such as overall accidents, extreme weather, etc.), these events have an equal impact on all nodes, rather than exhibiting heterogeneous impacts in local space. Current technology has the following problems and shortcomings: Traditional spatial attention mechanisms focus only on local relationships between nodes and cannot effectively handle the uniform impact of global events on all nodes. Therefore, when a global event occurs, all nodes are similarly affected, but existing spatiotemporal graph neural network models still allocate attention only according to local spatial relationships, which leads to a decrease in model prediction accuracy.

[0003] Existing spatiotemporal graph neural network models do not consider a global perspective during feature extraction; these models typically only aggregate global information at the output layer, which prevents the full utilization of the global features inherent in the global events themselves. This design approach directly limits the ability of spatiotemporal graph neural network models to deeply understand and effectively model global events.

[0004] Existing spatial attention mechanisms are relatively simple in design and cannot adaptively balance local spatial relationships and global trends. When both local heterogeneity and global homogeneity exist simultaneously, the model struggles to make optimal attention allocations. Summary of the Invention

[0005] The purpose of this invention is to overcome the shortcomings of the prior art and provide a graph spatiotemporal neural network prediction method and system that integrates an adaptive global perception spatial attention mechanism, which can simultaneously focus on local spatial relationships and global trends, thereby improving prediction accuracy in global event scenarios.

[0006] To achieve the above objectives, the present invention employs the following technical solution: A graph-temporal neural network prediction method integrating an adaptive global perception spatial attention mechanism includes the following steps: Acquire spatiotemporal graph data, normalize the data, and construct an adjacency matrix; A graph spatiotemporal neural network model is constructed, which includes a temporal attention layer, a local spatial attention calculation module, a global feature extraction module, a global attention calculation module, and an attention fusion module. The normalized data is input into the temporal attention layer, the attention weights in the time dimension are calculated and the data is processed to obtain the data after temporal attention processing; The data after temporal attention processing is processed in parallel to perform local spatial attention computation and global feature extraction. The global feature extraction is to perform average pooling operation on the features of all nodes along the node dimension to obtain global features that represent the overall trend. Based on global features, global attention weights are calculated using independent parameter matrices, and these global attention weights are extended to the node space to generate a global attention matrix. By utilizing learnable fusion weight parameters and temperature parameters, the local spatial attention matrix and the global attention matrix are weighted and summed to generate an enhanced attention matrix; The enhanced attention matrix is ​​used to perform graph convolution on node features to extract spatial features, and temporal convolution is performed to extract temporal features. Finally, the prediction result is output.

[0007] A graph spatiotemporal neural network prediction system integrating an adaptive global perception spatial attention mechanism includes: The data preprocessing module is used to acquire spatiotemporal graph data, normalize the data, and construct an adjacency matrix. The model building module is used to build a graph spatiotemporal neural network model, which includes a temporal attention layer, a local spatial attention calculation module, a global feature extraction module, a global attention calculation module, and an attention fusion module. The time attention processing module is used to input normalized data into the time attention layer, calculate the attention weights in the time dimension, and process the data to obtain the time attention-processed data. The global feature extraction module is used to perform local spatial attention calculation and global feature extraction in parallel on the data after temporal attention processing. The global feature extraction is to perform average pooling operation on the features of all nodes along the node dimension to obtain global features that represent the overall trend. The attention calculation module is used to calculate global attention weights based on global features using independent parameter matrices, and to extend these global attention weights to the node space to generate a global attention matrix. The weighted summation module is used to perform weighted summation on the local spatial attention matrix and the global attention matrix using learnable fusion weight parameters and temperature parameters to generate an enhanced attention matrix; The prediction output module is used to perform graph convolution operations on node features using the enhanced attention matrix to extract spatial features, and perform temporal convolution operations to extract temporal features, and finally output the prediction results.

[0008] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the graph spatiotemporal neural network prediction method that incorporates an adaptive global awareness spatial attention mechanism.

[0009] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the graph spatiotemporal neural network prediction method that integrates an adaptive global perception spatial attention mechanism.

[0010] Compared with the prior art, the present invention has the following beneficial effects: This invention effectively addresses the problem that traditional models, which focus only on local spatial relationships, cannot cope with the uniform impact of global events (such as large-scale accidents or extreme weather) on all network nodes by introducing an adaptive global awareness spatial attention mechanism into a graph spatiotemporal neural network. First, global features of all network nodes are extracted through average pooling, and global attention is calculated using an independent parameter matrix, thereby capturing the influence of overall trends on inter-node relationships and compensating for the blind spots of local attention. Second, an adaptive fusion mechanism based on learnable parameters and a temperature coefficient is designed, enabling the model to dynamically adjust the weight distribution of local and global attention according to data features, achieving an adaptive balance between local heterogeneity and global homogeneity. Finally, a multi-task loss function is combined to simultaneously optimize global and node-level predictions. This design not only significantly improves the model's prediction accuracy under global sudden events but also effectively enhances the accuracy and robustness of inferring the state of distant nodes. Attached Figure Description

[0011] Figure 1 This is a complete flowchart of the spatiotemporal neural network prediction method of the present invention; Figure 2 This is a diagram of the global perception spatial attention mechanism architecture of this invention; Figure 3 This is a comparison diagram between the traditional spatial attention mechanism and the global perception spatial attention mechanism of this invention; Figure 4 This is the attention weight distribution diagram of the present invention; Figure 5 This is the attention weight distribution diagram of the present invention; Figure 6 This is a visualization of the attention heatmap of the present invention; Figure 7 This is a comparison chart of the global traffic and node-level prediction performance of this invention. Detailed Implementation

[0012] Part 1: Introduces the complete steps of the graph spatiotemporal neural network prediction method that integrates an adaptive global awareness spatial attention mechanism.

[0013] like Figure 1 As shown, the graph spatiotemporal neural network prediction method based on the fusion of adaptive global perception spatial attention mechanism described in this invention includes steps such as data preprocessing, model initialization, forward propagation calculation, loss calculation and backpropagation, model training, and model evaluation.

[0014] Step 1: Data preprocessing.

[0015] 1.1 Data Loading: Spatiotemporal graph data is loaded from the data source. The data format is a four-dimensional tensor, containing four dimensions: batch dimension B, node dimension N, feature dimension F, and time dimension T, where: B represents the batch size, ranging from 16 to 128 (preferably 64). N represents the number of nodes, ranging from 50 to 500 (307 nodes in this embodiment). F represents the feature dimension, ranging from 3 to 10 feature channels (6 feature channels in this embodiment: the first 3 are traffic data: flow rate, speed, and occupancy rate; the last 3 are accident data). T represents the number of time steps, ranging from 6 to 24 time steps (12 time steps in this embodiment).

[0016] 1.2 Data Normalization. The input data is standardized using the Z-score normalization method to normalize the data to a distribution with a mean of 0 and a standard deviation of 1. Specific steps are as follows: Calculate the mean and standard deviation of the training set. The formula for calculating the mean is: .

[0017] Where N is the number of training set samples, and X_train is the formula for calculating the standard deviation of the training set data:

[0018] Normalization formula: .

[0019] Where X represents the input data, μ represents the mean of the training set, and σ represents the standard deviation of the training set. The normalized data X_normalized has a mean of 0 and a standard deviation of 1.

[0020] The training, validation, and test sets were normalized using the same mean and standard deviation. 1.3 Adjacency Matrix Construction. An adjacency matrix A is constructed based on the spatial relationships between nodes. The method for constructing the adjacency matrix is ​​as follows: Distance-based adjacency matrix: When the distance between nodes is less than a threshold d, the adjacency matrix element is 1; otherwise, it is 0. The distance threshold d ranges from 1 to 10 kilometers (this embodiment uses the original adjacency matrix from the PEMS04 dataset). Adjacency matrix dimension: (N, N), where N is the number of nodes.

[0021] Step 2: Initialize the graph spatiotemporal neural network model.

[0022] 2.1 Parameter Matrix Initialization. Parameter initialization is performed using the PyTorch framework, as detailed below: 2.1.1 Initialization of local spatial attention parameters.

[0023] W1 parameter matrix: dimension (num_of_timesteps, ), uniformly initialized using Xavier. W2 parameter matrix: dimension (in_channels, num_of_timesteps), uniformly initialized using Xavier. W3 parameter matrix: dimension (in_channels, ), uniformly initialized using Xavier. Vs parameter matrix: dimension (num_of_vertices, num_of_vertices), uniformly initialized using Xavier. bs bias matrix: dimension (1, num_of_vertices, num_of_vertices), initialized to 0.

[0024] 2.1.2 Initialization of global attention parameters.

[0025] The W1_global parameter matrix has a dimension of (num_of_timesteps,) and is uniformly initialized using Xavier. The W2_global parameter matrix has a dimension of (in_channels, num_of_timesteps) and is uniformly initialized using Xavier. The W3_global parameter matrix has a dimension of (in_channels,) and is uniformly initialized using Xavier. The Vg parameter matrix has a dimension of (num_of_vertices, num_of_vertices) and is uniformly initialized using Xavier. The bg bias matrix has a dimension of (1, 1) and is initialized to 0.

[0026] 2.1.3 Initialization of fusion parameters.

[0027] alpha parameter: initialized to a value between 0.2 and 0.4 (preferably 0.3), indicating that initially local attention accounts for 60% to 80% and global attention accounts for 20% to 40%. temperature parameter: initialized to a value between 0.5 and 2.0 (preferably 1.0), used to control the softness or hardness of the sigmoid function.

[0028] Specific steps: Initialize the alpha parameter to 0.3 and the temperature parameter to 1.0. These two parameters are learnable during training and can be automatically adjusted based on data characteristics.

[0029] 2.2 Model Architecture Configuration. Number of spatial attention blocks (nb_block): 1–4 (preferably 2). Chebyshev polynomial order (K): 2–5 (preferably 3). Number of spatial filters (nb_chev_filter): 32–128 (preferably 64). Number of temporal filters (nb_time_filter): 32–128 (preferably 64). Time step (time_strides): 1–3 (preferably 1).

[0030] Step 3: Forward propagation calculation.

[0031] 3.1 Temporal Attention Calculation. Input data X passes through the temporal attention layer, and the attention weights along the time dimension are calculated. Specific operations include: The input data X has dimensions of batch size B, number of nodes N, feature dimension F, and time step T. The temporal attention matrix has dimensions of batch size B, time step T, and time step T. Each row is normalized using the softmax function to ensure that the sum of all elements in each row equals 1, representing the probability distribution of attention weights between different time steps.

[0032] Temporal attention processing: The input data X is multiplied by the temporal attention matrix to obtain the time-attention processed data X_TAt. The dimensions of the time-attention processed data X_TAt are maintained as batch size B, number of nodes N, feature dimension F, and time step T. See appendix for details. Figure 2 The temporal attention layer in the global awareness spatial attention mechanism architecture diagram.

[0033] 3.2 Local Spatial Attention Calculation. Local spatial attention is calculated for X_TAt to capture local relationships between nodes. Specific operations include: Replace with QKV projection calculation, left projection: The dimensions are (B, N, T). Here, X_TAt is the input data after temporal attention processing, with dimensions (B, N, F, T); W1 is the first-layer projection matrix, with dimensions (T, T); and W2 is the second-layer projection matrix, with dimensions (F, T). Matrix multiplication "·" represents matrix multiplication.

[0034] Right side projection: The dimensions are (B, T, N). Among them, W3 is the third-level projection matrix with dimensions (F, F); the superscript T indicates the matrix transpose operation.

[0035] Calculate attention score: The dimension is (B, N, N). Here, Product represents the similarity matrix between nodes, which is obtained by multiplying the matrices of the left projection and the right projection.

[0036] Generate local attention matrix: The dimension is (B, N, N), where σ(·) represents the sigmoid activation function, calculated as follows: The input values ​​are compressed to the (0, 1) interval; Vs is the mapping matrix with dimension (N, N); bs is the bias term with dimension (1, N, N).

[0037] Normalization process: .

[0038] The formula for calculating the softmax function is as follows: Normalize each row to ensure that the sum of the elements in each row is 1, representing the probability distribution of attention weights of each node to other nodes.

[0039] See appendix for details Figure 2 The local spatial attention computation part in the global perception spatial attention mechanism architecture diagram, and the attached... Figure 3 The left side of the comparison diagram between traditional spatial attention mechanisms and global perception spatial attention mechanisms shows the traditional method section.

[0040] 3.3 Global Feature Extraction. Unlike traditional methods, this invention extracts global features through average pooling. This is an innovative feature first proposed in this invention, used to capture the overall trend of all nodes and solve the problem that traditional methods cannot handle global events. Specific operation: Global feature calculation: The dimensions are (B, 1, F, T).

[0041] Where N is the number of nodes, Σ_n represents the summation over all n nodes, and X_TAt[n] represents the feature of the nth node. Through average pooling, the features of all nodes are averaged along the node dimension to obtain the global feature Global_feat. This feature represents the overall trend of all nodes and can capture the impact of global events.

[0042] See appendix for details Figure 2 The global feature extraction part in the global awareness spatial attention mechanism architecture diagram, and the attached... Figure 3 The right side of the figure shows the method of this invention, which is a comparison between traditional spatial attention mechanisms and global perception spatial attention mechanisms.

[0043] 3.4 Global Attention Calculation. Based on global features, this invention uses an independent parameter matrix to calculate global attention. This is an innovative point first proposed in this invention, differing from traditional methods that only calculate local attention. Specific operation: Global feature processing: The dimensions are (B, 1, T). Among them, W1_global is the parameter matrix of the first layer of global attention, with dimensions (T, T); W2_global is the parameter matrix of the second layer of global attention, with dimensions (F, T).

[0044] Calculate the right projection of global attention: The dimension is (B, T). Among them, W3_global is the parameter matrix of the third layer of global attention, with a dimension of (F, F).

[0045] Generate global attention score: The dimension is (B, 1, 1), where Σ_t represents the summation over all time steps t, and Global_LHS[t] and Global_RHS[t] represent the left and right projection results at the t-th time step, respectively.

[0046] Calculate the global attention weights: The dimension is (B, 1, 1), where σ represents the sigmoid activation function and bg is the global attention bias term with dimension (1, 1).

[0047] Extending to node space: The dimension is (B, N, N), where Vg is the global attention mapping matrix with dimension (N, N), which is expanded to (B, N, N) in the batch dimension.

[0048] Generate a global attention matrix: The dimension is (B, N, N), where ⊙ represents element-wise multiplication (Hadamard product), and global attention weights are applied to all node pairs.

[0049] Normalization process: .

[0050] The softmax function normalizes each row to ensure that the sum of the elements in each row is 1.

[0051] See appendix for details Figure 2 The global attention computation part in the global awareness spatial attention mechanism architecture diagram.

[0052] 3.5 Attention Fusion. Adaptive fusion of local and global attention is achieved using learnable fusion weights alpha and a temperature parameter. This is the adaptive fusion mechanism proposed in this invention, which automatically adjusts the local-to-global attention ratio based on data features, thus avoiding the hassle of manual parameter tuning. Specific operation: Calculate the fusion weights: .

[0053] Where α is a learnable fusion weight parameter, T is a temperature parameter, max represents the maximum value operation to ensure that the denominator is not less than 0.1 and to avoid division by zero error; σ represents the sigmoid activation function to ensure that the fusion weight a_normalized is in the range [0, 1].

[0054] Integrating local and global attention: The dimension is (B, N, N).

[0055] Where S_global_normalized is the normalized global attention matrix, S_local_normalized is the normalized local attention matrix, and α_normalized is the fusion weight. This formula fuses local and global attention through a weighted summation. When α_normalized is close to 1, it leans more towards global attention; when α_normalized is close to 0, it leans more towards local attention. The fused attention matrix S_enhanced preserves both local spatial relationships and incorporates the overall global trend.

[0056] See appendix for details Figure 2 The attention fusion part in the global awareness spatial attention mechanism architecture diagram, and the attached... Figure 3 The right side of the figure shows the method of this invention, which is a comparison between traditional spatial attention mechanisms and global perception spatial attention mechanisms.

[0057] 3.6 Graph convolution and temporal convolution.

[0058] Spatial features are extracted using Chebyshev graph convolution operations performed with the fused enhanced attention matrix S_enhanced. The Chebyshev graph convolution utilizes a Chebyshev multinomial approximation graph convolution kernel, applying spatial convolution operations to node features through the fused enhanced attention matrix to capture spatial relationships between nodes. Temporal convolution layers are then used to perform temporal convolution operations on the spatial features to extract temporal features. These temporal convolution layers employ one-dimensional convolution operations, sliding the convolution kernel along the temporal dimension to capture temporal dependencies in the time series. Through stacking multiple spatial-temporal blocks (each containing both Chebyshev graph convolution and temporal convolution), spatial and temporal features are progressively extracted and fused, ultimately yielding the feature representation used for prediction.

[0059] Step 4: Loss calculation and backpropagation.

[0060] 4.1 Multi-task loss calculation. Simultaneously optimize global traffic prediction (primary objective) and node-level traffic prediction (secondary objective). Specific operations include: Global traffic loss: Calculate the MAE loss between the predicted global traffic (the average of the predicted values ​​of all nodes) and the actual global traffic.

[0061] Global traffic prediction: The dimension is (B, T).

[0062] Where N is the number of nodes, Σ_n represents the summation over all n nodes, Outputs[n] represents the predicted value of the nth node, and Outputs_global represents the average of the predicted values ​​of all nodes, i.e., the global traffic prediction value.

[0063] Actual global traffic figures: The dimension is (B, T).

[0064] Where Labels[n] represents the true value of the nth node, and Labels_global represents the average of the true values ​​of all nodes, i.e., the true value of global traffic.

[0065] Global traffic loss:

[0066] Where B is the batch size, T is the number of time steps, Σ_b and Σ_t represent the summation over all batches b and time steps t, respectively, and || represents the absolute value operation. This loss function calculates the mean absolute error (MAE) between the predicted and actual values.

[0067] Node-level traffic loss: Calculate the MAE loss between the predicted and actual values ​​for each node.

[0068]

[0069] Where Outputs[b, n, t] and Labels[b, n, t] represent the predicted and actual values ​​for the b-th batch, the n-th node, and the t-th time step, respectively.

[0070] Total loss: .

[0071] Wherein, λ_global is the weight coefficient of global traffic loss, and λ_node is the weight coefficient of node-level traffic loss. Both are dynamically adjusted during training.

[0072] 4.2 Dynamic Loss Weight Adjustment Strategy: A progressive training strategy is adopted to dynamically adjust the weights of the global and node-level losses. Specific operations are as follows: For the first 20 epochs of training: lambda_global=1.0, lambda_node=0.0 (pure global optimization). For 20-50 epochs: lambda_global linearly decreases from 1.0 to 0.75, lambda_node linearly increases from 0.0 to 0.25. For 50-80 epochs: lambda_global linearly decreases from 0.75 to 0.65, lambda_node linearly increases from 0.25 to 0.35. After 80 epochs: lambda_global=0.6, lambda_node=0.4 (global-node balancing).

[0073] 4.3 Backpropagation and Parameter Update. Parameter updates are performed using the Adam optimizer. The specific steps are as follows: Optimizer: Adam. Learning rate: 0.0005–0.01 (preferably 0.001). Weight decay coefficient: 0.00001–0.001 (preferably 0.0001). Gradient clipping: max_norm ranges from 3.0 to 10.0 (preferably 5.0) to prevent gradient explosion. Parameter update: The Adam optimizer updates the model parameters based on the calculated gradients, including all learnable parameters such as local spatial attention parameters, global attention parameters, and fusion parameters.

[0074] Step 5: Training the graph-temporal neural network model. The parameters processed in Step 4 are used to train the model in Step 5.

[0075] 5.1 Training Parameter Settings. Batch size: 16–128 (64 preferred). Number of training epochs: 100–300 (200 preferred). Learning rate decay strategy: The learning rate decays to 0.5–0.9 times its original value every 50 epochs (0.8 times preferred).

[0076] 5.2 Training Monitoring. Monitor the following metrics: MAE, RMSE, and MAPE for global traffic prediction; MAE, RMSE, and MAPE for node-level traffic prediction; and the changing trend of the fusion weight alpha, ensuring it remains within a reasonable range (0.2–0.5).

[0077] Step 6: Evaluation of the graph spatiotemporal neural network model.

[0078] 6.1 Evaluate model performance on the test set. 6.2 Calculate various metrics for global traffic prediction and node-level traffic prediction. 6.3 Analyze prediction performance on different nodes to verify the effectiveness of the global awareness attention mechanism.

[0079] The graph spatiotemporal neural network model trained in step 5 and evaluated in step 6 is used to predict the global state of traffic.

[0080] Part Two: Using specific cases to illustrate the theory.

[0081] 2.1 Theoretical Feasibility of Global Perception Spatial Attention Mechanism The global perception spatial attention mechanism proposed in this invention is theoretically feasible. We illustrate this with a practical application case in a traffic flow prediction project. Specifically, we used the PEMS04 dataset, which contains 307 monitoring points and 6 feature channels: the first three are traffic data (flow rate, speed, and occupancy rate), and the last three are accident data. Based on this case, we conduct the following theoretical analysis: 2.1.1 Theoretical basis for global feature extraction. In the traffic flow prediction project of this invention, by comparing the experimental results of the old model (using only local spatial attention) and the new model (using global perception spatial attention), a key problem was found: the spatial mismatch problem.

[0082] The old model performed poorly on global traffic flow prediction tasks: MAE was 6.6823, RMSE was 9.3344, and MAPE was 3.9685%. Analysis revealed that when global events (such as traffic accidents) occur, traditional methods only focus on local spatial relationships between nodes, failing to effectively capture the equal impact of global events on all nodes. For example, in the event of a major traffic accident, traffic flow, speed, and occupancy rates at all 307 monitoring points in the entire road network are affected; this impact is global, not limited to a local area near the accident.

[0083] This invention extracts global features through average pooling, which theoretically has the following advantages: Mathematical representation: The formula for calculating global features is: Global_feat = (1 / N)·Σ_nX[n], with dimensions (B, 1, F, T) Where N is the number of nodes (307 in this embodiment), Σ_n represents the summation over all n nodes, and X[n] represents the feature matrix of the nth node with dimensions (B, F, T). The average pooling operation averages the features of all nodes along the node dimension to obtain the global feature Global_feat. This feature represents the overall trend of all 307 nodes and is mathematically represented as the average of the features of all nodes, which can effectively extract global information.

[0084] Information Preservation: The global features retain the feature dimension F (including flow rate, speed, occupancy rate, accident data, etc.) and the time dimension T, while compressing the node dimension N (from 307 to 1), enabling the global information to be effectively represented. In traffic flow prediction, the global features can represent the average traffic state of the entire road network, including average flow rate, average speed, average occupancy rate, and global accident impact.

[0085] Timing advantage: Compared to traditional methods, this invention introduces a global perspective at the feature extraction stage, rather than performing global aggregation only at the output layer. This allows for more full utilization of global information, enabling the model to perceive the impact of global events at an early stage.

[0086] Practical validation: The new model significantly outperforms the old model on the global traffic prediction task: MAE decreased from 6.6823 to 5.8751 (a reduction of 12.08%), RMSE decreased from 9.3344 to 8.0281 (a reduction of 13.99%), and MAPE decreased from 3.9685% to 3.5306% (a reduction of 11.03%), fully validating the effectiveness of global feature extraction. See appendix for details. Figure 2 The global feature extraction part in the global awareness spatial attention mechanism architecture diagram.

[0087] 2.1.2 Theoretical Basis for Global Attention Calculation. This invention uses independent parameter matrices to calculate global attention based on global features, which is theoretically sound. Problem Discovery Process: In this project, we discovered that the impact patterns of global events (such as traffic accidents) differ from those of local spatial relationships. Traditional methods using local spatial attention parameters (W1, W2, W3, Vs, bs) cannot effectively model the impact of global events. Therefore, we chose to use independent parameters to learn the impact patterns of global events on the overall network.

[0088] Theoretical Basis: The Necessity of Independent Parameters: Global attention uses independent parameter matrices (W1_global, W2_global, W3_global, Vg, bg) to learn the impact patterns of global events on the overall network. In traffic flow prediction, the impact patterns of global events (such as traffic accidents) differ from those of local spatial relationships; therefore, we need to use independent parameters to model this global impact.

[0089] Representation of the global attention matrix: The global attention matrix S_global has dimensions (B, 307, 307) and represents the impact of global events on all node pairs. In traffic flow prediction, global events (such as traffic accidents) will have a similar impact on all 307 node pairs, which is complementary to the local attention matrix S_local (representing the local spatial relationships between nodes).

[0090] The role of the mapping matrix: Through a learnable mapping matrix Vg (307×307 dimensions), global impacts can be mapped to the inter-node relationship space, enabling the effective utilization of global information. In traffic flow prediction, Vg can learn how global events propagate among the 307 nodes; for example, how the impact of a global accident affects the relationships between different node pairs. See appendix for details. Figure 2 The global attention computation part in the global awareness spatial attention mechanism architecture diagram.

[0091] 2.1.3 Theoretical Basis of the Adaptive Fusion Mechanism. The adaptive fusion mechanism proposed in this invention is theoretically extremely feasible: Problem Discovery Process: During the project, it was discovered that the impact of local spatial relationships and global events varies across different time periods and scenarios. For example, under normal traffic conditions, local spatial relationships may be more important; however, in the event of a global incident, the impact of the global event may be more significant. Therefore, we need to adopt a mechanism that can automatically adjust the local-to-global attention ratio based on data characteristics.

[0092] The necessity of learnable fusion weights: Learnable fusion weights, alpha, are normalized to the range [0, 1] using the sigmoid function, enabling automatic adjustment of the local-global attention allocation ratio based on data characteristics. In traffic flow prediction, the influence of local spatial relationships and global events varies across different time periods and scenarios. For example, under normal traffic conditions, local spatial relationships may be more important; while in the event of a global accident, the impact of global events may be more significant. Adaptive fusion mechanisms can automatically adjust this ratio based on data characteristics.

[0093] The role of the temperature parameter: The temperature parameter controls the "hardness" of the sigmoid function, balancing training stability and learning speed. When the temperature is higher, the sigmoid function is smoother, the weight changes more gradually, and training is more stable; when the temperature is lower, the sigmoid function is steeper, the weight changes more sensitively, and the learning speed is faster.

[0094] Reasonableness of the fusion formula: Fusion formula This ensures that the fused attention matrix not only preserves local spatial relationships but also incorporates global trends. In traffic flow prediction, the fused attention matrix can simultaneously capture local spatial relationships between nodes (such as the correlation of traffic states between adjacent road segments) and the impact of global events (such as the impact of global accidents on all road segments).

[0095] Actual verification: Among 307 nodes, 91 nodes (29.6%) achieved performance improvements in single-node prediction. Among the top 5 performing nodes, node 12 saw its MAE decrease from 75.78 to 54.12 (a reduction of 28.58%), RMSE from 111.97 to 78.26 (a reduction of 30.11%), and MAPE from 18.32% to 14.75% (a reduction of 19.49%). These experimental data fully validate the effectiveness of the adaptive fusion mechanism.

[0096] See appendix for details Figure 2 Global awareness spatial attention mechanism architecture diagram and appendix Figure 3 Comparison of traditional spatial attention mechanism and global perception spatial attention mechanism.

[0097] 2.2 Theoretical Basis of the Multi-Task Loss Function. The multi-task loss function designed in this invention is theoretically reasonable: Problem discovery process: During the project, it was found that simply optimizing node-level traffic prediction could not effectively improve the accuracy of global traffic prediction. Therefore, we need to optimize both global traffic prediction (the average traffic of all nodes) and node-level traffic prediction. Thus, we need to find a strategy that can balance the needs of global prediction and node-level prediction.

[0098] Theoretical Basis: Global prediction and node-level prediction are complementary. We simultaneously optimize both global traffic flow prediction (the average traffic flow across all nodes) and node-level traffic flow prediction to better leverage the global perception attention mechanism. In traffic flow prediction tasks, global traffic flow prediction reflects the overall trend of the entire road network, while node-level prediction characterizes the specific state of each monitoring point. Combining the two helps improve the model's prediction accuracy.

[0099] We employ a progressive training strategy, gradually transitioning from pure global optimization to a global-node balancing approach. This allows the model to first learn global features and then gradually balance global and local capabilities. In the early stages of training, the model prioritizes learning global features (such as the impact of global events), which helps in understanding the impact patterns of global events. In the later stages of training, while maintaining global awareness, the model gradually improves the accuracy of predicting the specific states of each node.

[0100] Dynamic weight adjustment avoids the hassle of manual parameter tuning and automatically optimizes loss weights based on the training process. In traffic flow prediction, the requirements for global prediction and node-level prediction differ at different training stages, and dynamic weight adjustment can automatically adapt to these changes.

[0101] Practical verification: We adopted a progressive training strategy, gradually decreasing lambda_global from 1.0 to 0.6 and lambda_node from 0.0 to 0.4. Experimental results show that the new model significantly outperforms the old model on the global traffic prediction task, proving that the multi-task loss function is effective.

[0102] 2.3 Combined with the traffic flow prediction project of this invention, this invention has the following beneficial effects: 1. Addressing the issue of spatial mismatch: By incorporating global attention, we reduce the interference of local spatial heterogeneity on global event prediction. In traffic flow prediction, when a global incident occurs, traditional methods may fail to accurately predict changes in global traffic flow due to excessive focus on local spatial relationships. However, this invention, through a global perception attention mechanism, can better capture the impact of global events.

[0103] 2. Improved Prediction Accuracy: The global perception attention mechanism can more accurately capture the impact of global events, thereby improving prediction accuracy. In traffic flow prediction, the MAE of global flow prediction decreased by 12.08%, RMSE decreased by 13.99%, and MAPE decreased by 11.03%, proving that the global perception attention mechanism is effective.

[0104] 3. Adaptive Balancing: Learnable fusion weights can automatically adjust the local-to-global attention ratio based on data features, thereby achieving better prediction results. In traffic flow prediction, the influence of local spatial relationships and global events varies across different time periods and scenarios; the adaptive fusion mechanism can automatically adapt to these changes.

[0105] 4. Training Stability: Temperature parameters and progressive training strategies can enhance training stability and avoid oscillations during the training process. In traffic flow prediction, progressive training strategies allow the model to first learn global features and then gradually balance global and local capabilities, which helps stabilize the model during training.

[0106] See appendix for details Figure 4 Comparison of experimental results and appendix Figure 5 Attention weight distribution diagram.

[0107] Part Three: Verifying the effectiveness of the present invention.

[0108] 3.1 Experimental Setup. To verify the effectiveness of this invention, experiments were conducted using the PEMS04 dataset in a traffic flow prediction project. The experimental setup was as follows: Dataset: PEMS04 traffic dataset. Number of monitoring points: 307. Feature channels: 6 (the first 3 are traffic data: flow rate, speed, and occupancy rate; the last 3 are accident data). Number of time steps: 12 time steps.

[0109] Model configuration: Input dimensions: (Batch_size, 307, 6, 12). Output dimensions: (Batch_size, 307, 12) node-level traffic prediction. Number of spatial attention blocks: 2. Chebyshev polynomial order: 3. Number of spatial / temporal filters: 64. Initialization of fusion weights: alpha=0.3, temperature=1.0.

[0110] Training parameters: Learning rate: 0.001. Batch size: 64. Number of training epochs: 200. Optimizer: Adam (weight_decay=0.0001). Loss function: MaskedMAE. Multi-task loss weights: dynamically adjusted (lambda_global from 1.0→0.6, lambda_node from 0.0→0.4). Gradient clipping: max_norm=5.0.

[0111] 3.2 Comparison of experimental results.

[0112] 3.2.1 Comparison of Global Traffic Prediction. Comparing the experimental results of the old model (using only local spatial attention) and the new model (using global perceptual spatial attention): Experimental results show that the present invention significantly outperforms the baseline model on the global traffic prediction task: MAE is reduced by 12.08% (from 6.6823 to 5.8751), RMSE is reduced by 13.99% (from 9.3344 to 8.0281), and MAPE is reduced by 11.03% (from 3.9685% to 3.5306%).

[0113] See appendix for details Figure 4 The experimental results comparison chart (containing four sub-charts: top left for global traffic prediction MAE comparison, top right for global traffic prediction RMSE comparison, bottom left for global traffic prediction MAPE comparison, and bottom right for a comprehensive comparison of the three indicators in a bar chart) and appendix. Figure 7 : Comparison chart of global traffic and node-level prediction performance (containing four sub-charts: top left is the comparison of global traffic prediction MAE, top right is the comparison of global traffic prediction RMSE, bottom left is the comparison of node-level prediction MAE, and bottom right is the comparison of node-level prediction RMSE).

[0114] 3.2.2 Comparison of Node-Level Traffic Prediction. Experimental results show that node-level traffic prediction slightly decreased, which is because the model focuses more on global traffic prediction, a result that is in line with expectations. Meanwhile, out of 307 nodes, 91 nodes (29.6%) achieved performance improvement in single-node prediction, indicating that the global awareness attention mechanism is effective at specific nodes.

[0115] See appendix for details Figure 4The experimental results comparison chart (containing four sub-charts: top left for global traffic prediction MAE comparison, top right for global traffic prediction RMSE comparison, bottom left for global traffic prediction MAPE comparison, and bottom right for a comprehensive comparison of the three indicators in a bar chart) and appendix. Figure 7 : Comparison chart of global traffic and node-level prediction performance (containing four sub-charts: top left is the comparison of global traffic prediction MAE, top right is the comparison of global traffic prediction RMSE, bottom left is the comparison of node-level prediction MAE, and bottom right is the comparison of node-level prediction RMSE).

[0116] 3.3 Attention Weight Distribution Analysis. To analyze the working principle of the global perception attention mechanism, the weight distribution of local attention, global attention, and fused attention at different nodes was analyzed.

[0117] 3.3.1 Characteristics of attention weight distribution.

[0118] Local attention (corresponding appendix) Figure 5 Top-left subgraph: Primarily focuses on the local spatial relationships between nodes, with weight distribution exhibiting local clustering characteristics. Global attention (corresponding to the appendix) Figure 5 Top right subgraph: Primarily focuses on the impact of global events, with weight distribution exhibiting a globally uniform characteristic. Attention after fusion (corresponding appendix) Figure 5 (Lower left subplot): This combines local and global features, with weight distribution that retains local spatial relationships while also incorporating global trends. (Appendix) Figure 5 The bottom right subplot is a comparison of the three attention distributions, visually demonstrating the differences between local, global, and fused attention.

[0119] See appendix for details Figure 5 Attention weight distribution diagram (containing four sub-graphs: top left is the local spatial attention distribution, top right is the global attention distribution, bottom left is the fused attention distribution, and bottom right is a comparison of the three attention distributions).

[0120] 3.3.2 Trend of Fusion Weight alpha. During training, the trend of fusion weight alpha is as follows: Initial value: alpha = 0.3 (indicating an initial 30% global and 70% local attention). During training: alpha varies within the range of 0.2 to 0.5, indicating that the model can automatically adjust the local-to-global attention ratio based on data features. Final value: alpha stabilizes within a reasonable range, ensuring that the fused attention matrix retains both local spatial relationships and incorporates the overall global trend.

[0121] See appendix for details Figure 5Attention weight distribution diagram (containing four sub-graphs: top left is the local spatial attention distribution, top right is the global attention distribution, bottom left is the fused attention distribution, and bottom right is a comparison of the three attention distributions) 3.4 Attention Visualization Analysis. To more intuitively understand the working principle of the global awareness attention mechanism, the local attention matrix, global attention matrix, and fused attention matrix were visualized.

[0122] 3.4.1 Visualization of the Local Attention Matrix. The local attention matrix S_local has dimensions (B, 307, 307), representing the local spatial relationships between nodes. (See attached...) Figure 6 The visualization results of the top-left subgraph show that the local attention matrix exhibits characteristics of local clustering, mainly focusing on the relationship between adjacent nodes.

[0123] 3.4.2 Visualization of the Global Attention Matrix. The global attention matrix S_global has dimensions (B, 307, 307) and represents the impact of global events on all node pairs. (See attached...) Figure 6 The visualization results of the top right subgraph show that the global attention matrix exhibits a globally uniform characteristic, indicating that global events have a similar impact on all node pairs.

[0124] 3.4.3 Visualization of the Fuded Attention Matrix. The fused attention matrix S_enhanced has dimensions (B, 307, 307), representing the fused attention weights. (See attached...) Figure 6 The visualization results in the lower left subgraph show that the fused attention matrix preserves both local spatial relationships and incorporates global trends, indicating that the global awareness attention mechanism can effectively balance local and global features. (Appendix) Figure 6 The bottom right subplot is a heatmap showing the difference before and after fusion (S_enhanced-S_local), which visually demonstrates the effect of the fusion mechanism on adjusting attention weights.

[0125] See appendix for details Figure 6 Attention heatmap visualization (containing four sub-plots: top left is the local spatial attention heatmap, top right is the global attention heatmap, bottom left is the fused attention heatmap, and bottom right is the difference heatmap before and after fusion; all heatmaps are displayed in black and white grayscale).

[0126] 3.5 Single-Node Performance Analysis. To further verify the effectiveness of the global perception attention mechanism, a detailed analysis of the prediction performance of a single node was conducted.

[0127] 3.5.1 Overall Node Performance Improvement. Among the 307 nodes, 91 nodes (29.6%) achieved performance improvement in single-node prediction, indicating that the global perception attention mechanism is effective on specific nodes.

[0128] 3.5.2 Typical Node Performance Analysis Among the top 5 performing nodes, the detailed analysis of node 12 is as follows: The MAE of node 12 decreased from 75.78 to 54.12 (a decrease of 28.58%), the RMSE decreased from 111.97 to 78.26 (a decrease of 30.11%), and the MAPE decreased from 18.32% to 14.75% (a decrease of 19.49%), which proves that the global awareness attention mechanism is effective on specific nodes.

[0129] The prediction performance comparison chart for node 12 (containing four subplots: top left is the MAE comparison for node 12, top right is the RMSE comparison for node 12, bottom left is the MAPE comparison for node 12, and bottom right is a scatter plot of the predicted and actual values ​​for node 12; among them, MAE decreased by 28.58%, RMSE decreased by 30.11%, and MAPE decreased by 19.49%, verifying the effectiveness of the global perception attention mechanism on specific nodes).

[0130] 3.6 Conclusion. Through experimental comparison and analysis, the present invention has the following beneficial effects: 1. On the global traffic prediction task, MAE was reduced by 12.08%, RMSE by 13.99%, and MAPE by 11.03%, verifying the effectiveness of the global awareness attention mechanism.

[0131] 2. By incorporating global attention, we reduced the interference of local spatial heterogeneity on global event prediction, achieving a performance improvement in single-node prediction for 29.6% of nodes.

[0132] 3. The learnable fusion weight alpha can automatically adjust the local-global attention allocation ratio according to data features to achieve optimal prediction results.

[0133] 4. By visualizing the attention weight distribution map and attention heatmap, we can intuitively demonstrate the working principle and effectiveness of the global perception attention mechanism.

[0134] The following are specific embodiments of the present invention to further illustrate the technical solution of the present invention.

[0135] Example 1: Global Traffic Flow Prediction (PEMS04 Dataset).

[0136] 1.1 Data Preparation. The PEMS04 traffic dataset was used, containing 307 monitoring points and 6 feature channels (the first 3 for traffic data: flow rate, speed, and occupancy rate; the last 3 for accident data). The prediction target was set as global flow rate (the average flow rate of all nodes).

[0137] 1.2 Model Configuration Parameters. Based on the parameter range given in Part 1, the specific parameters selected are as follows: Batch size: 64 (midpoint of parameter range 16-128). Number of nodes: 307 (actual number of nodes in the PEMS04 dataset). Feature dimension: 6 feature channels (the first 3 are traffic data: flow rate, speed, and occupancy rate; the last 3 are accident data). Number of time steps: T: 12 time steps (midpoint of parameter range 6-24). Number of spatial attention blocks: nb_block: 2 (midpoint of parameter range 1-4). Chebyshev polynomial order: K: 3rd order (midpoint of parameter range 2-5). Number of spatial filters: nb_chev_filter: 64 (midpoint of parameter range 32-128). Number of temporal filters: nb_time_filter: 64 (midpoint of parameter range 32-128). Fusion weight alpha: 0.3 (midpoint of parameter range 0.2-0.4). Temperature parameter: 1.0 (the midpoint of the parameter range of 0.5 to 2.0).

[0138] 1.3 Training Parameters. Learning rate: 0.001 (midpoint of the parameter range 0.0005–0.01). Weight decay coefficient: 0.0001 (midpoint of the parameter range 0.00001–0.001). Gradient clipping: max_norm: 5.0 (midpoint of the parameter range 3.0–10.0). Number of training epochs: 200 (midpoint of the parameter range 100–300). Optimizer: Adam. Loss function: MaskedMAE. Multi-task loss weights: dynamically adjusted (lambda_global from 1.0 → 0.6, lambda_node from 0.0 → 0.4).

[0139] 1.4 Parameter Comparison Experiment: To verify the effectiveness of the parameter range, the following parameter comparison experiment was conducted in this embodiment: 1.4.1 Batch size comparison experiment.

[0140] Example 1-1: batch_size=16 (endpoint values ​​of parameter range 16-128, using the METR_LA dataset, 207 nodes). Example 1-2: batch_size=32 (intermediate values ​​of parameter range 16-128, using the PEMS04 dataset, 307 nodes). Example 1-3: batch_size=64 (intermediate values ​​of parameter range 16-128, the preferred value, using the traffic_accident dataset, 307 nodes). Experimental results show that when batch_size=64, the model performs best on the global traffic prediction task.

[0141] 1.4.2 Learning rate comparison experiment.

[0142] Examples 1-4: learning_rate = 0.0008 (intermediate value in the parameter range of 0.0005 to 0.01, optimized configuration). Examples 1-5: learning_rate = 0.001 (intermediate value in the parameter range of 0.0005 to 0.01, preferred value). Experimental results show that when learning_rate = 0.001, the model training is stable and converges quickly.

[0143] 1.4.3 Experiment comparing fusion weights.

[0144] Examples 1-6: alpha=0.2 (endpoint values ​​in the parameter range of 0.2-0.4, optimized configuration). Examples 1-7: alpha=0.3 (intermediate values ​​in the parameter range of 0.2-0.4, preferred value). Experimental results show that when alpha=0.3, the model can effectively balance local and global attention, achieving the best prediction results.

[0145] 1.5 Experimental Results. Using the above optimized parameter configuration (batch_size=64, learning_rate=0.001, alpha=0.3), the experimental results on the PEMS04 dataset are as follows: Global traffic prediction: MAE was 5.8751, RMSE was 8.0281, and MAPE was 3.5306%, representing reductions of 12.08%, 13.99%, and 11.03% respectively compared to the baseline model. Node-level prediction: Among 307 nodes, 91 nodes (29.6%) achieved performance improvements in single-node prediction. Specifically, we found that node 12 saw a 28.58% reduction in MAE, a 30.11% reduction in RMSE, and a 19.49% reduction in MAPE.

[0146] See appendix for details Figure 4 Comparison of experimental results, attached: Figure 7 Global traffic and node-level prediction performance comparison chart: Node 12 prediction performance comparison chart.

[0147] 1.6 Typical Scenario Case Analysis. To intuitively demonstrate the technical effects of this invention in real-world scenarios, the following typical cases are selected for analysis: Scenario: The impact of a major traffic accident on the overall state of the road network. Event description: In the PEMS04 road network, a major traffic accident involving multiple vehicles occurred on the main road where node A (number 101) is located during the morning rush hour. This event not only caused a complete disruption of traffic flow at node A, but its impact also spread rapidly throughout the road network.

[0148] Limitations of traditional models (comparative models): Misjudgment of global impact: Traditional models rely solely on local spatial attention, and their predictions depend primarily on the relationship between node A and its neighboring nodes. Therefore, they can only predict the congestion caused by an accident in the vicinity, but cannot accurately predict the significant decrease in the average speed (global state) of the entire road network.

[0149] Misjudgment of remote nodes: For remote node B (number 258, not directly connected to A), the traditional model almost failed to predict the abnormal fluctuations in its traffic flow and speed due to its weak local correlation with A. In reality, due to global traffic flow reorganization, the traffic flow at node B increased by 18% in the 30 minutes following the accident.

[0150] The beneficial effects of the model of this invention: Accurately capturing the overall situation: The global perception attention mechanism of this invention quickly captures the overall trend of declining traffic and slowing speed across the entire road network through average pooling. As shown in the figure, the global average speed predicted by this invention (solid red line) is highly consistent with the actual value (dashed black line), accurately predicting a decrease of approximately 8 km / h after the accident, while the traditional model (dashed blue line) only predicted a tiny change of less than 3 km / h.

[0151] Accurate prediction of remote impact: For remote node B, the global attention mechanism of this invention identifies the event as a global event and assigns appropriate global attention weights to node B through an adaptive fusion mechanism. Therefore, the model successfully predicted the increase in traffic and decrease in speed of node B after the incident, and its MAE was reduced by 22.7% compared with the traditional model.

[0152] Conclusion: This case demonstrates that by introducing a global perception and adaptive fusion mechanism, the present invention effectively solves the "spatial mismatch" problem of traditional models when facing global events, which not only improves the accuracy of global state prediction, but also enhances the ability to infer the states of seemingly unrelated remote nodes.

[0153] Example 2: Other spatiotemporal prediction tasks.

[0154] The global perception attention mechanism of this invention is also applicable to other spatiotemporal prediction tasks, specifically including: 2.1 Energy network forecasting.

[0155] Power Grid Load Forecasting: Using power grid node data, forecast the global load demand of the entire power grid. Number of Nodes: 50–500 power grid nodes. Feature Dimensions: 3–10 feature channels (including voltage, current, power, etc.). Number of Time Steps: 6–24 time steps. Forecast Target: Global load (average load of all nodes).

[0156] Application Case: When the power grid encounters global events such as extreme weather, traditional methods struggle to accurately predict the overall load change trend across the entire grid. This invention, through a global perception mechanism, can effectively capture the unified impact of such events on all substation nodes, thereby more accurately predicting the overall load change of the entire grid and providing a reliable basis for power grid dispatching.

[0157] Renewable Energy Generation Forecasting: Using node data from wind farms or photovoltaic power plants, forecast global power generation. Number of nodes: 50–500. Feature dimensions: 3–10 feature channels (including wind speed, solar irradiance, power generation, etc.). Number of time steps: 6–24 time steps. Forecast target: Global power generation (average power generation across all nodes).

[0158] Application Case: In wind farms or photovoltaic power plant clusters, when large-scale weather changes occur, this invention can accurately capture the overall trend of power generation changes across the entire cluster through a global feature extraction mechanism, overcoming the limitations of traditional methods that only focus on local correlations.

[0159] 2.2 Environmental monitoring.

[0160] Air Quality Forecast: Using data from air quality monitoring stations, predict the global air quality index (AQI) for the entire monitoring area. Number of stations: 50–500. Feature dimensions: 3–10 feature channels (including PM2.5, PM10, NO2, SO2, and other pollutant concentrations). Number of time steps: 6–24 time steps. Prediction target: Global AQI (average of all monitoring stations).

[0161] Application Case: When large-scale pollution events such as sandstorms and smog occur, this invention, through an adaptive fusion mechanism, can accurately predict the overall trend of air quality index changes in the entire monitoring area and make more accurate predictions of the pollution level at monitoring points in different locations.

[0162] 2.3 Sensor Networks.

[0163] IoT Sensor Data Prediction: Predicting the global sensor state using data from IoT sensor nodes. Number of nodes: 50–500 sensor nodes. Feature dimensions: 3–10 feature channels (including sensor readings, status information, etc.). Number of time steps: 6–24 time steps. Prediction target: Global sensor state (average value across all sensor nodes).

[0164] Application Case: In large industrial equipment monitoring networks, when system-level faults or changes in operating conditions occur, this invention can quickly predict the overall trend of sensor status changes across the entire system and promptly detect abnormal propagation patterns through a global attention mechanism.

[0165] 2.4 Financial Network.

[0166] Related Stock Price Prediction: Using stock network node data, predict the overall market index. Number of nodes: 50-500 stocks. Feature dimensions: 3-10 feature channels (including price, volume, market capitalization, etc.). Number of time steps: 6-24 time steps. Prediction target: Global sensor state (average value of all sensor nodes).

[0167] Application Case: When systemic financial risks or major policy adjustments occur, this invention, through a global perception mechanism, can more accurately predict the overall trend of the market index and capture the correlation between different sectors, providing support for risk management.

[0168] The above embodiments all employ the same model architecture and training method as Embodiment 1, requiring only adjustments to the data preprocessing and feature engineering sections based on specific application scenarios. These application examples demonstrate that the present invention can effectively handle global events in spatiotemporal prediction tasks across various fields, exhibiting broad application prospects.

[0169] See appendix for details Figure 4 Experimental results comparison chart (containing four sub-charts: top left for global traffic prediction MAE comparison, top right for global traffic prediction RMSE comparison, bottom left for global traffic prediction MAPE comparison, and bottom right for a comprehensive comparison of the three indicators in a bar chart), attached. Figure 5 Attention weight distribution diagram (containing four sub-graphs: top left is the local spatial attention distribution, top right is the global attention distribution, bottom left is the fused attention distribution, and bottom right is a comparison of the three attention distributions), attached. Figure 6 Attention heatmap visualization (containing four sub-plots: top left is the local spatial attention heatmap, top right is the global attention heatmap, bottom left is the fused attention heatmap, and bottom right is the difference heatmap before and after fusion; all heatmaps are displayed in grayscale). (Attached) Figure 7 : Comparison chart of global traffic and node-level prediction performance (containing four sub-charts: top left is the comparison of global traffic prediction MAE, top right is the comparison of global traffic prediction RMSE, bottom left is the comparison of node-level prediction MAE, and bottom right is the comparison of node-level prediction RMSE): Comparison chart of node 12 prediction performance (containing four sub-charts: top left is the comparison of node 12 MAE, top right is the comparison of node 12 RMSE, bottom left is the comparison of node 12 MAPE, and bottom right is a scatter plot of node 12 predicted values ​​and actual values).

[0170] A graph-temporal neural network prediction method integrating an adaptive global perception spatial attention mechanism includes the following steps: Acquire spatiotemporal graph data, normalize the data, and construct an adjacency matrix; A graph spatiotemporal neural network model is constructed, which includes a temporal attention layer, a local spatial attention calculation module, a global feature extraction module, a global attention calculation module, and an attention fusion module. The normalized data is input into the temporal attention layer, the attention weights in the time dimension are calculated and the data is processed to obtain the data after temporal attention processing; The data after temporal attention processing is processed in parallel to perform local spatial attention computation and global feature extraction. The global feature extraction is to perform average pooling operation on the features of all nodes along the node dimension to obtain global features that represent the overall trend. Based on global features, global attention weights are calculated using independent parameter matrices, and these global attention weights are extended to the node space to generate a global attention matrix. By utilizing learnable fusion weight parameters and temperature parameters, the local spatial attention matrix and the global attention matrix are weighted and summed to generate an enhanced attention matrix; The enhanced attention matrix is ​​used to perform graph convolution on node features to extract spatial features, and temporal convolution is performed to extract temporal features. Finally, the prediction result is output.

[0171] This embodiment also discloses a graph spatiotemporal neural network prediction system that integrates an adaptive global perception spatial attention mechanism, including: The data preprocessing module is used to acquire spatiotemporal graph data, normalize the data, and construct an adjacency matrix.

[0172] The model building module is used to build a graph spatiotemporal neural network model, which includes a temporal attention layer, a local spatial attention calculation module, a global feature extraction module, a global attention calculation module, and an attention fusion module.

[0173] The temporal attention processing module is used to input normalized data into the temporal attention layer, calculate the attention weights in the time dimension, and process the data to obtain the time-attention-processed data.

[0174] The global feature extraction module is used to perform local spatial attention calculation and global feature extraction in parallel on the data after temporal attention processing. The global feature extraction is to perform average pooling operation on the features of all nodes along the node dimension to obtain global features that represent the overall trend.

[0175] The attention calculation module is used to calculate global attention weights based on global features using an independent parameter matrix, and then extend these global attention weights to the node space to generate a global attention matrix.

[0176] The weighted summation module is used to perform weighted summation on the local spatial attention matrix and the global attention matrix using learnable fusion weight parameters and temperature parameters to generate an enhanced attention matrix.

[0177] The prediction output module is used to perform graph convolution operations on node features using the enhanced attention matrix to extract spatial features, and perform temporal convolution operations to extract temporal features, and finally output the prediction results.

[0178] This embodiment also discloses a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of the graph spatiotemporal neural network prediction method that integrates an adaptive global perception spatial attention mechanism.

[0179] This embodiment also discloses a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the graph spatiotemporal neural network prediction method that integrates an adaptive global perception spatial attention mechanism.

Claims

1. A graph spatiotemporal neural network prediction method integrating an adaptive global perception spatial attention mechanism, characterized in that, Includes the following processes: Acquire spatiotemporal graph data, normalize the data, and construct an adjacency matrix; A graph spatiotemporal neural network model is constructed, which includes a temporal attention layer, a local spatial attention calculation module, a global feature extraction module, a global attention calculation module, and an attention fusion module. The normalized data is input into the temporal attention layer, the attention weights in the time dimension are calculated and the data is processed to obtain the data after temporal attention processing; The data after temporal attention processing is processed in parallel to perform local spatial attention computation and global feature extraction. The global feature extraction is to perform average pooling operation on the features of all nodes along the node dimension to obtain global features that represent the overall trend. Based on global features, global attention weights are calculated using independent parameter matrices, and these global attention weights are extended to the node space to generate a global attention matrix. By utilizing learnable fusion weight parameters and temperature parameters, the local spatial attention matrix and the global attention matrix are weighted and summed to generate an enhanced attention matrix; The enhanced attention matrix is ​​used to perform graph convolution on node features to extract spatial features, and temporal convolution is performed to extract temporal features. Finally, the prediction result is output.

2. The graph spatiotemporal neural network prediction method based on an adaptive global perception spatial attention mechanism according to claim 1, characterized in that, The specific process of global feature extraction is as follows: Obtain the data after time attention processing, which includes batch dimension, node dimension, feature dimension and time dimension; Perform average pooling on the data along the node dimension, sum the feature values ​​of all nodes and divide by the number of nodes to obtain a global feature tensor that retains both the feature dimension and the time dimension.

3. The graph spatiotemporal neural network prediction method based on an adaptive global perception spatial attention mechanism according to claim 1, characterized in that, The process of generating the global attention matrix is ​​as follows: The global features are projected to the left using the first and second layer parameter matrices, and projected to the right using the third layer parameter matrix. Multiply the left projection result by the right projection result to generate the global attention score; The global attention score is processed using an activation function to obtain the global attention weights; The global attention weights are applied to all node pairs using the global attention mapping matrix, and each row is normalized to obtain the global attention matrix.

4. The graph spatiotemporal neural network prediction method based on an adaptive global perception spatial attention mechanism according to claim 1, characterized in that, The process of generating the local spatial attention matrix is ​​as follows: The data after time attention processing were projected to the left and right sides using different parameter matrices. Calculate the product of the left projection result and the right projection result to obtain the similarity matrix between nodes; The similarity matrix is ​​linearly transformed and nonlinearly activated using a mapping matrix and activation function, and the results are normalized to obtain the local spatial attention matrix.

5. The graph spatiotemporal neural network prediction method based on an adaptive global perception spatial attention mechanism according to claim 1, characterized in that, The specific process of generating the enhanced attention matrix is ​​as follows: Initialize the learnable fusion weight parameters and temperature parameters; Calculate the ratio of the fusion weight parameter to the temperature parameter, and use the activation function to map this ratio to the interval between 0 and 1 to obtain the normalized fusion weight; use the normalized fusion weight to weight the global attention matrix, and use the difference between 1 and the normalized fusion weight to weight the local spatial attention matrix. The weighted global attention matrix is ​​added to the weighted local spatial attention matrix to obtain the enhanced attention matrix.

6. The graph spatiotemporal neural network prediction method based on an adaptive global perception spatial attention mechanism according to claim 1, characterized in that, The process of calculating the loss when training a graph-temporal neural network model is as follows: Calculate the global traffic forecast, which is the average of the forecasts from all nodes. Calculate the true global traffic value, which is the average of the true values ​​of all nodes; Calculate the first mean absolute error between the global traffic prediction and the actual global traffic, and use it as the global traffic loss. Calculate the second mean absolute error between the predicted value and the actual value for each node, as the node-level traffic loss; By using the global traffic loss weighting coefficient and the node-level traffic loss weighting coefficient, the global traffic loss and the node-level traffic loss are weighted and summed to obtain the total loss.

7. The graph spatiotemporal neural network prediction method based on an adaptive global perception spatial attention mechanism according to claim 6, characterized in that, A gradual strategy is used to dynamically adjust the loss weight coefficients: In the initial training phase, the global traffic loss weight coefficient is set to the maximum value, and the node-level traffic loss weight coefficient is set to the minimum value. As the number of training rounds increases, the global traffic loss weight coefficient is gradually reduced in a linear proportion, while the node-level traffic loss weight coefficient is gradually increased at the same time. In the later stages of training, the global traffic loss weight coefficient and the node-level traffic loss weight coefficient are fixed at preset balance values.

8. A graph spatiotemporal neural network prediction system integrating an adaptive global perception spatial attention mechanism, characterized in that, include: The data preprocessing module is used to acquire spatiotemporal graph data, normalize the data, and construct an adjacency matrix. The model building module is used to build a graph spatiotemporal neural network model, which includes a temporal attention layer, a local spatial attention calculation module, a global feature extraction module, a global attention calculation module, and an attention fusion module. The time attention processing module is used to input normalized data into the time attention layer, calculate the attention weights in the time dimension, and process the data to obtain the time attention-processed data. The global feature extraction module is used to perform local spatial attention calculation and global feature extraction in parallel on the data after temporal attention processing. The global feature extraction is to perform average pooling operation on the features of all nodes along the node dimension to obtain global features that represent the overall trend. The attention calculation module is used to calculate global attention weights based on global features using independent parameter matrices, and to extend these global attention weights to the node space to generate a global attention matrix. The weighted summation module is used to perform weighted summation on the local spatial attention matrix and the global attention matrix using learnable fusion weight parameters and temperature parameters to generate an enhanced attention matrix; The prediction output module is used to perform graph convolution operations on node features using the enhanced attention matrix to extract spatial features, and perform temporal convolution operations to extract temporal features, and finally output the prediction results.

9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the graph spatiotemporal neural network prediction method as described in any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the graph spatiotemporal neural network prediction method as described in any one of claims 1 to 7.