A subway passenger flow prediction method based on adaptive chain and hierarchical attention

CN123014297APending Publication Date: 2026-10-30HUAZHONG NORMAL UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611146861.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-30
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

[0007]本发明要解决的技术问题在于针对现有技术中存在的以下技术问题:多源嵌入融合方式多用静态拼接的方式,无法适应动态场景;注意力权重由同一输入生成,导致全局特征主导、局部特征表达不足;模型对短时突发波动的响应能力较弱;提供一种基于自适应链式与分层注意力的地铁客流预测方法

Benefits of technology

(1)本发明通过自适应链式机制中的前向链和反馈链,实现了客流特征与时空先验的动态深度耦合,可学习系数允许模型自适应平衡原始观测与先验信息的贡献。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123014297A_ABST
    Figure CN123014297A_ABST
Patent Text Reader

Abstract

The application discloses a subway passenger flow prediction method based on adaptive chain and hierarchical attention, comprising the following steps: S1, extracting historical passenger flow, time attribute and subway network topology through a data embedding module, generating flow, time and space embedding, splicing time embedding and space embedding to obtain space-time prior; S2, through an adaptive chain module, guiding flow embedding to generate passenger flow space-time embedding in the forward chain with the space-time prior, calculating the deviation matrix between the passenger flow embedding and the original flow in the feedback chain, and obtaining the calibrated passenger flow space-time feature through residual fusion; S3, through a hierarchical attention module, the first stage utilizes the passenger flow space-time feature to generate global attention to extract stable space-time representation, and the second stage calculates the heterogenous attention after locally partitioning the passenger flow space-time embedding, and outputs the future passenger flow prediction result. The application can effectively balance the global stability and local sensitivity, significantly improve the accuracy of subway passenger flow prediction, and performs more excellent in the peak period.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of intelligent transportation technology, and in particular to a subway passenger flow prediction method based on adaptive chaining and hierarchical attention. Background Technology

[0002] Urban subway passenger flow forecasting is of great significance for operation scheduling, safety management, and passenger service. Existing methods are mainly divided into three categories: mathematical statistics methods (such as ARIMA), machine learning methods (such as random forests and support vector machines), and deep learning methods (such as graph neural networks and Transformers). Among them, models based on graph neural networks and attention mechanisms have made significant progress in capturing spatiotemporal dependencies.

[0003] However, existing technologies still have the following drawbacks: 1. Limited multi-source embedding fusion methods: Most methods simply concatenate or linearly weight temporal and spatial embeddings with the original passenger flow features, failing to adaptively adjust the contribution of each source feature according to dynamic scenarios, and are particularly difficult to cope with dynamic changes such as morning and evening peak hours and holidays.

[0004] 2. Homogeneous generation problem of attention mechanism: In existing Transformer-type models, the query Q, key K, and value V usually come from the linear projection of the same input. This causes the attention weights to mainly reflect the global periodic pattern and are insufficient to respond to short-term sudden fluctuations and local adjacency changes, resulting in an imbalance between global and local feature representation.

[0005] 3. Lack of effective local dynamic enhancement mechanisms: When dealing with long sequences, existing models tend to learn long-term trends, but have limited ability to capture rapid changes in passenger flow in a short period of time (such as sudden passenger flow).

[0006] Therefore, there is an urgent need for a subway passenger flow prediction method that can dynamically integrate multi-source information and balance global and local features. Summary of the Invention

[0007] The technical problem to be solved by this invention is to address the following technical issues existing in the prior art: multi-source embedding fusion methods mostly use static splicing, which cannot adapt to dynamic scenarios; attention weights are generated from the same input, resulting in global features dominating and insufficient expression of local features; the model has a weak response capability to short-term sudden fluctuations; and a subway passenger flow prediction method based on adaptive chaining and hierarchical attention is provided.

