Traffic flow prediction method, device and electronic equipment
By combining nonlinear autoencoder networks and multilayer perceptrons with attention networks, the number of collaborative attention points is dynamically calculated, solving the problem of inaccurate traffic flow prediction in existing technologies and achieving higher-precision road traffic flow prediction.
Patent Information
- Application Number
- CN202511455676.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-13
- Publication Date
- 2025-12-16
- Estimated Expiration
- 2045-10-13
AI Technical Summary
In existing technologies, deep learning-based road traffic flow prediction methods struggle to fully capture the long-distance correlations and dynamic characteristics of traffic flow changes between different road segments, leading to inaccurate predictions.
By combining a nonlinear autoencoder network and a multilayer perceptron with an attention network, historical traffic flow sequences from multiple observation points are acquired. Embedding encoding and attention score matrix calculation are performed to dynamically determine the number of collaborative attention points, construct high-order collaborative information, and finally use the multilayer perceptron for prediction.
It improves the accuracy of road traffic flow prediction, and can more accurately capture the complex spatial dependencies and dynamic changes between observation points in the road network, outputting more accurate traffic flow prediction results.
Smart Images

Figure CN120932463B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of road traffic flow prediction, and in particular to a traffic flow prediction method, device and electronic equipment. BACKGROUND
[0002] Road traffic flow prediction is a key task for building intelligent transportation systems. Accurate road flow prediction not only improves the efficiency of road network operation, but also provides decision support for dynamic signal control, path planning and other intelligent transportation systems, which has important practical significance for relieving urban congestion and guiding travel.
[0003] The mainstream road traffic flow prediction method is a prediction method based on deep learning. In terms of spatial learning, these early methods rely on static predefined graphs based on road network geographic distance, which is difficult to fully capture the long-distance correlation and dynamic characteristics of traffic changes between road segments.
[0004] Therefore, the traffic flow prediction method in the related art has the technical problem of inaccurate prediction due to traffic changes between different road segments. SUMMARY
[0005] The present application provides a traffic flow prediction method, device and electronic equipment to solve the problem of inaccurate prediction of traffic changes between different road segments in the prior art, and to improve the accuracy of road traffic flow prediction.
[0006] The present application provides a traffic flow prediction method, device and electronic equipment, comprising the following steps. Obtain the historical observation sequence of traffic flow of a plurality of observation points; input the standardized historical observation sequence into a nonlinear auto-encoding network for embedding coding to obtain the traffic flow time sequence output by the nonlinear auto-encoding network; input the traffic flow time sequence corresponding to each observation point of the plurality of observation points into a first attention network to obtain the attention score matrix output by the first attention network; determine the number of collaborative attentions of the attention score matrix based on the number of the plurality of observation points; determine the collaborative information of the number of collaborative attentions of each observation point in the plurality of observation points; input the collaborative information of the number of collaborative attentions into a second attention network to obtain the high-order collaborative information output by the second attention network; based on the number of collaborative attentions and the high-order collaborative information, construct a fusion representation vector of the traffic flow time sequence; input the fusion representation vector into a prediction network based on a multi-layer perception machine to obtain a traffic flow prediction result output by the prediction network.
[0007] According to the traffic flow prediction method provided by the application, after the historical observation sequence of the traffic flow of the plurality of observation points is obtained, the method further comprises: normalizing the historical observation sequence of each observation point to obtain a normalized historical observation sequence:
[0008] ;
[0009] Among them, The normalized historical observation sequence is represented by The historical observation sequence is represented by The mean of the historical observation sequence is represented by The standard deviation of the historical observation sequence is represented by
[0010] According to the traffic flow prediction method provided by the application, the traffic flow time sequence corresponding to each observation point of the plurality of observation points is input into the first attention network to obtain the attention score matrix output by the first attention network, which comprises: determining the attention score matrix of each collaborative attention according to the following formula:
[0011] ;
[0012] ;
[0013] ;
[0014] Among them, The attention score matrix of the i-th collaborative attention is represented by The query matrix of the i-th collaborative attention is represented by The key matrix of the i-th collaborative attention is represented by The number of collaborative attentions is represented by The traffic flow time sequence is represented by The query parameter weight matrix of the i-th collaborative attention is represented by The key parameter weight matrix of the i-th collaborative attention is represented by The transposed matrix is represented by
[0015] According to the traffic flow prediction method provided by the application, the collaborative information of each collaborative attention of the plurality of observation points is determined, which comprises: based on the attention score matrix of each collaborative attention, the collaborative information of each collaborative attention is determined:
[0016] ;
[0017] ;
[0018] wherein, represents the collaborative information of the th collaborative attention, represents the attention score matrix of the th collaborative attention, represents the value matrix of the th collaborative attention, represents the traffic flow time series, represents the value parameter weight matrix of the th collaborative attention.
[0019] According to the traffic flow prediction method provided by the application, the collaborative information of the collaborative attention is input into the second attention network, and high-order collaborative information output by the second attention network is obtained, which comprises:
[0020] Based on the collaborative information of the collaborative attention, a high-order collaborative attention score matrix of the traffic flow time series is determined:
[0021] ;
[0022] ;
[0023] ;
[0024] wherein, represents the high-order collaborative attention score matrix of the th traffic flow time series, represents the query matrix of the high-order attention, represents the key matrix of the high-order attention, represents the number of collaborative attentions, represents the collaborative information of the th traffic flow time series, represents the query parameter weight matrix of the high-order attention, represents the key parameter weight matrix of the high-order attention;
[0025] Based on the high-order collaborative attention score matrix of the traffic flow time series, a high-order collaborative information of the traffic flow time series is determined:
[0026] ;
[0027] ;
[0028] wherein, represents the high-order collaborative information of the high-order collaborative information of a traffic flow time series, a high-order collaborative attention score matrix representing a traffic flow time series, a value matrix representing high-order attention, a high-order collaborative attention score matrix representing a traffic flow time series, a value parameter weight matrix representing high-order attention. a high-order collaborative attention score matrix representing a traffic flow time series, a value parameter weight matrix representing high-order attention.
[0029] According to the traffic flow prediction method provided by the application, the fusion representation vector is input into the prediction network based on the multilayer perceptron, and the traffic flow prediction result output by the prediction network is obtained, which comprises:
[0030] ;
[0031] ;
[0032] wherein, the fusion representation vector, the collaborative attention representation vector corresponding to the collaborative attention quantity, the high-order collaborative attention representation vector corresponding to the high-order collaborative information, splicing, the output traffic flow prediction result, the prediction network based on the multilayer perceptron.
[0033] The application also provides a traffic flow prediction device, comprising the following modules: an acquisition module for acquiring historical observation sequences of traffic flows of multiple observation points; an encoding module for inputting the standardized historical observation sequences into a nonlinear auto-encoding network for embedding coding to obtain traffic flow time series output by the nonlinear auto-encoding network; an attention score module for inputting traffic flow time series corresponding to the multiple observation points respectively into a first attention network to obtain an attention score matrix output by the first attention network; a determination module for determining the collaborative attention quantity of the attention score matrix based on the number of the multiple observation points; a collaborative attention module for determining collaborative information of the collaborative attention quantity of each observation point in the multiple observation points; a high-order attention module for inputting the collaborative information of the collaborative attention quantity into a second attention network to obtain high-order collaborative information output by the second attention network; a fusion module for constructing a fusion representation vector of the traffic flow time series based on the collaborative attention quantity and the high-order collaborative information; and a prediction module for inputting the fusion representation vector into a prediction network based on the multilayer perceptron to obtain a traffic flow prediction result output by the prediction network.
[0034] The application further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the traffic flow prediction method according to any one of the above when executing the computer program.
[0035] The application further provides a non-transitory computer-readable storage medium, which stores a computer program, wherein the computer program is executable on a processor to implement the traffic flow prediction method according to any one of the above.
[0036] The application further provides a computer program product, comprising a computer program, wherein the computer program is executable on a processor to implement the traffic flow prediction method according to any one of the above.
[0037] The traffic flow prediction method, device and electronic device provided by the application can obtain a traffic flow history observation sequence of multiple observation points, provide a comprehensive data basis for analysis, input the sequence into a nonlinear auto-encoding network after standardization, extract key features and reduce data dimension and complexity, input a traffic flow time sequence obtained into a first attention network, obtain an attention score matrix to capture the correlation between observation points, determine the number of collaborative attentions according to the number of observation points and find out collaborative information, focus on key collaborative relationships, obtain high-order collaborative information through a second attention network, deeply mine complex collaborative modes, construct a fusion representation vector based on the number of collaborative attentions and the high-order collaborative information, and comprehensively integrate multidimensional information, and finally input the vector into a multilayer perception prediction network to output an accurate traffic flow prediction result. BRIEF DESCRIPTION OF DRAWINGS
[0038] In order to more clearly illustrate the technical solutions of the present application or the prior art, the following will briefly introduce the drawings needed in the embodiments or prior art description one by one. Obviously, the drawings in the following description are some embodiments of the present application, and those skilled in the art can obtain other drawings according to these drawings without creative labor.
[0039] Figure 1 is the technical overall framework provided by the present application.
[0040] Figure 2 is the flowchart of the traffic flow prediction method provided by the present application.
[0041] Figure 3 is the collaborative attention calculation framework provided by the present application.
[0042] Figure 4 is the module diagram of the traffic flow prediction device provided by the present application.
[0043] Figure 5Fig. 1 is a schematic diagram of a physical structure of an electronic device provided by the present application. DETAILED DESCRIPTION
[0044] In order to make the objects, technical solutions and advantages of the present application clearer, the technical solutions in the present application will be described clearly and completely below with reference to the drawings in the present application. Obviously, the described embodiments are some but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall into the scope of protection of the present application.
[0045] The mainstream method of road traffic flow prediction is the prediction method based on deep learning. Mainly using recurrent neural network (RNN) and its variant models long short-term memory network (LSTM) and gated recurrent unit (GRU), as well as graph neural network (GNN) and Transformer architecture to build prediction model. For example, the early T-GCN (Temporal Graph Convolutional Network) model as a typical spatio-temporal model, by combining the graph convolution network (GCN) in GNN and GRU, effectively improves the accuracy of traffic flow spatio-temporal prediction. The STGCN (Spatio-Temporal Graph Convolutional Network) model combines GCN with time convolution block, and achieves higher prediction accuracy than traditional RNN. The DCRNN (Diffusion Convolutional Recurrent Neural Network) model combines diffusion process and RNN, effectively capturing the spatial and temporal dependence of spatio-temporal data. AGCRN (Adaptive Graph Convolutional Recurrent Network) proposes a node adaptive parameter learning module (Node-Adaptive Parameter Learning, NAPL) and a data adaptive graph generation module (Data-Adaptive Graph Generation, DAGG) to dynamically generate graph structures and capture the spatio-temporal correlation of traffic flow. MTGNN (Multivariate Time Series Graph Neural Network) designs corresponding graph learning modules and adaptive mechanisms, and achieves better prediction performance and generalization performance in multivariate time series prediction tasks.
[0046] In spatial learning, these early methods all used static predefined maps constructed based on road network geographical distances, which could not fully characterize the long-distance correlations and dynamic changes in traffic flow between different road segments in the road network. To address this issue, researchers proposed data-driven adaptive graph generation methods, which construct end-to-end optimized graph structures by assigning learnable parameters to sensor nodes to more flexibly learn complex spatial dependencies between nodes. However, when applied to large-scale road network traffic flow prediction, they still face challenges such as an excessive number of parameters, low computational efficiency, and insufficient modeling of spatiotemporal relationships.
[0047] In temporal relationship learning, compared to recursive architectures such as RNNs and LSTMs that rely on sequential modeling, the Transformer architecture can capture long-range dependencies without strict time recursion, making it particularly adept at global trend analysis. Furthermore, its multi-head attention mechanism can efficiently model dynamic interactions between multiple variables, significantly improving the prediction accuracy of high-dimensional traffic flow. However, the Transformer architecture also suffers from drawbacks such as high computational complexity (O(n²)) and insufficient sensitivity to local features.
[0048] refer to Figure 1 , Figure 1 This is a diagram illustrating the overall technical framework provided by the present invention.
[0049] First, the number of attention heads is calculated using a multi-head calculator (MC). N ) is transformed into the optimal number of attention heads in the model structure ( H (Received dimension is) N x T Input data S (i.e., traffic flow time series), this data is processed by multiple parallel Attention modules to generate... H This information is then fed into a higher-order collaborative attention network for integration, forming a higher-order collaborative representation vector. This vector undergoes further processing to obtain the final representation vector, which is ultimately used by the output prediction network to generate the model's prediction output. (i.e., traffic flow forecast results).
[0050] To enhance the model's ability to learn temporal relationships and improve the accuracy of road traffic flow prediction, a traffic flow prediction method based on Transformer high-order collaboration was invented, such as... Figure 1 As shown. This includes: attention count calculation, H collaborative information units, a high-order collaborative attention network (i.e., the second attention network), a high-order collaborative representation vector, a representation vector, and an output prediction network.
[0051] Optionally, the traffic flow prediction method of the embodiments of the present application can be executed by a server, or by a terminal device, or by both the server and the terminal device. Taking the traffic flow prediction method executed by the server as an example.
[0052] Figure 2 is a flowchart of the traffic flow prediction method provided by the present application, as shown in the figure, the method comprises the following steps. Figure 2
[0053] Step 201, obtaining a historical observation sequence of traffic flow of a plurality of observation points.
[0054] In the embodiments of the present application, given a historical observation sequence with T time steps and N variables (i.e. the number of observation points), the target is to predict the road traffic flow in the future L time steps (i.e. the traffic flow prediction result): , N is the number of observation points. As follows:
[0055]
[0056] wherein, M denotes the prediction method.
[0057] The flowchart of the present application and the important modules of the design are shown in Figure 1 , mainly including the following three processes: cooperative attention calculation, feature high-order cooperative learning and prediction.
[0058] According to the traffic flow prediction method provided by the present application, after obtaining the historical observation sequence of traffic flow of a plurality of observation points, the above method further comprises:
[0059] standardizing the historical observation sequence of each observation point to obtain the standardized historical observation sequence:
[0060] ;
[0061] wherein, denotes the standardized historical observation sequence, denotes the historical observation sequence, denotes the mean of the historical observation sequence, denotes the standard deviation of the historical observation sequence.
[0062] In the embodiments of the present application, the historical observation sequence of the observation point n is first standardized to obtain the historical observation sequence .The corresponding standardized matrix (i.e. the standardized historical observation sequence corresponding to the nth observation point ).
[0063] By the embodiment of the application, the historical observation sequence of each observation point is standardized, which can effectively eliminate the influence of different observation point data due to the difference in dimension and numerical range, so that the data of each observation point is in the same scale, and the data quality and comparability are improved.
[0064] In step 202, the standardized historical observation sequence is input into a nonlinear auto-encoding network for embedding coding to obtain a traffic flow time sequence output by the nonlinear auto-encoding network.
[0065] In the embodiment of the application, the standardized historical observation sequence is initially coded, as follows:
[0066] ;
[0067] wherein, denotes the output traffic flow time sequence, denotes the input standardized historical observation sequence, denotes the nonlinear auto-encoding network, and the application adopts a multilayer perceptron (MLP) with a Softplus activation function.
[0068] In step 203, the traffic flow time sequences corresponding to the multiple observation points are input into a first attention network to obtain an attention score matrix output by the first attention network.
[0069] In the embodiment of the application, the first attention network is used to calculate the attention score matrix between multiple traffic flow time sequences, and the essence is a fully connected graph neural network. The calculation process of the attention score matrix corresponding to the traffic flow time sequence is as follows.
[0070] According to the traffic flow prediction method provided by the application, the traffic flow time sequences corresponding to the multiple observation points are input into a first attention network to obtain an attention score matrix output by the first attention network, which includes:
[0071] According to the following formula, the attention score matrix of each collaborative attention is determined:
[0072] ;
[0073] ;
[0074] ;
[0075] wherein, denotes the nth An attention score matrix of collaborative attention, Indicates the first A query matrix for collaborative attention. Indicates the first A key matrix for collaborative attention, Indicates the amount of collaborative attention. Represents the time series of traffic flow. Indicates the first A query parameter weight matrix for collaborative attention. Indicates the first The key parameter weight matrix of collaborative attention, This represents the transpose of the matrix.
[0076] refer to Figure 3 , Figure 3 This is a schematic diagram of the collaborative attention computation framework provided by the present invention. It is used to process the historical observation sequence of the nth observation point through an attention mechanism. Transform into the nth observation point Collaborative information of collaborative attention .
[0077] In some embodiments, the traffic flow time series of multiple observation points (represented as...) S (This can be viewed as a matrix or tensor containing the time-series data of all observation points) is input into the first attention network.
[0078] The first attention network includes H There are two parallel, identically structured "corelative attention heads". Each corelative attention head works independently.
[0079] For the One collaborative attention: using a query parameter weight matrix For the input traffic flow time series S Perform a linear transformation (matrix multiplication) to obtain the query matrix for this head. Use another key parameter weight matrix. Similarly to S Perform a linear transformation to obtain the key matrix of the head. Use another value parameter, the weight matrix. Similarly to S Perform a linear transformation to obtain the value matrix of the head. .
[0080] The first A query matrix of collaborative attention Bond matrix performing matrix multiplication and dividing the multiplication result by a scaling factor is the total number of collaborative attentions), this step is to prevent the dot product result from being too large when the dimension is high, causing the Softmax gradient to disappear. Apply the softmax function to the scaled result to normalize it. This normalization process ensures that the calculated weights (attention scores) are non-negative and sum to 1. The final result is the attention score matrix of the collaborative attention .
[0081] Through the embodiments of the present application, the first attention network dynamically calculates a plurality of attention score matrices based on the input traffic flow time series data through a plurality of parallel, parameter-independent collaborative attentions; can adaptively and multi-angle capture the complex, dynamic and nonlinear spatial dependence relationship between observation points in the road network, overcoming the limitations of relying on static predefined graphs.
[0082] Step 204, based on the number of observation points, determine the number of collaborative attentions of the attention score matrix.
[0083] Since the number of multi-head attentions in the existing model is a hyperparameter, too few attentions result in insufficient extraction ability of the Transformer, and redundant attention networks affect the optimization efficiency of the model, resulting in reduced representation ability. Therefore, the present application calculates the appropriate number of collaborative attentions based on the dimension theorem H , the calculation method is as follows:
[0084] ;
[0085] In the formula, represents round up, N is the number of observation points.
[0086] Step 205, determine the collaborative information of the number of collaborative attentions of each observation point in the plurality of observation points.
[0087] In the embodiments of the present application, the first collaborative information calculation process is as follows.
[0088] According to the traffic flow prediction method provided by the present application, the collaborative information of the number of collaborative attentions of each observation point in the plurality of observation points is determined, including:
[0089] Based on the attention score matrix of each collaborative attention, determine the collaborative information of each collaborative attention:
[0090] ;
[0091] ;
[0092] wherein, denotes the th collaborative attention's collaborative information, denotes the th collaborative attention's attention score matrix, denotes the th collaborative attention's value matrix, denotes the traffic flow time series, denotes the th collaborative attention's value parameter weight matrix.
[0093] In the embodiments of the present application, the H th attention score matrix from the first attention network and the original traffic flow time series are received.
[0094] Figure 3 Continuing to refer to , for the th collaborative attention: using a value parameter weight matrix to linearly transform (matrix multiplication) the input traffic flow time series , the value matrix of this head is obtained.
[0095] The attention score matrix of the th collaborative attention is multiplied by the corresponding value matrix , and the result of this matrix multiplication is the collaborative information of the th collaborative attention.
[0096] H The th collaborative information matrix , ,..., is obtained. Each is a matrix, whose rows usually correspond to observation points (nodes), and whose columns correspond to feature dimensions (determined by the dimension of ). Therefore, the n th row in n represents the collaborative information provided by the neighbor nodes to the th node.
[0097] Through the embodiments of the present application, the information of related nodes is effectively fused based on the dynamically learned spatial dependency relationship, a multi-angle feature representation containing collaborative interaction state is generated for each observation point, and a rich and structured input is provided for subsequent high-order collaborative relationship modeling.
[0098] Step 206, input the collaborative information of the number of collaborative attentions to the second attention network to obtain high-order collaborative information output by the second attention network.
[0099] In the embodiment of the application, H collaborative information matrices are obtained, and according to the calculated H values, it is indicated that there are H collaborative attentions. Then, for the observation point n, H collaborative information needs to be obtained: . Wherein, represents the first collaborative information of it, d represents the feature dimension.
[0100] According to the traffic flow prediction method provided by the application, the collaborative information of the number of collaborative attentions is input to the second attention network to obtain high-order collaborative information output by the second attention network, which comprises:
[0101] Based on the collaborative information of the number of collaborative attentions, the high-order collaborative attention score matrix of the traffic flow time series is determined:
[0102] ;
[0103] ;
[0104] ;
[0105] Wherein, represents the first high-order collaborative attention score matrix of the traffic flow time series, represents the query matrix of high-order attention, represents the key matrix of high-order attention, represents the number of collaborative attentions, represents the collaborative information of the number of collaborative attentions of the first traffic flow time series, represents the query parameter weight matrix of high-order attention, represents the key parameter weight matrix of high-order attention;
[0106] Based on the high-order collaborative attention score matrix of the traffic flow time series, the high-order collaborative information of the traffic flow time series is determined:
[0107] ;
[0108] ;
[0109] Wherein, represents the first high-order collaborative information of the traffic flow time series, a high-order collaborative attention score matrix representing the a value matrix representing high-order attention, a high-order collaborative attention score matrix representing the collaborative information of the collaborative attention quantity of the a value parameter weight matrix representing high-order attention.
[0110] The collaborative information respectively represents the information gain between the observation sequences, and each gain has different effects on the time series prediction. To extract the optimal collaborative information, the application designs a high-order information extraction network, which aims to obtain the optimal combination of H collaborative information, i.e., high-order collaborative information. The high-order information extraction network is an attention network, that is, the H collaborative information obtained by the nth observation sequence is taken as H nodes, an attention matrix is calculated, and a high-order collaborative matrix is aggregated.
[0111] In the embodiment of the application, and are the learnable parameters of the second attention network (high-order information extraction network), which are shared in the entire model (applied to all observation points n).
[0112] This operation is independently performed for each observation point, and the interaction relationship between the H different collaborative information of each observation point itself is calculated. The dimension of corresponds to H H, which represents the importance of the H collaborative relationships of the nth observation point to each other (for example, the correlation degree between the a th collaborative relationship and the b th collaborative relationship).
[0113] Through the embodiment of the application, the high-order interaction and relative importance between the multiple collaborative relationship modes of the observation point n itself are dynamically and adaptively modeled. This realizes the deep refinement and fusion of the first-layer spatial collaborative information, captures more complex spatiotemporal dependence patterns (high-order collaboration), and lays a key foundation for constructing an accurate and node-specific fusion vector.
[0114] Step 207, based on the collaborative attention quantity and the high-order collaborative information, a fusion representation vector of the traffic flow time series is constructed.
[0115] The H attention heads and the high-order collaborative information are combined as the representation vector of the traffic flow time series S, and then a prediction network is constructed to obtain the output. The application adopts a multilayer perceptron as the prediction network, which has the core advantages of simple structure and high efficiency. The calculation process is as follows.
[0116] In step 208, the fusion representation vector is input into a prediction network based on a multi-layer perception machine to obtain a traffic flow prediction result output by the prediction network.
[0117] According to the traffic flow prediction method provided by the application, the fusion representation vector is input into a prediction network based on a multi-layer perception machine to obtain a traffic flow prediction result output by the prediction network, which comprises the following steps:
[0118] ;
[0119] ;
[0120] Among them, The fusion representation vector is represented by The collaborative attention representation vector corresponding to the collaborative attention quantity is represented by The high-order collaborative attention representation vector corresponding to the high-order collaborative information is represented by Splicing is represented by The output traffic flow prediction result is represented by The prediction network based on the multi-layer perception machine is represented by
[0121] Through the embodiment of the application, by acquiring a multi-observation-point traffic flow historical observation sequence, comprehensive data basis is provided for analysis; after standardization, the sequence is input into a nonlinear auto-encoding network for embedding coding, key features can be extracted and data dimension and complexity can be reduced; the obtained traffic flow time sequence is input into a first attention network, an attention score matrix can be acquired to capture the correlation between observation points; the collaborative attention quantity is determined according to the number of observation points, and collaborative information is found out, the key collaborative relationship can be focused; the high-order collaborative information is obtained through a second attention network, the complex collaborative mode can be deeply mined; the fusion representation vector is constructed based on the collaborative attention quantity and the high-order collaborative information, the multi-dimensional information can be comprehensively integrated; finally, the multi-layer perception machine prediction network is input, and the accurate traffic flow prediction result can be output.
[0122] The method of the application aims at the shortcomings of the Transformer model and its improved version: high computational complexity O(n²), insufficient sensitivity to local features, and lack of high-order collaborative information capture, etc. A solution is proposed, which first dynamically calculates the number of attention heads based on the dimension theorem to balance the model efficiency, then designs a high-order collaborative optimization network, and strengthens the representation ability of historical time sequence features through collaborative information combination strategy, and further improves the prediction accuracy. The main advantage of the application is that a high-order collaborative optimization network is designed, which fully extracts the high-order statistical correlation such as nonlinear covariance between variables, and enhances the time sequence feature mining ability of the traffic flow time sequence.
[0123] The traffic flow prediction device provided by the present application is described below, and the traffic flow prediction device described below can be correspondingly referred to the traffic flow prediction method described above.
[0124] Reference Figure 4 , Figure 4 is a schematic diagram of the modules of the traffic flow prediction device provided by the present application.
[0125] The acquisition module 401 is configured to acquire a historical observation sequence of traffic flow of a plurality of observation points.
[0126] The encoding module 402 is configured to input the standardized historical observation sequence into a nonlinear auto-encoding network for embedding coding to obtain a traffic flow time sequence output by the nonlinear auto-encoding network.
[0127] The attention score module 403 is configured to input the traffic flow time sequences corresponding to the plurality of observation points respectively into a first attention network to obtain an attention score matrix output by the first attention network.
[0128] The determination module 404 is configured to determine a number of collaborative attentions of the attention score matrix based on the number of the plurality of observation points.
[0129] The collaborative attention module 405 is configured to determine collaborative information of the number of collaborative attentions of each observation point in the plurality of observation points.
[0130] The high-order attention module 406 is configured to input the collaborative information of the number of collaborative attentions into a second attention network to obtain high-order collaborative information output by the second attention network.
[0131] The fusion module 407 is configured to construct a fusion representation vector of the traffic flow time sequence based on the number of collaborative attentions and the high-order collaborative information.
[0132] The prediction module 408 is configured to input the fusion representation vector into a prediction network based on a multilayer perceptron to obtain a traffic flow prediction result output by the prediction network.
[0133] Specifically, the traffic flow prediction device provided by the present application can realize all the method steps realized by the traffic flow prediction method embodiment, and can achieve the same technical effects. Therefore, the same parts and beneficial effects of the present embodiment as the method embodiment will not be described in detail.
[0134] Figure 5 is a schematic diagram of the physical structure of the electronic device provided by the present application, such as Figure 5As shown, the electronic device can include a processor 510, a communications interface 520, a memory 530, and a communications bus 540, wherein the processor 510, the communications interface 520, and the memory 530 complete mutual communication through the communications bus 540. The processor 510 can invoke a logic instruction in the memory 530 to execute a traffic flow prediction method, which includes: obtaining a historical observation sequence of traffic flow of a plurality of observation points; inputting the standardized historical observation sequence into a nonlinear auto-encoding network for embedding coding to obtain a traffic flow time sequence output by the nonlinear auto-encoding network; inputting the traffic flow time sequence corresponding to the plurality of observation points into a first attention network respectively to obtain an attention score matrix output by the first attention network; determining a collaborative attention quantity of the attention score matrix based on the number of the plurality of observation points; determining collaborative information of the collaborative attention quantity of each observation point in the plurality of observation points; inputting the collaborative information of the collaborative attention quantity into a second attention network to obtain high-order collaborative information output by the second attention network; constructing a fusion representation vector of the traffic flow time sequence based on the collaborative attention quantity and the high-order collaborative information; and inputting the fusion representation vector into a prediction network based on a multilayer perception machine to obtain a traffic flow prediction result output by the prediction network.
[0135] In addition, the logic instruction in the memory 530 described above can be implemented in the form of a software function unit and sold or used as an independent product, and can be stored in a computer-readable storage medium. Based on such understanding, the technical solutions of the present application essentially or the part that contributes to the prior art or part of the technical solutions can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a plurality of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in various embodiments of the present application. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various program code storage media.
[0136] In another aspect, the present application also provides a computer program product comprising a computer program, which can be stored on a non-transitory computer-readable storage medium, and the computer program can be executed by a processor to enable a computer to perform the traffic flow prediction method provided by the above method, which comprises: obtaining a historical observation sequence of traffic flow of a plurality of observation points; inputting the standardized historical observation sequence into a nonlinear auto-encoding network for embedding coding to obtain a traffic flow time sequence output by the nonlinear auto-encoding network; inputting the traffic flow time sequences corresponding to the plurality of observation points respectively into a first attention network to obtain an attention score matrix output by the first attention network; determining a collaborative attention quantity of the attention score matrix based on the number of the plurality of observation points; determining collaborative information of the collaborative attention quantity of each observation point in the plurality of observation points; inputting the collaborative information of the collaborative attention quantity into a second attention network to obtain high-order collaborative information output by the second attention network; constructing a fusion representation vector of the traffic flow time sequence based on the collaborative attention quantity and the high-order collaborative information; and inputting the fusion representation vector into a prediction network based on a multilayer perceptron to obtain a traffic flow prediction result output by the prediction network.
[0137] In another aspect, the present application also provides a non-transitory computer-readable storage medium having a computer program stored thereon, and the computer program can be executed by a processor to implement the traffic flow prediction method provided by the above method, which comprises: obtaining a historical observation sequence of traffic flow of a plurality of observation points; inputting the standardized historical observation sequence into a nonlinear auto-encoding network for embedding coding to obtain a traffic flow time sequence output by the nonlinear auto-encoding network; inputting the traffic flow time sequences corresponding to the plurality of observation points respectively into a first attention network to obtain an attention score matrix output by the first attention network; determining a collaborative attention quantity of the attention score matrix based on the number of the plurality of observation points; determining collaborative information of the collaborative attention quantity of each observation point in the plurality of observation points; inputting the collaborative information of the collaborative attention quantity into a second attention network to obtain high-order collaborative information output by the second attention network; constructing a fusion representation vector of the traffic flow time sequence based on the collaborative attention quantity and the high-order collaborative information; and inputting the fusion representation vector into a prediction network based on a multilayer perceptron to obtain a traffic flow prediction result output by the prediction network.
[0138] The device embodiments described above are only schematic, wherein the units illustrated as separate components can or can not be physically separate, and the components illustrated as units can or can not be physical units, i.e., can be located in one place or distributed on a plurality of network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the present embodiment scheme. Those skilled in the art can understand and implement it without creative labor.
[0139] Those skilled in the art can clearly understand the implementation of the various embodiments by means of software and necessary general hardware platforms through the above description of the embodiments, and of course, the embodiments can also be implemented by hardware. Based on such understanding, the above technical solutions, essentially or in other words, the part of the prior art that makes a contribution, can be embodied in the form of a software product, which can be stored in a computer readable storage medium, such as a ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute the methods described in the various embodiments or some parts of the embodiments.
[0140] Finally, it should be noted that: the above examples are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing examples, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing examples, or make equivalent replacement for some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the various embodiments of the present application.
Claims
1. A traffic flow prediction method, characterized in that, include: Obtain historical observation sequences of traffic flow from multiple observation points; The standardized historical observation sequence is input into a nonlinear autoencoder network for embedding encoding to obtain the traffic flow time series output by the nonlinear autoencoder network; The traffic flow time series corresponding to the multiple observation points are input into the first attention network to obtain the attention score matrix output by the first attention network. Based on the number of the multiple observation points, determine the number of collaborative attention points in the attention score matrix; Determine the collaborative information for the number of collaborative attention points for each of the multiple observation points; The collaborative information of the number of collaborative attentions is input into the second attention network to obtain the high-order collaborative information output by the second attention network. Based on the number of collaborative attention points and the higher-order collaborative information, a fusion representation vector of the traffic flow time series is constructed; The fused representation vector is input into a prediction network based on a multilayer perceptron to obtain the traffic flow prediction result output by the prediction network.
2. The traffic flow prediction method according to claim 1, characterized in that, After acquiring historical observation sequences of traffic flow from multiple observation points, the method further includes: The historical observation sequence for each observation point is standardized to obtain the standardized historical observation sequence: ; in, This represents the standardized historical observation sequence. This represents the historical observation sequence. This represents the mean of the historical observation sequence. The standard deviation of the historical observation sequence is represented.
3. The traffic flow prediction method according to claim 1, characterized in that, The step of inputting the traffic flow time series corresponding to the multiple observation points into the first attention network to obtain the attention score matrix output by the first attention network includes: The attention score matrix for each collaborative attention is determined using the following formula: ; ; ; in, Indicates the first An attention score matrix of collaborative attention, Indicates the first A query matrix for collaborative attention. Indicates the first A key matrix for collaborative attention, Indicates the amount of collaborative attention. This represents the traffic flow time series. Indicates the first A query parameter weight matrix for collaborative attention. Indicates the first The key parameter weight matrix of collaborative attention, This represents the transpose of the matrix.
4. The traffic flow prediction method according to claim 3, characterized in that, The collaborative information for determining the number of collaborative attention points for each of the plurality of observation points includes: Based on the attention score matrix for each collaborative attention, the collaborative information for each collaborative attention is determined: ; ; in, Indicates the first Collaborative information for collaborative attention. Indicates the first An attention score matrix of collaborative attention, Indicates the first A matrix of values for collaborative attention. This represents the traffic flow time series. Indicates the first The values of the collaborative attention parameters are a weight matrix.
5. The traffic flow prediction method according to claim 1, characterized in that, The step of inputting the collaborative information of the number of collaborative attentions into the second attention network to obtain the high-order collaborative information output by the second attention network includes: Based on the collaborative information regarding the number of collaborative attention points, a higher-order collaborative attention score matrix for the traffic flow time series is determined: ; ; ; in, Indicates the first A high-order collaborative attention score matrix for traffic flow time series. The query matrix representing higher-order attention. The key matrix representing higher-order attention. Indicates the amount of collaborative attention. Indicates the first Collaborative information on the number of collaborative attention items in a traffic flow time series. The query parameter weight matrix represents higher-order attention. The key parameter weight matrix representing higher-order attention; Based on the higher-order collaborative attention score matrix of the traffic flow time series, the higher-order collaborative information of the traffic flow time series is determined: ; ; in, Indicates the first High-order collaborative information of traffic flow time series Indicates the first A high-order collaborative attention score matrix for traffic flow time series. The value matrix representing higher-order attention. Indicates the first Collaborative information on the number of collaborative attention items in a traffic flow time series. The weight matrix represents the value parameters of higher-order attention.
6. The traffic flow prediction method according to claim 1, characterized in that, The step of inputting the fused representation vector into a multilayer perceptron-based prediction network to obtain the traffic flow prediction result output by the prediction network includes: ; ; in, This represents the fused representation vector. This represents the collaborative attention representation vector corresponding to the number of collaborative attention points. This represents the high-order collaborative attention representation vector corresponding to the higher-order collaborative information. Indicates splicing, This indicates the output traffic flow prediction results. This represents a prediction network based on a multilayer perceptron.
7. A traffic flow prediction device, characterized in that, include: The acquisition module is used to acquire historical observation sequences of traffic flow from multiple observation points; The encoding module is used to input the standardized historical observation sequence into the nonlinear autoencoder network for embedding encoding, so as to obtain the traffic flow time series output by the nonlinear autoencoder network; The attention score module is used to input the traffic flow time series corresponding to the multiple observation points into the first attention network to obtain the attention score matrix output by the first attention network. A determination module is used to determine the number of collaborative attentions in the attention score matrix based on the number of the multiple observation points; A collaborative attention module is used to determine collaborative information for the number of collaborative attention points for each of the multiple observation points. The higher-order attention module is used to input the collaborative information of the number of collaborative attentions into the second attention network to obtain the higher-order collaborative information output by the second attention network; The fusion module is used to construct a fusion representation vector of the traffic flow time series based on the number of collaborative attentions and the higher-order collaborative information. The prediction module is used to input the fused representation vector into a prediction network based on a multilayer perceptron to obtain the traffic flow prediction result output by the prediction network.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the traffic flow prediction method as described in any one of claims 1 to 6.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the traffic flow prediction method as described in any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the traffic flow prediction method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Traffic flow prediction method based on attention mechanism
CN114822027A
Traffic flow prediction method and device based on space-time attention network, and readable medium
CN117079452A