[0008] The technical solution adopted by this invention to solve its technical problem is: This invention provides a subway passenger flow prediction method based on adaptive chaining and hierarchical attention, the method comprising the following steps: S1: Construct a data embedding module to obtain historical passenger flow data, timestamps, holiday information, and subway network maps from the subway, and generate traffic embeddings through mapping in a fully connected layer. Extract timestamps and holiday information to generate embedded time data. Furthermore, eigenvalue decomposition is performed on the Laplacian matrix of the subway network graph to generate spatial embeddings. By splicing together temporal and spatial embeddings, a spatiotemporal prior is formed. ; S2: Construct adaptive chained modules, including forward chains and feedback chains: The forward chain will incorporate the spatiotemporal prior. As a query, the traffic embedding Passenger flow spatiotemporal embeddings are generated using an attention mechanism, serving as keys and values. ; The feedback chain embeds the spatiotemporal flow of passengers. As a query, the traffic embedding As keys and values, the bias matrix Δ is calculated, and then processed using learnable coefficients. The passenger flow spatiotemporal embedding after weighting the deviation matrix Δ The traffic embedding obtained in step S1 Residual fusion is performed to obtain the calibrated spatiotemporal characteristics of passenger flow. ; S3: Construct a hierarchical attention module, including the first and second stages: In the first stage, the calibrated spatiotemporal characteristics of passenger flow are utilized. Generate homogeneous attention weights and extract global spatiotemporal representations. ; In the second stage, the spatiotemporal embedding of passenger flow is performed. Local passenger flow spatiotemporal embedding is obtained by segmenting the data. The global spatiotemporal representation output by the first stage As keys and values, the local passenger flow is spatiotemporally embedded. As a query, heterogeneous attention weights are generated to obtain the final predicted passenger flow.

[0009] Furthermore, in the data embedding module of step S1 of the present invention, traffic embedding is generated. and time embedding The methods include: Traffic embedding generation: This involves generating historical passenger flow sequences. The input fully connected layer is mapped to traffic embedding. The calculation formula is:

[0010] in, Indicates a fully connected layer. As a dimension of traffic embedding, N The total number of stations, t Here, T represents the time step, and T represents the length of the historical sequence. Time embedding generation: timestamp and holiday signs They are converted into intermediate vectors through fully connected layers, and then combined with dynamic position encoding. By concatenating the data and then adjusting the dimensions through a fully connected layer, the temporal embedding is obtained. :

[0011] in, This indicates a splicing operation. For the embedding dimension of time.

[0012] Furthermore, in the data embedding module of step S1 of the present invention, spatial embedding is generated. and spacetime prior The methods include: Spatial Embedding Generation: Based on Connectivity Graph Constructing an adjacency matrix If the two stations are directly connected, then Otherwise, it is 0; symmetry processing Calculate the Laplace matrix. ;in, for The degree matrix; for Perform eigenvalue decomposition Take the front The eigenvectors corresponding to the smallest non-zero eigenvalues ​​are used to generate spatial embeddings through learnable linear transformations. , For the embedded dimension of space; Spatiotemporal prior construction: combining temporal and spatial embeddings to form a spatiotemporal prior. : .

[0013] Furthermore, in the adaptive chain module of step S2 of the present invention, the forward chain processing method includes: Embedded with traffic As a query, spacetime prior Using key and value pairs, scaled dot product attention is computed to generate a spatiotemporal embedding of passenger flow. :

[0014] in, The attention weights for querying Q in the forward chain. , These are the attention weights for the forward chain bond K and value V, respectively. d k For the projection dimension.

[0015] Furthermore, in the adaptive chain module of step S2 of the present invention, the method for processing the reverse chain includes: by As a query, traffic embedding As the key, calculate the deviation matrix. :

[0016] in, The attention weights for the front backlink query Q. The attention weights for the reverse chain bond K; Introducing learnable coefficients The calibrated spatiotemporal embedding of passenger flow is generated through the residual structure. :

[0017] when hour, The original traffic pattern is retained.

[0018] Furthermore, in the hierarchical attention module of step S3 of the present invention, the processing method in the first stage includes: Using time attention Through a two-layer fully connected network Generate weight matrix :

[0019]

[0020] Where E represents an unknown parameter; Output It is split into three temporal attention weight matrices , and :

[0021] Site At time step and The degree of correlation is:

[0022]

[0023] in, For the first The hidden state of the layer express Previous time step set; index t i This indicates that the process is currently in progress. time step 、t j The first one that is being watched time step 、t r This represents all time steps allowed to participate in attention calculations; The outputs of each element are concatenated to obtain the hidden state in the time dimension:

[0024] Spatial attention weights are achieved through spatial attention mechanisms. , and The generation method is the same as that of the temporal attention weight matrix; With time attention score The difference is in generating spatial attention scores. A multi-graph constraint mechanism was introduced:

[0025] in, It represents the Hadamah accumulation. This is a multi-graph fusion weight matrix, where the multi-graph includes a connection graph. Static similarity graph Dynamic similarity graph Correlation plot ; Finally, the output of the k-th attention submodule is obtained by multiplying the enhanced attention score by V, and the results of the K parallel spatial attention submodules are concatenated to obtain the site. vi In time interval t Space Hidden State:

[0026] The first-stage output is obtained through the feedforward network. .

[0027] Furthermore, the multiple diagrams of the present invention include connection diagrams. Static similarity graph Dynamic similarity graph Correlation plot Specifically: Connection diagram Based on the physical connections of the subway lines, if there is a direct rail connection between two stations, the edge weight is 1; otherwise, it is 0. Static similarity graph The static similarity between two stations is calculated using the Euclidean distance of historical passenger flow sequences, with edge weights as follows: ,in For the site The historical state vector; Dynamic similarity graph The similarity of passenger flow trends between stations is calculated using Dynamic Time Warping (DTW). Only the top K pairs of stations with the highest similarity are retained as virtual edges, and the edge weights are normalized DTW similarity. Correlation plot Based on passenger flow origin-destination (OD) distribution, calculate the distance from the station Station entry, station Percentage of passengers exiting the station The edge weights are normalized correlation ratios, where, Indicates from the site to station Passenger flow, Indicates from the site To any station Passenger flow.

[0028] Furthermore, in the hierarchical attention module of step S3 of the present invention, the second-stage processing method includes: For the output of the forward chain Perform segmentation; set the sequence length. , division length Step length Then the number of divisions ;along The dimension performs feature mapping on each segment to obtain the feature map where local features dominate. ; Use the first stage output pass Generate the weights of keys and values :

[0029] use Weight of generated queries :

[0030] The predicted passenger flow is then calculated and output according to the standard attention mechanism.

[0031] This invention provides a subway passenger flow prediction system based on adaptive chaining and hierarchical attention, comprising: The data embedding module is used to acquire historical passenger flow data to generate flow embedding, and to generate temporal embedding and spatial embedding, which are then spliced ​​together to obtain spatiotemporal priors; An adaptive chained module, including a forward chain and a feedback chain, is used to generate a spatiotemporal embedding of passenger flow and calibrate it to obtain calibrated spatiotemporal features of passenger flow. The hierarchical attention module includes a first attention stage and a second attention stage, which are used to extract global spatiotemporal representations and perform local dynamic adjustments, respectively, and finally output predicted passenger flow.

[0032] The present invention provides a computer-readable storage medium, characterized in that it stores a computer program for implementing the subway passenger flow prediction method based on adaptive chaining and hierarchical attention when executed by a processor.

[0033] The beneficial effects of this invention are: (1) This invention achieves dynamic deep coupling between passenger flow characteristics and spatiotemporal priors through the forward chain and feedback chain in the adaptive chain mechanism. The learnable coefficients allow the model to adaptively balance the contributions of the original observations and prior information.

[0034] (2) The present invention adopts a hierarchical attention architecture. In the first stage, global spatiotemporal representation is extracted, and in the second stage, local dynamic response is enhanced by block heterogeneous attention, which overcomes the defects of global feature dominance and insufficient local response in the traditional single-source attention mechanism. Attached Figure Description

[0035] The present invention will be further described below with reference to the accompanying drawings and embodiments. In the accompanying drawings: Figure 1 A schematic diagram of the subway passenger flow prediction method based on adaptive chaining and hierarchical attention provided by the present invention; Figure 2 A flowchart of the subway passenger flow prediction method based on adaptive chaining and hierarchical attention provided by this invention; Figure 3 The diagram shows the model architecture of the subway passenger flow prediction method based on adaptive chaining and hierarchical attention provided by this invention. Detailed Implementation

[0036] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0037] Example 1 This invention provides a subway passenger flow prediction system based on adaptive chaining and hierarchical attention, comprising: The data embedding module is used to acquire historical passenger flow data and generate traffic embedding. Extract time attributes to generate time embeddings Spatial embeddings are generated by performing Laplacian eigenvalue decomposition on the subway network graph. And splicing the temporal embedding and spatial embedding together to obtain the spatiotemporal prior. ; An adaptive chain module, connected to the data embedding module, is used for embedding the traffic. With spatiotemporal prior embedding Deep coupling and dynamic calibration are performed; the adaptive chain mechanism module specifically includes: The forward chain is used to generate passenger flow spatiotemporal embeddings by using spatiotemporal priors as queries and traffic embeddings as keys and values, through an attention mechanism. ; Feedback chains are used for spatiotemporal embedding of the passenger flow. As a query, traffic embedding The bias matrix Δ is calculated as keys and values, and then processed using learnable coefficients. The passenger flow spatiotemporal embedding after weighting the deviation matrix Δ Embedded with raw traffic Residual fusion is performed to obtain the calibrated spatiotemporal characteristics of passenger flow. ; The hierarchical attention module, connected to the adaptive chain mechanism module, is used to perform spatiotemporal embedding of the calibrated passenger flow. Multi-level spatiotemporal dependency modeling is performed; the hierarchical attention architecture module includes multiple processing layers, each layer containing: The first stage is used to embed the calibrated passenger flow spatiotemporally. As a common input, stable global attention weights are generated, and spatiotemporal representations reflecting long-term global patterns are extracted accordingly. The second stage connects to the attention unit of the first stage and is used to generate a global spatiotemporal representation based on the output of the attention unit of the first stage. As key and value terms, the local passenger flow spatiotemporal embedding after segmenting the passenger flow spatiotemporal embedding output by the forward chain unit is used. As a query term, learnable local adjustment weights are generated through the attention mechanism of heterogeneous input, and the final spatiotemporal representation with enhanced local sensitivity on the basis of global stability is extracted accordingly.

[0038] In a preferred embodiment of the present invention, the attention calculation method for the forward chain is as follows: The traffic embedding is used as Q to generate attention weights. Spacetime a priori As K and V, attention weights are generated. , Information related to the current passenger flow characteristics is obtained from spatiotemporal priors, so that the output spatiotemporal passenger flow characteristics include the original passenger flow characteristics and the temporal periodicity and spatial structure information extracted from the spatiotemporal priors:

[0039] In a preferred embodiment of the present invention, the deviation matrix of the feedback chain is calculated as follows: The spatiotemporal features of passenger flow output from the feed chain are Q, and attention weights are generated. The traffic containing the original passenger flow information is embedded as K to generate corresponding attention weights. First, the spatiotemporal features of passenger flow are embedded with traffic flow and then subjected to Softmax to calculate the deviation matrix Δ. Using actual passenger flow data, the spatiotemporal features of the current prediction scenario are identified, focusing on similar features and suppressing irrelevant features.

[0040] In a preferred embodiment of the present invention, the calibrated spatiotemporal characteristics of passenger flow are represented as follows: The calculated deviation matrix is ​​used as weights to weight the spatiotemporal characteristics of passenger flow for calibration. To balance the original and calibrated features, learnable coefficients are introduced. , When the volume is large, the model relies more on passenger flow data and can react to short-term emergencies more quickly; When the size is small, the model relies more on priors. To maintain global stability:

[0041] In a preferred embodiment of the present invention, in the first stage of the hierarchical attention module, a temporal attention mechanism and a spatial attention mechanism are used; both the temporal attention mechanism and the spatial attention mechanism generate attention weights using the same source input, that is, the query item, key item, and value item are all obtained from the same input through linear projection, and their calculation process can be uniformly represented as follows:

[0042]

[0043] Output It was split into three weight matrices , and :

[0044] The spatial attention mechanism employs multi-graph constraints to enhance spatial dependency modeling; specifically, for any two stations... and First, calculate its original attention score. Then, the score is fused with the pre-built multi-graph weights using the Hadamard Product to obtain the enhanced attention score. :

[0045] in, It represents the Hadamah accumulation. This is a multi-graph fusion weight matrix, where the multi-graph includes a connection graph. Static similarity graph Dynamic similarity graph Correlation plot This fusion mechanism enables the model to simultaneously capture multi-dimensional spatial relationships between stations, including physical connections, functional similarities, dynamic trends, and passenger flow correlations. The multiple graphs include connection graphs, static similarity graphs, dynamic similarity graphs, and correlation graphs, specifically: Connection diagram Based on the physical connections of the subway lines, if there is a direct rail connection between two stations, the edge weight is 1; otherwise, it is 0. Static similarity graph The static similarity between two stations is calculated using the Euclidean distance of historical passenger flow sequences, with edge weights as follows: ,in For the site The historical state vector; Dynamic similarity graph The similarity of passenger flow trends between stations is calculated using Dynamic Time Warping (DTW). Only the top K pairs of stations with the highest similarity are retained as virtual edges, and the edge weights are normalized DTW similarity. Correlation plot Based on passenger flow origin-destination (OD) distribution, calculate the distance from the station Station entrance, station Percentage of passengers exiting the station The edge weights are normalized correlation rates.

[0046] The output of the first stage is .

[0047] In a preferred embodiment of the present invention, the second stage of the hierarchical attention module employs a heterogeneous input mechanism to balance global trends and local fluctuations; specifically including: The spatiotemporal embedding of passenger flow output by the forward chain unit of the adaptive chain mechanism module The data is segmented into n non-overlapping sequence segments along the time dimension, and each segment is independently feature-mapped to obtain the local passenger flow spatiotemporal embedding. :

[0048]

[0049] The global spatiotemporal representation output by the first stage unit As key and value terms, the local passenger flow is embedded in spatiotemporal context. As a query term, calculate the heterogeneous attention weights:

[0050]

[0051] This design allows query terms to focus on local short-term features, while keys and values ​​retain global long-term features, thus achieving an effective synergy between global stability and local sensitivity in attention computation.

[0052] Example 2 like Figure 1 and Figure 2 As shown in the figure, the subway passenger flow prediction system based on adaptive chaining and hierarchical attention provided in this embodiment of the invention mainly includes: S1, Data Embedding Module: This module maps historical passenger flow data, time attributes (time stamps, holiday identifiers), and spatial structure information (multi-graph topology) to flow embedding, time embedding, and spatial embedding, respectively, and constructs a spatiotemporal prior representation.

[0053] In a preferred embodiment of the present invention, historical passenger flow data specifically includes: Passenger card numbers, entry stations, entry times, exit stations, and exit times are obtained from the subway's automatic fare collection system; the number of passengers entering and exiting each station is aggregated at fixed time intervals to obtain a passenger flow time series. , where N is the total number of stations and t is the time step.

[0054] S2, Adaptive Chain Module: Used to deeply couple and dynamically calibrate traffic embedding with spatiotemporal priors through forward and feedback chains, generating calibrated passenger flow spatiotemporal feature embeddings.

[0055] S3, Hierarchical Attention Module: Divided into two stages. The first stage uses calibrated embedding to generate global attention weights and extract long-term spatiotemporal dependencies; the second stage introduces segmented passenger flow spatiotemporal embedding, generates attention weights through heterogeneous inputs, and captures local dynamic patterns.

[0056] like Figure 3 As shown, the embodiments of the present invention mainly include three parts: the first part is a data embedding module; the second part is an adaptive chain module; and the third part is a hierarchical attention module.

[0057] Part 1: Data Embedding Module (1) Traffic embedding generation: historical passenger flow sequence The input fully connected layer is mapped to traffic embedding. The calculation formula is:

[0058] in, Indicates a fully connected layer. For the embedded dimension.

[0059] (2) Time embedding generation: timestamp (Minutes of the day) and holiday signs (Whether it is a weekend or a public holiday) are respectively converted into intermediate vectors through a fully connected layer, and then combined with dynamic position encoding. By concatenating the data and then adjusting the dimensions through a fully connected layer, the temporal embedding is obtained. :

[0060] in This indicates a splicing operation. .

[0061] (3) Spatial embedding generation: based on connection graph Constructing an adjacency matrix If the two stations are directly connected, then Otherwise, it is 0. Symmetry processing. Calculate the Laplace matrix. .in for The degree matrix. For Perform eigenvalue decomposition Take the front The eigenvectors corresponding to the smallest non-zero eigenvalues ​​are used to generate spatial embeddings through learnable linear transformations. , .

[0062] (4) Spatiotemporal prior construction: splicing temporal embedding and spatial embedding to form a spatiotemporal prior. :

[0063] Part Two: Adaptive Chained Modules (1) Forward chain processing: The attention calculation method for the forward chain is as follows: the traffic embedding is used as Q to generate attention weights. Spacetime a priori As K and V, attention weights are generated. , Information related to the current passenger flow characteristics is obtained from the spatiotemporal prior, so that the output spatiotemporal passenger flow characteristics include the original passenger flow characteristics and the temporal periodicity and spatial structure information extracted from the spatiotemporal prior.

[0064] Embedded with traffic As a query, spacetime prior Using key and value pairs, scaled dot product attention is computed to generate a spatiotemporal embedding of passenger flow. :

[0065] (2) Feedback chain processing: The deviation matrix of the feedback chain is calculated as follows: the spatiotemporal embedding of the passenger flow output from the forward chain is Q, and attention weights are generated. The traffic flow containing the original passenger flow information is embedded as K to generate corresponding attention weights. First, the spatiotemporal embedding of passenger flow and the flow embedding are subjected to Softmax to calculate the deviation matrix Δ. Then, using actual passenger flow data, the spatiotemporal characteristics of the current prediction scenario are identified, focusing on similar features and suppressing irrelevant features.

[0066] by As a query, traffic embedding As the key, calculate the deviation matrix. :

[0067] The calculated deviation matrix is ​​used as weights to weight the spatiotemporal characteristics of passenger flow for calibration. To balance the original and calibrated features, learnable coefficients are introduced. , When the volume is large, the model relies more on passenger flow data and can reflect short-term emergencies more quickly; When the size is small, the model relies more on priors. To maintain overall stability.

[0068] Introducing learnable coefficients (Initialized to 0.2), the calibrated spatiotemporal embedding of passenger flow is generated through the residual structure. :

[0069] when hour, The original traffic pattern is preserved.

[0070] Part Three: Layered Attention Module This module contains a total of The layers are divided into two stages.

[0071] (1) First stage: Global attention extraction (same source input) The system employs both temporal and spatial attention mechanisms. Both mechanisms generate attention weights using the same source input, meaning that the query item, key item, and value item are all obtained from the same input through linear projection.

[0072] Using time attention Through a two-layer fully connected network Generate weight matrix :

[0073]

[0074] Split the output into three matrices , and :

[0075] Then calculate the time attention score for the site. At time step and The degree of correlation is:

[0076]

[0077] in For the first The hidden state of the layer express The previous set of time steps. The outputs of each element are concatenated to obtain the hidden state in the time dimension:

[0078] Spatial attention weights are achieved through spatial attention mechanisms. , and The generation method is exactly the same as that of temporal attention. Both are based on joint projection of the same source input, which is learned simultaneously during training and then split.

[0079] With time attention score The difference is in generating spatial attention scores. A multi-graph constraint mechanism is introduced, which, compared to not using multi-graph constraints, can more accurately capture multi-scale and multi-type site relationships, enhancing the model's ability to express complex spatial dependencies.

[0080] Finally, by multiplying the enhanced attention score by V, the output of the k-th attention submodule is obtained, and the results of the K parallel spatial attention submodules are concatenated to obtain the spatial hidden state of station vi at time interval t:

[0081] The first-stage output is obtained through the feedforward network. .

[0082] (2) Second stage: Local dynamic adjustment (heterogeneous input) For the output of the forward chain The sequence is segmented into n non-overlapping segments along the time dimension, and each segment is independently feature-mapped. Let the sequence length be... , division length Step length Then the number of divisions .along The dimension performs feature mapping on each segment to obtain the feature map where local features dominate. .

[0083] Use the first stage output pass Weights for generating keys and values:

[0084] use The weights for generating queries are calculated, i.e., the weights for heterogeneous attention:

[0085] This design allows query terms to focus on local short-term features, while keys and values ​​retain global long-term features, thus achieving an effective synergy between global stability and local sensitivity in attention computation.

[0086] The output is then calculated using the standard attention mechanism. In this stage, because Q and K come from different sources (heterogeneous input), the query end is better able to express local short-term features, thus enhancing its sensitivity to sudden fluctuations. After the layer, the final hidden state is obtained. .

[0087] Example 3 In the overall performance comparison of other baseline methods across the entire test set, the results for the HZMetro and SHMetro datasets are shown in Table 1 and Table 2, respectively. Bold text is used to highlight the best result in each row, and underlined text is used to indicate the second-best result.

[0088] Other prediction methods include: Historical Average (HA), Random Forest (RF), Feedforward Neural Network (FNN), Diffusion Convolutional Recurrent Neural Network (DCRNN), Graph-WaveNet (GWN), A Graph Multi-Attention Network for Traffic Prediction (GMAN), Physical-Virtual Collaboration Modeling for Intra-and Inter-Station Subway Ridership Prediction (PVCGN), A Novel Framework for Spatial–Temporal Traffic Prediction (MGT).

[0089] Experimental results show that the present invention achieves optimal performance on both the HZMetro and SHMetro real-world subway datasets, while MGT performs second best overall. On the SHMetro dataset, CACH achieves average improvements of 4.06%, 2.92%, and 4.24% in RMSE, MAE, and MAPE, respectively, compared to the second-best model across four prediction steps. On the HZMetro dataset, the average improvements in these three metrics are 3.06%, 3.21%, and 4.23%, respectively.

[0090] Table 1. Subway passenger flow prediction results on the HZMetro dataset.

[0091] Table 2. Subway passenger flow prediction results on the SHMetro dataset.

[0092] Example 4: Application Example An application embodiment of the present invention provides a computer device, which includes a memory and a processor. The memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps of a subway passenger flow prediction method based on adaptive chaining and hierarchical attention.

[0093] An application embodiment of the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, causes the processor to perform steps of a subway passenger flow prediction method based on adaptive chaining and hierarchical attention.

[0094] An application embodiment of the present invention provides an information data processing terminal, which is used to implement a deep learning-based system for predicting sudden passenger flow in rail transit.

[0095] It should be noted that embodiments of the present invention can be implemented in hardware, software, or a combination of both. The hardware portion can be implemented using dedicated logic; the software portion can be stored in memory and executed by a suitable instruction execution system, such as a microprocessor or dedicated-design hardware. Those skilled in the art will understand that the above-described devices and methods can be implemented using computer-executable instructions and / or included in processor control code, for example, such code provided on a carrier medium such as a disk, CD, or DVD-ROM, a programmable memory such as read-only memory (firmware), or a data carrier such as an optical or electronic signal carrier. The devices and modules of the present invention can be implemented by hardware circuitry such as very large-scale integrated circuits or gate arrays, semiconductors such as logic chips, transistors, or programmable hardware devices such as field-programmable gate arrays, programmable logic devices, etc., or by software executed by various types of processors, or by a combination of the above-described hardware circuitry and software, such as firmware.

[0096] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0097] It should be understood that those skilled in the art can make improvements or modifications based on the above description, and all such improvements and modifications should fall within the protection scope of the appended claims.

Claims

1. A subway passenger flow prediction method based on adaptive chaining and hierarchical attention, characterized in that, The method includes the following steps: S1: Construct a data embedding module to obtain historical passenger flow data, timestamps, holiday information, and subway network maps from the subway, and generate traffic embeddings through mapping in a fully connected layer. Extract timestamps and holiday information to generate embedded time data. Furthermore, eigenvalue decomposition is performed on the Laplacian matrix of the subway network graph to generate spatial embeddings. By splicing together temporal and spatial embeddings, a spatiotemporal prior is formed. ; S2: Construct adaptive chained modules, including forward chains and feedback chains: The forward chain will incorporate the spatiotemporal prior. As a query, the traffic embedding Passenger flow spatiotemporal embeddings are generated using an attention mechanism, serving as keys and values. ; The feedback chain embeds the spatiotemporal flow of passengers. As a query, the traffic embedding As keys and values, the bias matrix Δ is calculated, and then processed using learnable coefficients. The passenger flow spatiotemporal embedding after weighting the deviation matrix Δ The traffic embedding obtained in step S1 Residual fusion is performed to obtain the calibrated spatiotemporal characteristics of passenger flow. ; S3: Construct a hierarchical attention module, including the first and second stages: In the first stage, the calibrated spatiotemporal characteristics of passenger flow are utilized. Generate homogeneous attention weights and extract global spatiotemporal representations. ; In the second stage, the spatiotemporal embedding of passenger flow is performed. Local passenger flow spatiotemporal embedding is obtained by segmenting the data. The global spatiotemporal representation output by the first stage As keys and values, the local passenger flow is spatiotemporally embedded. As a query, heterogeneous attention weights are generated to obtain the final predicted passenger flow.

2. The subway passenger flow prediction method based on adaptive chaining and hierarchical attention as described in claim 1, characterized in that, In the data embedding module of step S1, traffic embedding is generated. and time embedding The methods include: Traffic embedding generation: This involves generating historical passenger flow sequences. The input fully connected layer is mapped to traffic embedding. The calculation formula is: in, Indicates a fully connected layer. As a dimension of traffic embedding, N The total number of stations, t Here, T represents the time step, and T represents the length of the historical sequence. Time embedding generation: timestamp and holiday signs They are converted into intermediate vectors through fully connected layers, and then combined with dynamic position encoding. By concatenating the data and then adjusting the dimensions through a fully connected layer, the temporal embedding is obtained. : in, This indicates a splicing operation. For the embedding dimension of time.

3. The subway passenger flow prediction method based on adaptive chaining and hierarchical attention as described in claim 2, characterized in that, In the data embedding module of step S1, spatial embedding is generated. and spacetime prior The methods include: Spatial Embedding Generation: Based on Connectivity Graph Constructing an adjacency matrix If the two stations are directly connected, then Otherwise, it is 0; symmetry processing Calculate the Laplacian matrix. ;in, for The degree matrix; for Perform eigenvalue decomposition Take the front The eigenvectors corresponding to the smallest non-zero eigenvalues ​​are used to generate spatial embeddings through learnable linear transformations. , For the embedded dimension of space; Spatiotemporal a priori construction: combining temporal and spatial embeddings to form a spatiotemporal a priori. : .

4. The subway passenger flow prediction method based on adaptive chaining and hierarchical attention as described in claim 3, characterized in that, In the adaptive chain module of step S2, the forward chain processing method includes: Embedded with traffic As a query, spacetime prior Using key and value pairs, scaled dot product attention is computed to generate a spatiotemporal embedding of passenger flow. : in, The attention weights for querying Q in the forward chain. , These are the attention weights for the forward chain key K and value V, respectively. d k For the projection dimension.

5. The subway passenger flow prediction method based on adaptive chaining and hierarchical attention as described in claim 4, characterized in that, In the adaptive chain module of step S2, the method for processing the reverse chain includes: by As a query, traffic embedding As the key, calculate the deviation matrix. : in, The attention weights for the front backlink query Q. The attention weights for the reverse chain bond K; Introducing learnable coefficients The calibrated spatiotemporal embedding of passenger flow is generated through the residual structure. : when hour, The original traffic pattern is preserved.

6. The subway passenger flow prediction method based on adaptive chaining and hierarchical attention as described in claim 5, characterized in that, In the hierarchical attention module of step S3, the processing method in the first stage includes: Using time attention Through a two-layer fully connected network Generate weight matrix : Where E represents an unknown parameter; Output It is split into three temporal attention weight matrices , and : Site At time step and The degree of correlation is: in, For the first The hidden state of the layer express Previous time step set, index t i This indicates that the process is currently in progress. time step 、t j The first one that is being watched time step 、t r This represents all time steps allowed to participate in attention calculations; The outputs of each element are concatenated to obtain the hidden state in the time dimension: Spatial attention weights are achieved through spatial attention mechanisms. , and The generation method is the same as that of the temporal attention weight matrix; With time attention score The difference is in generating spatial attention scores. A multi-graph constraint mechanism was introduced: in, It represents the Hadamah accumulation. This is a multi-graph fusion weight matrix, where the multi-graph includes a connection graph. Static similarity graph Dynamic similarity graph Correlation plot ; Finally, the output of the k-th attention submodule is obtained by multiplying the enhanced attention score by V, and the results of the K parallel spatial attention submodules are concatenated to obtain the site. vi In time interval t Space Hidden State: The first-stage output is obtained through the feedforward network. .

7. The subway passenger flow prediction method based on adaptive chaining and hierarchical attention as described in claim 6, characterized in that, The multiple graphs include connection graphs. Static similarity graph Dynamic similarity graph Correlation plot Specifically: Connection diagram Based on the physical connections of the subway lines, if there is a direct rail connection between two stations, the edge weight is 1; otherwise, it is 0. Static similarity graph The static similarity between two stations is calculated using the Euclidean distance of historical passenger flow sequences, with edge weights as follows: ,in For the site The historical state vector; Dynamic similarity graph The similarity of passenger flow trends between stations is calculated using Dynamic Time Warping (DTW). Only the top K pairs of stations with the highest similarity are retained as virtual edges, and the edge weights are normalized DTW similarity. Correlation plot Based on passenger flow origin-destination (OD) distribution, calculate the distance from the station Station entry, station Percentage of passengers exiting the station The edge weights are normalized correlation ratios, where, Indicates from the site to station Passenger flow, Indicates from the site To any station Passenger flow.

8. The subway passenger flow prediction method based on adaptive chaining and hierarchical attention as described in claim 6, characterized in that, In the hierarchical attention module of step S3, the second-stage processing method includes: For the output of the forward chain Perform segmentation; set the sequence length. , division length Step length Then the number of divisions ;along The dimension performs feature mapping on each segment to obtain the feature map where local features dominate. ; Use the first stage output pass Generate the weights of keys and values : use Weight of generated queries : The predicted passenger flow is then calculated and output according to the standard attention mechanism.

9. A subway passenger flow prediction system based on adaptive chaining and hierarchical attention, used to implement the subway passenger flow prediction method based on adaptive chaining and hierarchical attention as described in any one of claims 1-8, characterized in that, include: The data embedding module is used to acquire historical passenger flow data to generate flow embedding, and to generate temporal embedding and spatial embedding, which are then spliced ​​together to obtain spatiotemporal priors; An adaptive chained module, including a forward chain and a feedback chain, is used to generate a spatiotemporal embedding of passenger flow and calibrate it to obtain calibrated spatiotemporal features of passenger flow. The hierarchical attention module includes a first attention stage and a second attention stage, which are used to extract global spatiotemporal representations and perform local dynamic adjustments, respectively, and finally output predicted passenger flow.

10. A computer-readable storage medium, characterized in that, The device contains a computer program that, when executed by a processor, implements the subway passenger flow prediction method based on adaptive chaining and hierarchical attention as described in any one of claims 1 to 8.