Traffic Flow Prediction Method and Device Based on Dynamic Contrast Learning and Multi-Scale 3D Convolution
Through the method of dynamic comparison learning and multi-scale 3D convolution, the shortcomings of the existing traffic flow prediction model in capturing nonlinear spatiotemporal dependence and dynamic change characteristics are solved, and accurate modeling and rapid response to traffic flow are achieved, and prediction performance and adaptability are improved.
Patent Information
- Application Number
- CN202510742205.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-05
- Publication Date
- 2025-08-05
- Estimated Expiration
- 2045-06-05
AI Technical Summary
Existing traffic flow prediction models are difficult to effectively capture the synergy between nonlinear space-time dependence, dynamic emergencies and environmental factors, and are limited in efficiency when processing large-scale data, which cannot meet real-time prediction requirements.
The method of dynamic contrast learning and multi-scale 3D convolution is adopted, and the global and local spatiotemporal characteristics of traffic flow data are extracted through the multi-scale 3D convolution module, and the positive and negative sample generation strategy is adjusted in combination with dynamic contrast learning, and a dynamic temperature coefficient and gated attention mechanism are introduced to fusion of features to achieve accurate modeling and rapid response to traffic flow.
It significantly improves the prediction performance for unexpected traffic events and complex environmental conditions, can quickly respond to violent fluctuations in traffic flow, meet real-time prediction needs, and enhances the adaptability and robustness of the model.
Smart Images

Figure CN120260295B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of urban traffic flow prediction, and specifically relates to a traffic flow prediction method and device based on dynamic contrastive learning and multi-scale 3D convolution. Background Art
[0002] With the continuous advancement of urbanization and smart city construction, modern traffic management is undergoing a transition from traditional regulation to intelligent predictive decision-making. Real-time traffic data is collected on a large scale through sensors, cameras, and other data collection devices throughout the city, providing a rich information resource for traffic flow forecasting. Accurate traffic flow forecasts can provide timely control and optimization for traffic management departments, such as signal configuration and road scheduling. They can also assist autonomous vehicles in selecting optimal routes, reduce accident risks and environmental pollution, and support logistics distribution and public transportation planning. Currently, traditional time series analysis and machine learning methods, such as ARIMA, SVM, and random forests, can achieve some results in some scenarios. However, they often rely on pre-defined linear relationships and fixed spatiotemporal dependency structures, making it difficult to capture the nonlinear and dynamic characteristics of traffic flow. Furthermore, these methods are limited in their efficiency when processing large amounts of data, making them difficult to meet the requirements of real-time forecasting.
[0003] In recent years, the application of deep learning technology has become a growing trend. Convolutional neural networks (CNNs), recurrent neural networks (RNNs), and their variants (such as LSTMs and GRUs) have made significant progress in modeling the spatiotemporal dependencies of traffic data. For example, the spatiotemporal graph convolutional network (STGCN) combines graph convolution with convolution operations to effectively extract the topological structure and dynamic characteristics of traffic networks. For example, Chinese patent document CN115482666A discloses a multi-graph convolutional neural network traffic prediction method based on data fusion. This method uses 3D convolution to construct a 3DRepVGG component to extract the spatiotemporal features of Euclidean traffic flow data and uses them as the features of each node in the traffic topology graph. A periodic gated logic unit is designed to process non-Euclidean traffic flow data, improving the model's ability to extract temporal features. Clustering algorithms are used to identify and quantify regional traffic conditions, enhancing model generalization and reducing the number of parameters. Multiple traffic topology graphs are constructed based on regional traffic conditions, non-Euclidean traffic flow data, and node feature data, strengthening the model's ability to extract long-range spatial features and further improving prediction accuracy.
[0004] Chinese patent document CN115601960A discloses a multimodal traffic flow prediction method and system based on graph comparative learning, which establishes local and global traffic heterogeneous graphs based on historical traffic flow data; encodes the global and local traffic heterogeneous graphs to obtain corresponding heterogeneous graph traffic features; calculates the mutual information of the traffic features of the local traffic heterogeneous graph to optimize the traffic features of the local traffic heterogeneous graph; performs graph comparative learning on the traffic features of the global traffic heterogeneous graph, which are fused into a global traffic feature through an attention mechanism, to optimize the traffic features of the global traffic heterogeneous graph; and inputs the optimized local and global traffic heterogeneous graph traffic features into a spatial graph convolutional neural network to predict multimodal traffic flow respectively.
[0005] However, deep learning methods currently used in traffic flow prediction models face two limitations. First, not all deep learning models are convolution-based. While some models employ fixed-scale convolutional kernels to extract spatiotemporal features, this is only representative of the design approach of convolutional neural networks. Other models, such as those based on recurrent neural networks or self-attention mechanisms, face similar challenges in extracting spatiotemporal features, namely, difficulty adaptively balancing the capture of global trends and local details. Second, traditional contrastive learning methods typically rely on pre-set fixed time windows to generate samples. This means that during data sampling, positive and negative samples are drawn from a fixed time period. This fixed strategy cannot flexibly adapt to drastic changes in real-time traffic conditions, potentially failing to capture sudden traffic incidents or subtle traffic fluctuations. Third, the interaction between environmental and traffic flow features is often handled through simple concatenation, failing to fully capture their dynamic synergy in different contexts.
[0006] Based on this, the present invention proposes a traffic flow prediction method based on dynamic contrastive learning and multi-scale 3D convolution to solve the problems existing in the above-mentioned prior art. Summary of the Invention
[0007] The present invention aims to overcome at least one of the above-mentioned defects of the prior art and provide a traffic flow prediction method and device based on dynamic contrastive learning and multi-scale 3D convolution. The core idea is to achieve accurate modeling and rapid response to traffic flow changes through an end-to-end processing flow, from raw data collection to final prediction output; this method aims to address the shortcomings of traditional prediction methods in capturing nonlinear spatiotemporal dependencies, dynamic emergency response, and collaborative modeling of environmental factors.
[0008] The detailed technical solutions of the present invention are as follows:
[0009] A traffic flow prediction method based on dynamic contrastive learning and multi-scale 3D convolution, the method comprising:
[0010] S1. Obtain traffic trajectory data and environmental data and perform preprocessing operations on them respectively to obtain a traffic feature matrix and an environmental feature vector, map the environmental feature vector to the spatial dimension of the traffic grid to obtain an environmental feature matrix, and concatenate the traffic feature matrix and the environmental feature matrix to obtain a target spatiotemporal matrix as a model input;
[0011] S2. Constructing a traffic flow prediction model including a multi-scale 3D convolution module, a dynamic contrastive learning module, an environmental feature gated fusion module, and a spatiotemporal deconvolution prediction module, taking the target spatiotemporal matrix as input data, and constructing a joint loss function based on dynamic contrastive learning loss, gated fusion loss, and prediction loss to optimize the traffic flow prediction model;
[0012] Among them, the multi-scale 3D convolution module is used to extract the feature information of different scales of the traffic feature matrix in the target spatiotemporal matrix and fuse them to generate traffic fusion features; the dynamic contrast learning module is used to calculate the flow difference between two consecutive time steps in the traffic fusion features to obtain the real-time flow change rate, set the positive and negative sample generation strategy based on the real-time flow change rate, and obtain positive and negative sample pairs based on the strategy, use the positive and negative sample pairs as training data, introduce the dynamic temperature coefficient, and construct the dynamic contrast loss to optimize the traffic flow prediction model; the environmental feature gating fusion module is used to The environmental feature matrix in the target spatiotemporal matrix is subjected to a nonlinear transformation to obtain a high-dimensional embedding representation of the environment. Based on the traffic fusion feature and the high-dimensional embedding representation of the environment, a dynamic gating weight is calculated, and the target high-dimensional fusion feature is calculated using the dynamic gating weight. A gated fusion loss is constructed based on the traffic fusion feature and the target high-dimensional fusion feature for training the traffic flow prediction model; the spatiotemporal deconvolution prediction module is used to perform an upsampling operation on the target high-dimensional fusion feature to generate a prediction map of future traffic flow; and a prediction loss is constructed based on the prediction result to optimize the traffic flow prediction model.
[0013] According to a preferred embodiment of the present invention, in S1, the traffic trajectory data is pre-processed, specifically including:
[0014] The traffic trajectory data is cleaned and spatial discretized to obtain the traffic flow value of each grid in all time windows, and a corresponding single-frame two-dimensional traffic map is generated. ; Stack the single-frame two-dimensional flow maps generated by each grid in all time windows in chronological order to form a trajectory space-time matrix ;
[0015] The trajectory spatiotemporal matrix is dynamically filled by combining historical time series and adjacent spatial information through spatiotemporal weighted interpolation. The missing values in , the specific formula is:
[0016] (2);
[0017] In formula (2): Represents the time step And the grid position is Traffic flow value; Indicates the time step, ranging from 1 to ; Represents the time step And the grid position is Traffic flow value; Indicates the location of the adjacent grid; Represents the time step and adjacent to the grid position Traffic flow value; is the weight coefficient of the time dimension; is the weight coefficient of the spatial dimension; M(i,j) represents the neighborhood of the current grid (i,j), including the local neighborhood range formed by its upper, lower, left, right, and diagonal adjacent grids;
[0018] The interpolated trajectory space-time matrix Perform max-min normalization independently for each grid in :
[0019] (3);
[0020] In formula (3): Indicates grid position The normalized traffic flow value has a value range of [0, 1]; Indicates grid position The original traffic flow value of 、 Grid positions The maximum and minimum values of .
[0021] Preferably, in S1, the environmental data includes weather type, holiday identifier, and temperature data, and the preprocessing operation on the environmental data specifically includes:
[0022] The environmental data is cleaned and missing values are filled in the cleaned environmental data, including: interpolating the currently missing weather type according to the weather type of the adjacent time period; and using linear interpolation to fill the missing temperature data. The formula is: ,in, Represents the time step The original temperature value; Represents the time step The original temperature value; Represents the time step The original temperature value;
[0023] The filled environmental data is encoded, including: encoding the weather type using one-hot encoding to generate a dimension of The holiday identifier is encoded using binary coding to generate a vector of dimension The temperature data is converted into a scalar value by Z-score standardization, and its dimension is =1, that is:
[0024] (4);
[0025] In formula (4): Represents the normalized temperature value, which is usually in the range of [-1, 1] or [0, 1], depending on the original temperature value distribution of represents the mean of the temperature data in the training set; represents the standard deviation of the temperature data in the training set;
[0026] Combine the weather type, holiday identifier, and temperature data to form an environmental feature vector. .
[0027] Preferably, in S1, the weather type and holiday identifier vectors encoded in the environmental feature vector are used as global features, and feature mapping operations are performed to generate a global feature matrix, the formula of which is:
[0028] (5);
[0029] In formula (5): Represents the time step And the grid position is The global eigenvector of ; Represents the time step The global eigenvector of ;
[0030] The standardized temperature value is used as the spatial distribution feature and the feature mapping operation is performed to generate the spatial distribution feature matrix:
[0031] (6);
[0032] In formula (6): Represents the time step And the grid position is The spatial distribution characteristic vector of Indicates the sensors at time step Observed values of Indicates the number of sensors; Indicates grid position To Euclidean distance between sensors; is a smoothing constant, such as =1e−6, used to prevent the denominator from being zero;
[0033] The generated global feature matrix and spatial distribution feature matrix are spliced together to form a complete environmental feature matrix :
[0034] (7);
[0035] The traffic feature matrix and the environment feature matrix are embedded and spliced to obtain the target spatiotemporal matrix :
[0036] (8).
[0037] According to the preferred embodiment of the present invention, in S2, the multi-scale 3D convolution module includes parallel coarse-grained branches, medium-grained branches and fine-grained branches; wherein the convolution kernel of the coarse-grained branch is , and with step length , whose expression is:
[0038] (9);
[0039] The convolution kernel of the medium-granularity branch , and the step size is set to 1, its expression is:
[0040] (10);
[0041] The fine-grained branch uses a 1×1×1 convolution kernel, which is expressed as:
[0042] (11);
[0043] In the above formula: Represents the output feature tensor after coarse-grained branch processing; Represents the output feature tensor after medium-granularity branch processing; Represents the output feature tensor after fine-grained branch processing;
[0044] The feature tensors generated by each branch in the multi-scale 3D convolution module are fused to form a fused feature tensor ; And use the channel attention mechanism to integrate the feature tensors generated by each branch in the multi-scale 3D convolution module:
[0045] (12);
[0046] In formula (12): Represents any branch of coarse, medium or fine; Represents the weight of each branch in the multi-scale 3D convolution module; is a learnable parameter; Indicates the Feature graph of each branch Perform global average pooling operation to obtain channel descriptors;
[0047] Based on the above, the traffic fusion characteristics are finally obtained for:
[0048] (13).
[0049] According to a preferred embodiment of the present invention, in S2, the calculation formula of the real-time flow rate change rate is:
[0050] (14);
[0051] In formula (14): Indicates the real-time traffic change rate; Represents the time step The fused feature tensor of Represents the time step The fused feature tensor of
[0052] The positive and negative sample generation strategy is set based on the real-time traffic change rate, including: if the real-time traffic change rate If it is higher than the set threshold, then the positive sample Select the current time step and its adjacent time steps and The fused feature tensor ; Negative samples Then sample from the area at least L grid units away from the current grid position; if the real-time flow change rate If the value is lower than the set threshold, the historical data of the same period will be used as the positive sample. , and sample negative samples in the same area ;
[0053] Project the traffic fusion features into a low-dimensional embedding space through linear mapping , and measure the similarity between positive and negative sample pairs by cosine similarity:
[0054] (15);
[0055] The improved InfoNCE loss function is used to perform comparative training on positive and negative sample pairs, and its formula is:
[0056] (16);
[0057] In formula (16): represents the InfoNCE loss function; Represents the similarity between positive sample pairs; Represents the positive sample and the The similarity between negative samples; Indicates the number of negative samples; is a dynamic temperature coefficient used to adjust the similarity distribution between positive and negative samples; and the dynamic temperature coefficient for:
[0058] (17);
[0059] In formula (17): 、 All are adjustment coefficients; is an exponential function.
[0060] According to the preferred embodiment of the present invention, in S2, the target spatiotemporal matrix The environmental feature matrix E in the nonlinear transformation is performed to obtain the high-dimensional embedding representation of the environment for:
[0061] (18);
[0062] In formula (18): represents the environmental feature matrix; represents a fully connected layer; Representing a high-dimensional embedding representation of the environment;
[0063] The attention weights between traffic features and environmental features are calculated through a multi-head attention mechanism, including: integrating traffic features Convert to query Q and embed the environment into a high-dimensional representation Mapping as Key The sum value V is:
[0064] (19);
[0065] In formula (19): Represents the query vector, which is composed of traffic fusion features By querying the fully connected layer Calculated; represents the key vector, represented by the high-dimensional embedding of the environment Through the key fully connected layer Calculated; Represents a value vector, represented by a high-dimensional embedding of the environment Through the value of the fully connected layer Calculated; then:
[0066] (20);
[0067] In formula (20): represents the dimension of the key vector; Represents the key vector matrix Perform transpose operation;
[0068] Calculating dynamic gating weights :
[0069] (twenty one);
[0070] In formula (21): Represents the Sigmoid activation function; represents a gated fully connected layer;
[0071] Through gated weight adaptive fusion, the target high-dimensional fusion features are obtained :
[0072] (twenty two);
[0073] Constructing the loss of the environment feature gated fusion module :
[0074] (twenty three);
[0075] In formula (23): represents the gated fusion loss; Indicates the Traffic integration characteristics of samples; Indicates the The target high-dimensional fusion features of samples; Indicates the number of samples in the batch.
[0076] According to the preferred embodiment of the present invention, in S2, the target high-dimensional fusion feature Perform upsampling operations to generate a forecast map of future traffic flow, including:
[0077] The target high-dimensional fusion feature Perform the first layer of 3D deconvolution operation, the expression is:
[0078] (twenty four);
[0079] Then the second layer of 3D deconvolution operation is performed, and its expression is:
[0080] (25);
[0081] The prediction output is then used to generate a forecast map of future traffic flow:
[0082] (26);
[0083] In formula (26): A forecast graph showing future traffic flow, The number of time steps to predict for the future;
[0084] Finally, the prediction loss is constructed based on the obtained prediction results :
[0085] (27);
[0086] In formula (27): represents the true traffic matrix of the i-th sample; Represents the prediction result of the i-th sample; is the total number of samples in the training set.
[0087] According to the preferred embodiment of the present invention, in S2, the joint loss function is constructed as follows:
[0088] (28);
[0089] In formula (28): α, ξ and η are used to balance the prediction loss , Dynamic Contrastive Learning Loss and gated fusion loss The preset weight coefficient of .
[0090] In another aspect of the present invention, a device for implementing a traffic flow prediction method based on dynamic contrastive learning and multi-scale 3D convolution is provided, the device comprising:
[0091] A data acquisition module is used to acquire traffic trajectory data and environmental data and perform preprocessing operations on them to obtain a traffic feature matrix and an environmental feature vector, map the environmental feature vector to the spatial dimension of the traffic grid to obtain an environmental feature matrix, and concatenate the traffic feature matrix and the environmental feature matrix to obtain a target spatiotemporal matrix as a model input;
[0092] a model construction module for constructing a traffic flow prediction model comprising a multi-scale 3D convolution module, a dynamic contrastive learning module, an environmental feature gated fusion module, and a spatiotemporal deconvolution prediction module, taking the target spatiotemporal matrix as input data and constructing a joint loss function based on the dynamic contrastive learning loss, the gated fusion loss, and the prediction loss to optimize the traffic flow prediction model;
[0093] The multi-scale 3D convolution module is used to extract and fuse feature information of different scales of the traffic feature matrix in the target spatiotemporal matrix to generate traffic fusion features;
[0094] The dynamic contrastive learning module is used to calculate the flow difference between two consecutive time steps in the traffic fusion feature to obtain a real-time flow change rate, set a positive and negative sample generation strategy based on the real-time flow change rate, obtain positive and negative sample pairs based on the strategy, use the positive and negative sample pairs as training data, introduce a dynamic temperature coefficient, and construct a dynamic contrast loss for optimizing the traffic flow prediction model;
[0095] The environmental feature gating fusion module is used to perform a nonlinear transformation on the environmental feature matrix in the target spatiotemporal matrix to obtain a high-dimensional embedding representation of the environment, calculate dynamic gating weights based on the traffic fusion features and the high-dimensional embedding representation of the environment, and use the dynamic gating weights to calculate the target high-dimensional fusion features, and construct a gated fusion loss based on the traffic fusion features and the target high-dimensional fusion features for training the traffic flow prediction model;
[0096] The spatiotemporal deconvolution prediction module is used to perform an upsampling operation on the target high-dimensional fusion feature to generate a prediction map of future traffic flow; and to construct a prediction loss based on the prediction result to optimize the traffic flow prediction model.
[0097] Compared with the prior art, the present invention has the following beneficial effects:
[0098] (1) This paper achieves significant performance improvement in the field of traffic flow prediction by deeply integrating dynamic contrastive learning with multi-scale 3D convolution technology, especially in handling sudden traffic events and complex environmental conditions.
[0099] (2) The present invention adopts multi-scale 3D convolution to synchronously extract the global and local spatiotemporal features of traffic flow data through coarse, medium and fine scale convolution kernels, which effectively solves the shortcomings of existing methods in capturing the nonlinear and dynamic characteristics of traffic flow and provides a comprehensive and detailed description of traffic status.
[0100] (3) The present invention combines dynamic contrastive learning to automatically adjust the selection strategy of positive and negative samples according to the real-time traffic change rate, and introduces a dynamic temperature coefficient to adaptively smooth the similarity distribution in the feature space, making the model more sensitive to sudden traffic events, thereby significantly improving the ability to respond to sudden events.
[0101] (4) The present invention uses the gated attention mechanism to dynamically fuse the embedded environmental features with the traffic flow features, fully reflecting the dynamic synergy between environmental factors and traffic flow characteristics in different situations, and enhancing the adaptability and robustness of the model to changes in external conditions.
[0102] (5) In terms of real-time performance, the present invention achieves real-time response to drastic fluctuations in traffic flow through spatiotemporal deconvolution prediction combined with sliding window and dynamic step adjustment strategies. The sliding window strategy can dynamically adjust the prediction step according to the flow change rate and shorten the step when the flow fluctuates drastically, ensuring that the model can quickly respond to dynamic changes in traffic and meet the requirements of real-time prediction, providing broad application prospects in the fields of intelligent traffic management, autonomous driving assistance, logistics distribution optimization, etc. BRIEF DESCRIPTION OF THE DRAWINGS
[0103] Figure 1 This is a flow chart of the traffic flow prediction method based on dynamic contrastive learning and multi-scale 3D convolution described in the present invention.
[0104] Figure 2 This is a flow chart of the preprocessing of traffic trajectory data and environmental data in Example 1 of the present invention.
[0105] Figure 3 4 is a flow chart of constructing a trajectory space-time matrix in Example 1 of the present invention.
[0106] Figure 4 4 is a network structure diagram of the traffic flow prediction model constructed in Example 1 of the present invention.
[0107] Figure 5 This is a schematic diagram of the process of feature extraction and fusion through multi-scale 3D convolution in Example 1 of the present invention.
[0108] Figure 6 1 is a flow chart of a model training process through dynamic contrast learning in Example 1 of the present invention.
[0109] Figure 7 It is a flowchart of fusing traffic features and environmental features through environmental feature gating in Example 1 of the present invention.
[0110] Figure 8 It is a flowchart of deconvolution prediction based on target high-dimensional fusion features in Example 1 of the present invention. DETAILED DESCRIPTION
[0111] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0112] It should be noted that the following detailed descriptions are exemplary and are intended to provide further illustrations of the present invention. Unless otherwise indicated, all technical and scientific terms used herein have the same meanings as those generally understood by those of ordinary skill in the art to which the present invention pertains. It should be noted that the terms used herein are intended only to describe specific embodiments and are not intended to limit exemplary embodiments according to the present invention. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components and / or combinations thereof.
[0113] In the absence of conflict, the embodiments of the present disclosure and the features thereof may be combined with each other.
[0114] In response to the shortcomings of the existing technology, the present invention provides a traffic flow prediction method based on dynamic contrastive learning and multi-scale 3D convolution. The method first uses a multi-scale 3D convolution module to synchronously extract the global and local spatiotemporal features of traffic flow data using coarse-grained, medium-scale and fine-grained convolution kernels, thereby achieving a comprehensive characterization of the traffic status. Subsequently, a dynamic contrastive learning module is used to automatically adjust the selection strategy of positive and negative samples according to the flow change rate, and a dynamic temperature coefficient is introduced to adaptively smooth the similarity distribution in the feature space, making the model more sensitive to sudden traffic events. Finally, the present invention uses a gated attention mechanism to deeply and dynamically fuse the embedded environmental features with the traffic flow features, achieving adaptive synergy between the two, thereby improving the overall prediction accuracy and real-time performance.
[0115] The traffic flow prediction method and device based on dynamic contrastive learning and multi-scale 3D convolution of the present invention are further described below in conjunction with specific embodiments.
[0116] Example 1
[0117] This embodiment provides a traffic flow prediction method based on dynamic contrastive learning and multi-scale 3D convolution, the purpose of which is to achieve accurate modeling and rapid response to traffic flow changes. Figure 1 , the method comprising:
[0118] S1. Obtain traffic trajectory data and environmental data and perform preprocessing operations on them to obtain traffic feature matrix and the environmental feature vector , the environmental feature vector Mapped to the spatial dimension of the traffic grid, the environmental feature matrix is obtained , the traffic feature matrix and environmental characteristics matrix Splicing is performed to obtain the target spatiotemporal matrix as the model input .
[0119] In this embodiment, input data primarily consists of two categories: traffic trajectory data and environmental data. Traffic trajectory data records vehicle GPS information. This data reflects each vehicle's geographic location and speed at a specific moment, serving as an important basis for subsequent traffic flow modeling. In addition to traffic trajectory data, external environmental data closely related to traffic conditions is also collected. This includes weather type, such as sunny, rainy, and snowy; holiday identifiers (0 for non-holidays and 1 for holidays); and temperature data (in degrees Celsius). This environmental data serves as auxiliary input in subsequent models, helping to account for traffic flow fluctuations caused by weather changes or special dates.
[0120] After obtaining the above traffic trajectory data and environmental data, first pre-process them. Figure 2 Specifically, in this embodiment, the acquired traffic trajectory data and environmental data are first pre-processed by data cleaning. Data cleaning is a key step in ensuring the quality of model input data. Data cleaning for traffic trajectory data and environmental data primarily includes three steps: deduplication, data format correction, and noise elimination: 1) Deduplication: Vehicle GPS records are checked and duplicates are removed based on timestamps and geographic coordinates. If multiple GPS records for a vehicle are found with the same timestamp, only one is retained. Environmental data records are checked and duplicates are removed based on the observation time. For example, if weather data has duplicate records with the same timestamp, only one is retained. 2) Data Format Correction: The timestamp format is standardized to ensure consistent time representation across all traffic trajectory data. The latitude and longitude data are formatted and corrected, eliminating outliers that clearly do not conform to geographic coordinates. The time representation of the environmental data is ensured to be consistent with the trajectory data. Data such as weather type and temperature are formatted to ensure data accuracy. 3) Noise Elimination: For traffic trajectory data, outliers are eliminated based on the rationality of vehicle speed. For example, if a record shows a vehicle speed exceeding twice the speed limit for that road section, it is considered noise data and removed. For environmental data, obviously incorrect weather condition records are removed, and abnormal fluctuations in temperature data are checked and corrected.
[0121] In addition, the construction of the trajectory space-time matrix is the core foundation for the efficient operation of the model. The preprocessing of traffic trajectory data also includes converting the original traffic trajectory data into a three-dimensional tensor that adapts to the 3D convolution input of the model through rigorous mathematical modeling and space-time alignment strategy. Figure 3 , the process mainly includes two steps: spatial discretization and time serialization:
[0122] 1) Perform spatial discretization on the traffic trajectory data, i.e., mapping from GPS coordinates to regular grids, so as to obtain the spatial distribution of each grid in all time windows. Traffic flow value within.
[0123] Raw traffic trajectory data (such as taxi GPS points and shared bike ride records) contains latitude and longitude, timestamps, and speed information. To achieve spatial discretization, the city area is first divided into a regular H×W grid, such as 500m×500m. The longitude and latitude coordinates of the trajectory points are converted to plane coordinates using the Mercator projection. The formula is as follows:
[0124] (1);
[0125] In formula (1): Indicates the longitude value; Indicates the latitude value; Indicates the plane coordinate value after transformation.
[0126] This projection ensures that the geographic coordinates of the trajectory points are evenly distributed on the plane and avoids deformation errors in high-latitude areas.
[0127] The traffic flow value of each grid is calculated by counting the fixed time window The number of trajectory points that fall into the grid within 5 minutes (e.g., 5 minutes) is determined, and a single-frame two-dimensional flow map is generated. For example, the traffic flow of a grid during the morning rush hour may reach 300 vehicles per 5 minutes, while it drops to less than 50 vehicles at night. This step not only converts the unstructured traffic trajectory data into a structured matrix but also provides a spatial alignment basis for the subsequent multi-scale 3D convolution to extract local and global features.
[0128] 2) For each grid in all time windows The traffic flow values in the time series operation are performed.
[0129] In order to capture the temporal evolution of traffic flow, it is necessary to divide the continuous time into equal time windows (such as 5 minutes) and stack the single-frame two-dimensional flow maps generated by each grid in all time windows in chronological order. , forming a three-dimensional space-time tensor, that is, the trajectory space-time matrix , The time dimension represents the time dimension. For example, to predict traffic flow over the next 12 hours, the input 3D space-time tensor has a time dimension of T = 144 = 12 hours × 12 frames / hour. This 3D structure directly adapts to the input requirements of 3D convolution: in the time dimension, the convolution kernel slides along the time axis to capture the periodicity (such as morning and evening rush hours) and sudden changes (such as traffic accidents) in traffic flow; in the spatial dimension, the convolution kernel extracts local spatial patterns (such as the spread of congestion at intersections) and global trends (such as the migration of traffic between regions) on an H × W grid.
[0130] Based on the constructed three-dimensional spatiotemporal tensor, this embodiment employs a key adaptation scheme to further improve feature extraction from it: Within the multi-scale 3D convolution branch, the coarse-grained branch uses a 5×5×5 convolution kernel with a large step size, effectively capturing long-term cross-regional trends while downsampling. The medium-grained branch uses a 3×3×3 convolution kernel to maintain high spatiotemporal resolution, enabling it to extract dynamic changes within the local area while also bridging global and local features. The fine-grained branch uses a 1×1×1 convolution kernel to maintain the original resolution, focusing on capturing instantaneous fluctuations in local traffic flow caused by factors such as traffic light switching. This multi-scale adaptation allows the model to comprehensively extract and integrate traffic flow change information across both temporal and spatial dimensions, providing a solid feature foundation for subsequent traffic flow prediction.
[0131] Furthermore, in practical applications, some grids may have missing data due to sensor failure or sparse trajectory, so the obtained trajectory space-time matrix needs to be Perform missing value processing.
[0132] 3) Dynamically fill in missing values by combining historical time series and neighboring spatial information through spatiotemporal weighted interpolation, namely:
[0133] (2);
[0134] In formula (2): Represents the time step And the grid position is Traffic flow value; Indicates the time step, ranging from 1 to ; Represents the time step And the grid position is Traffic flow value; Indicates the location of the adjacent grid; Represents the time step and adjacent to the grid position Traffic flow value; weight coefficient of time dimension Give more weight to recent data (for example, data points within the past 10 minutes); weight coefficient of spatial dimension Distance attenuation based on the grid position; M(i,j) is defined as the neighborhood of the current grid (i,j), including its upper, lower, left, right, and diagonal adjacent grids, forming a local neighborhood range.
[0135] This formula (2) dynamically fills missing values by combining historical time series data and neighboring spatial information, ensuring data continuity while avoiding the noise introduced by zero filling or simple mean interpolation.
[0136] Furthermore, in order to improve the stability of model training, the filled trajectory space-time matrix Perform data normalization.
[0137] 4) Perform max-min normalization on each grid independently:
[0138] (3);
[0139] In formula (3): Indicates grid position The normalized traffic flow value has a value range of [0, 1]; Indicates grid position The original traffic flow value of 、 Grid positions The maximum and minimum values of .
[0140] This operation scales the flow value of each grid to the interval [0, 1] while preserving the relative differences between grids. For example, the maximum flow of a grid in the city center may be 5 times that of a grid in the suburbs. 、 Based on training set statistics, information leakage of the test set is avoided.
[0141] Based on the above operations, the normalized traffic flow values of all grid locations in the urban area can be obtained and constructed into a traffic characteristic matrix .
[0142] The preprocessing of environmental data also includes missing value filling and encoding operations. The specific implementation process is as follows:
[0143] 1) Fill missing values in environmental data. For weather data, if weather records for a certain time period are missing, interpolation is performed based on the weather conditions in adjacent time periods. For example, if the weather data for 10:00 a.m. is missing, the weather patterns for 9:55 a.m. and 10:05 a.m. are weighted averaged, and the result is used as the weather data for 10:00 a.m. For temperature data, linear interpolation is used to fill missing values, that is: .in, Represents the time step The original temperature value; Represents the time step The original temperature value; Represents the time step For extreme outliers, such as -50°C or 50°C, the temperature range is based on the historical temperature range of the same period, that is, the mean ±3 , to be eliminated or corrected. Among them, Represents the standard deviation of the temperature data in the training set.
[0144] It should be understood that holiday identification is directly marked according to the national statutory holiday list without the need for interpolation.
[0145] 2) Encode the filled environmental data. For weather data, use one-hot encoding to generate dimensions of For example, weather types include sunny, rainy, and snowy, so the encoding dimension =3, sunny day is represented by , rainy days are represented by , snowy days are represented by Through one-hot encoding, the model can better learn the impact of different weather types on traffic flow. For holidays, binary encoding 0 / 1 is used, and the dimension is = 1. For example, weekdays are represented as 0 and holidays as 1. Holidays usually lead to changes in traffic flow. Binary identification can help the model distinguish traffic flow patterns on weekdays and holidays. For temperature data, it is converted to a scalar value through Z-score standardization, with a dimension of =1, the formula is:
[0146] (4);
[0147] In formula (4): Represents the normalized temperature value, which is usually in the range of [-1, 1] or [0, 1], depending on the original temperature value distribution of represents the mean of the temperature data in the training set; Represents the standard deviation of the temperature data in the training set.
[0148] By calculating the mean and standard deviation of the temperature data, we transform it into a standard normal distribution, allowing the model to better account for the impact of temperature changes on traffic flow. For example, if the mean of the temperature data is 20°C and the standard deviation is 5°C, Z-score normalization will transform the temperature data into a standard normal distribution, reducing the impact of temperature changes on the model.
[0149] The above encoding results are spliced in the feature dimension to form a unified environmental feature vector , where d= Then the obtained environmental feature vector Mapped to the spatial dimension of the traffic grid to obtain the environmental feature matrix .
[0150] Specifically, after completing the environmental data encoding, the obtained environmental feature vector Mapping to the spatial dimension of the traffic grid ensures that the environmental features are aligned with the traffic features in space. In this step, the environmental feature vector The weather type and holiday identifier vector encoded in the is used as the global feature, and the standardized temperature value is As spatial distribution features, feature mapping operations are performed respectively. The specific steps are as follows:
[0151] 1) Global features are features related to the entire transportation network, which usually do not change with the change of spatial location, or their changes can be ignored. Therefore, these features need to be copied to all grid locations to generate a global feature matrix , Represents the dimension of the global feature vector. That is:
[0152] (5);
[0153] In formula (5): Represents the time step And the grid position is The global eigenvector of ; Represents the time step The global eigenvector of .
[0154] 2) For spatial distribution characteristics, the impact of this characteristic varies with different spatial locations. It is necessary to assign it to each grid location based on the temperature data and grid location information. The Inverse Distance Weighting (IDW) method is used to interpolate the temperature data into the traffic grid to generate a spatial distribution characteristic matrix. , Represents the dimension of the spatial distribution feature vector. That is:
[0155] (6);
[0156] In formula (6): Represents the time step And the grid position is The spatial distribution characteristic vector of Indicates the sensors at time step Observed values of Indicates the number of sensors; Indicates grid position To Euclidean distance between sensors; is a smoothing constant, such as =1e−6, which is used to prevent the denominator from being zero.
[0157] The global feature matrix that will be generated in the end and spatial distribution feature matrix Splicing to form a complete environmental feature matrix ,Right now:
[0158] (7).
[0159] This step ensures the alignment of environmental features in the spatial dimension and provides a basis for subsequent feature fusion.
[0160] Next, the traffic feature matrix With the complete environmental characteristics matrix Perform embedding layer concatenation to obtain the target spatiotemporal matrix as model input Specifically, after completing the environmental feature vector After spatial mapping, the normalized traffic feature matrix and a complete environmental feature matrix containing global and spatial distribution features Concatenate in the channel dimension to form a unified input representation , where C is the number of channels of traffic characteristics; d is the total dimension of environmental characteristics, and its expression is:
[0161] (8).
[0162] This step integrates the two types of features as model input for the subsequent multi-scale 3D convolution module to extract spatiotemporal features.
[0163] S2, construct a traffic flow prediction model including a multi-scale 3D convolution module, a dynamic contrast learning module, an environmental feature gated fusion module and a spatiotemporal deconvolution prediction module, and transform the target spatiotemporal matrix As input data, a joint loss function is constructed based on dynamic contrastive learning loss, gated fusion loss and prediction loss to optimize the traffic flow prediction model.
[0164] Ginseng Figure 4 As shown, this step specifically includes the following operations.
[0165] The multi-scale 3D convolution module is used to extract the target spatiotemporal matrix Traffic characteristic matrix The feature information of different scales is integrated to generate traffic fusion features. Specifically, the target spatiotemporal matrix obtained by preprocessing is As input, the traffic feature matrix The multi-scale 3D convolution module extracts features, including traffic flow, from the data. This module uses a parallel branching structure to extract spatiotemporal features from different scales and gradually fuses them to form a comprehensive feature representation, providing rich semantic information for subsequent modules.
[0166] Ginseng Figure 5 The multi-scale 3D convolution module contains three parallel branches: the first branch is a coarse-grained branch that uses a larger convolution kernel. , for example, 5×5×5, with a larger step size s1. Its main function is to downsample the original input to capture overall traffic trends across regions and over long periods of time. For example, during peak hours, the trend of traffic spreading from the city's periphery to the city center will be clearly reflected in this branch. Its expression is:
[0167] (9);
[0168] In formula (9): This represents the output feature tensor after processing by the coarse-grained branch, which contains global trend information after downsampling. Here, the BatchNorm operation stabilizes the training process, while the ReLU activation function introduces nonlinearity, making the feature response more pronounced. The feature tensor generated by the coarse-grained branch is downsampled in both time and space, preserving global trend information but potentially blurring details.
[0169] In order to take into account both global trends and local details, the second branch is a medium-grained branch that uses a medium-sized convolution kernel. , for example, 3×3×3, and the step size is set to 1 to maintain the original resolution of the input. This can capture the dynamic characteristics of traffic propagation between adjacent grids while modeling the detailed information of the local area. The expression of this branch is:
[0170] (10);
[0171] In formula (10): This represents the output feature tensor after processing with medium-granularity branches. It retains the original input resolution and can capture detailed information about local regions. Because the resolution remains unchanged, the output features retain spatiotemporal details, making them highly expressive of the spread of local congestion at intersections and short-term fluctuations in the interaction between vehicles.
[0172] The third branch is the fine-grained branch. It targets extremely subtle local changes, such as instantaneous traffic fluctuations caused by traffic accidents or signal light changes. This branch uses a 1×1×1 convolution kernel to perform a single-point nonlinear transformation on each spatiotemporal unit. Its expression is:
[0173] (11);
[0174] In formula (11): The output feature tensor after fine-grained branching is processed, which can highlight local sharp changes. Although this branch does not change the spatial structure, it can highlight local sharp changes through nonlinear mapping, making the model more sensitive in detecting sudden events.
[0175] During the multi-scale feature extraction process, branches of different scales may produce feature maps of inconsistent sizes. To ensure effective alignment of information from each branch during subsequent feature fusion, a bilinear interpolation method is used after the output of each branch to unify them to the same spatial resolution. The number of channels of the feature map after interpolation is consistent with that before interpolation, ensuring that no additional channel alignment operation is required during subsequent splicing or channel attention fusion. This operation is different from the interpolation of the original data in the data preprocessing stage. Instead, it is an alignment process for the feature map to ensure that the coarse, medium, and fine scale information can be seamlessly fused in a unified spatial dimension to form a fused feature tensor: , Represents the sum of the number of output channels of the three branches of the multi-scale 3D convolution module.
[0176] In order to further integrate the features of each scale, a channel attention mechanism is used. The specific approach is to first perform global average pooling on each branch to obtain the channel descriptor of each branch, and then use the learnable parameters Calculate the weight of each branch, namely:
[0177] (12);
[0178] In formula (12): Represents any branch of coarse, medium or fine; Represents the weight of each branch in the multi-scale 3D convolution module; is a learnable parameter; Indicates the Feature graph of each branch Perform a global average pooling operation to obtain the channel descriptor.
[0179] Based on the above, the final traffic integration characteristics for:
[0180] (13).
[0181] Traffic integration features here It contains rich spatiotemporal information from global trends to local details, providing a solid foundation for subsequent dynamic contrast learning and environment fusion. Represents traffic integration characteristics The number of channels is the total number of channels after weighted fusion of the coarse, medium and fine branch feature tensor channels.
[0182] The dynamic contrast learning module is used to calculate the traffic fusion feature The flow difference between two consecutive time steps in the flow rate is used to obtain the real-time flow rate change rate , based on the real-time traffic change rate Set a positive and negative sample generation strategy, and obtain positive and negative sample pairs based on the strategy, use the positive and negative sample pairs as training data, and introduce a dynamic temperature coefficient , construct a dynamic contrast loss to optimize the traffic flow prediction model.
[0183] Specifically, in order to enhance the model's ability to respond to sudden changes in traffic flow, the dynamic contrastive learning module is used to analyze traffic fusion features. Further optimization is carried out. Figure 6 , including the following steps: First, the flow rate change rate The calculation of , calculates the flow difference between two consecutive time steps in the time dimension, measured by Euclidean distance:
[0184] (14);
[0185] In formula (14): Indicates the real-time traffic change rate; Represents the time step The fused feature tensor of Represents the time step Both contain rich spatiotemporal information from global trends to local details.
[0186] Real-time traffic change rate Reflects the severity of the current traffic situation. If the threshold is exceeded, it is considered an emergency scenario. Different strategies for generating positive and negative samples are used: 1) In this embodiment, if Higher, indicating a sudden scene, the positive sample is selected at the current time step and its adjacent time steps and The fused feature tensor , the positive sample is represented as ; Negative samples are sampled from an area at least L grid cells away from the current grid position, where L is a threshold predefined according to the specific traffic network layout. For example, in an urban traffic grid, L can be defined as 20% of the total number of grids or a fixed value such as 5 grid cells. Negative samples are represented as By setting a clear distance threshold, we ensure that the selected negative samples have a significant distance difference from the current grid in space, thereby highlighting the obvious flow differences between different regions and enhancing the model's ability to distinguish instantaneous dynamic changes. 2) If A lower value indicates a stable scene with relatively stable overall features. In order to further capture local details and minor changes, historical data from the same period can be used as positive samples. , for example, data from the same period of the previous 24 hours, and negative samples are sampled in the same area , so that the model pays more attention to the subtle traffic changes within the same geographical location rather than the overall traffic differences caused by geographical differences. In the dynamic contrastive learning module, cosine similarity is used as the core indicator to measure the similarity between positive and negative sample pairs. Specifically, the traffic fusion feature Projection to low-dimensional embedding space through linear mapping , which is convenient for calculating similarity. For the positive sample representation in the embedding space and negative sample representation , the cosine similarity is calculated by the following formula:
[0187] (15);
[0188] In formula (15): and Represent the feature vectors of positive and negative samples in the low-dimensional embedding space respectively. This similarity function calculates the dot product of two vectors and normalizes them to obtain the cosine value of the cosine angle between them, thereby quantifying the similarity between samples.
[0189] Based on the above strategy, positive and negative samples are obtained. Furthermore, in this embodiment, the improved InfoNCE loss function is used to perform comparative training on the positive and negative sample pairs. The improved InfoNCE loss function is:
[0190] (16);
[0191] In formula (16): represents the InfoNCE loss function; Indicates the similarity between positive sample pairs, using cosine similarity; Represents the positive sample and the The similarity between negative samples; is the dynamic temperature coefficient, which is used to adjust the similarity distribution between positive and negative samples; Indicates the number of negative samples, that is, the number of negative samples used for comparative learning with positive samples. for:
[0192] (17);
[0193] In formula (17): 、 All are adjustment coefficients; is an exponential function. Dynamic temperature coefficient The introduction of enables the model to adaptively smooth the similarity distribution in the feature space, thereby improving the ability to distinguish positive samples and reject negative samples in sudden scenarios.
[0194] By optimizing the contrast loss function, the similarity of positive sample pairs in the embedding space is improved, while the similarity of negative sample pairs is reduced. This optimization strategy helps the model better capture the dynamic changes of traffic flow, especially in sudden scenarios, thereby significantly enhancing the model's ability to distinguish sudden changes in traffic flow. Specifically, in sudden scenarios, the positive sample pairs , such as the current frame and its adjacent frames, whose similarity is maximized; while the negative sample pair The similarity between samples from areas at least L grid cells away from the current grid position is minimized. This optimization strategy enables the model to more discern and distinguish different traffic states, thereby improving its adaptability and prediction accuracy in complex traffic scenarios. In this way, the dynamic contrastive learning module effectively improves the model's responsiveness to sudden changes in traffic flow, providing a more accurate basis for traffic flow forecasting.
[0195] The environmental feature gated fusion module is used to The environmental feature matrix E in the nonlinear transformation is performed to obtain the high-dimensional embedding representation of the environment , based on the traffic fusion characteristics and high-dimensional embedding representation of the environment , calculate the dynamic gating weight , and using the dynamic gating weight Calculate the target high-dimensional fusion features , based on the traffic fusion characteristics and target high-dimensional fusion features A gated fusion loss is constructed for training the traffic flow prediction model.
[0196] Specifically, to fully leverage the impact of external environmental data on traffic flow, the environmental feature gating fusion module, after completing basic numerical encoding in the preprocessing phase, further performs deep feature learning and mapping on the environmental data to obtain a more discriminative environmental representation. This allows for a better integration of environmental information and traffic characteristics.
[0197] Ginseng Figure 7 , the process includes the following steps: 1) deep feature learning, that is, by The environmental feature matrix E in the nonlinear transformation is performed to obtain the high-dimensional embedding representation of the environment .
[0198] In the preprocessing stage, after spatial mapping, environmental features have been preliminarily integrated with traffic features to form a complete environmental feature matrix E containing global features and spatial distribution features, and then spliced with traffic features in the channel dimension to form a unified input representation. However, this preliminary integrated feature representation may not be sufficient to capture the complex interactive relationship between the environment and traffic. In order to further improve the discriminability of features, the environmental feature gated fusion module performs a nonlinear transformation on the environmental feature matrix E through a fully connected layer to generate a deep environmental embedding representation, thereby achieving more effective traffic flow feature fusion. Its expression is:
[0199] (18);
[0200] In formula (18): represents the environmental feature matrix; represents a fully connected layer; Represents a high-dimensional embedding representation of the environment for subsequent multi-head attention interaction and dynamic gating fusion.
[0201] 2) Multi-head attention interaction, that is, calculating the attention weights between traffic features and environmental features through a multi-head attention mechanism.
[0202] In order to capture the complex interaction between environmental data and traffic characteristics, the traffic fusion characteristics are first Convert to query Q; at the same time, embed the environment into a high-dimensional representation Mapping as Key Sum value V:
[0203] (19);
[0204] In formula (19): Represents the query vector, which is composed of traffic fusion features By querying the fully connected layer It is calculated to represent the query representation of traffic features at different locations, which is used to query the keys and values related to environmental features in the attention mechanism; Represents the key vector, represented by a deep high-dimensional embedding of the environment Through the key fully connected layer Calculated, it represents the key representation of the environment features at different positions and is used to match the query vector to calculate the attention weight; Represents a value vector represented by a deep high-dimensional embedding of the environment Through the value of the fully connected layer It is calculated and represents the value representation of the environmental features at different locations, and is used to output the weighted environmental feature values according to the calculated attention weights.
[0205] Calculate traffic fusion features through multi-head attention mechanism High-dimensional embedding representation of the environment The attention weight between reflects the influence of environmental information on each spatiotemporal position, and its expression is:
[0206] (20);
[0207] In formula (20): Indicates the dimension of the key vector, which is used to scale the dot product result to prevent the dot product result from being too large, causing the softmax function gradient to disappear or explode; Represents the key vector matrix A transpose operation is performed to perform matrix multiplication; the transposed matrix is multiplied with the query vector matrix Q to obtain the dot product between the query vector and the key vector, reflecting the correlation between them.
[0208] 3) Dynamic gating mechanism: By integrating traffic fusion features It is concatenated with the attention output and then activated by a layer of linear mapping and Sigmoid to calculate the dynamic gating weight. :
[0209] (twenty one);
[0210] In formula (21): Represents the Sigmoid activation function; Represents a gated fully connected layer, used to generate gated weights , controlling the fusion ratio of environmental features and traffic features.
[0211] Then, the target high-dimensional fusion feature is obtained through adaptive fusion of gated weights :
[0212] (twenty two).
[0213] Through this design, the environmental feature gated fusion module can not only make full use of the embedding layer splicing results in the preprocessing stage, but also further enhance the interaction between environmental features and traffic features, thereby improving the model's ability to understand complex traffic scenes and prediction accuracy. and target high-dimensional fusion features Constructing the loss of the environment feature gated fusion module , which is used to measure the effect of integrating environmental features with traffic features. The specific calculation method is as follows:
[0214] (twenty three);
[0215] In formula (23): represents the gated fusion loss; Indicates the Traffic integration characteristics of samples; Indicates the The target high-dimensional fusion features of samples; Indicates the number of samples in the batch.
[0216] The spatiotemporal deconvolution prediction module is used to fusion the target high-dimensional features An upsampling operation is performed to generate a prediction map of future traffic flow; and a prediction loss is constructed based on the prediction result to optimize the traffic flow prediction model.
[0217] Based on the target high-dimensional fusion features obtained in the above steps ,in, The time dimension is the size of the time series, i.e., the length of the time series. H × W is the spatial size of the urban area. C is the number of channels. This already integrates the multi-scale spatiotemporal characteristics of traffic flow and external environmental information. Next, the spatiotemporal deconvolution prediction module aims to upsample this high-dimensional feature to its original spatiotemporal resolution and generate a forecast map of future traffic flow.
[0218] First, since the multi-scale 3D convolution module and fusion process may cause downsampling in the time and space dimensions, in order to ensure that the prediction results have the same resolution as the original data, it is necessary to use 3D deconvolution to gradually restore the downsampled features. The complete deconvolution prediction process is as follows: Figure 8 As shown, the process includes the following steps:
[0219] 1) Preliminary upsampling, i.e. target high-dimensional fusion features After the first layer of 3D deconvolution operation.
[0220] This layer uses a larger convolution kernel , for example 4×4×4, and the corresponding step size , for example 2×2×2, to achieve fast upsampling. The deconvolution operation not only increases the time and space dimensions, but also fuses and smoothes the features to a certain extent. Its expression is:
[0221] (twenty four);
[0222] In formula (24): is the output of the first layer of 3D deconvolution. At this time, the output features The size of the target high-dimensional fusion feature There is obvious magnification, which lays the foundation for subsequent refined processing.
[0223] 2) Layer-by-layer refinement of upsampling, i.e., performing a second layer of 3D deconvolution to further restore details and complete spatiotemporal structure.
[0224] This layer uses medium-sized convolution kernels (e.g. 3×3×3) and smaller step size (e.g. 1×1×1) to refine the coarse features obtained in the previous step , while further restoring the original space and time dimensions; its expression is:
[0225] (25);
[0226] In formula (25): The output of the second layer of 3D deconvolution. In this stage, the model not only upsamples the data but also reconstructs the features through deconvolution operations, ensuring that the global trends and local details extracted by the previous multi-scale 3D convolution can be fully restored during the upsampling process.
[0227] 3) Final prediction output, i.e. generating a prediction map of future traffic flow.
[0228] The last layer of deconvolution uses a 1×1×1 convolution kernel and a 1×1×1 step size to compress the number of channels and map the features to the dimension of the target output. At the same time, the Sigmoid activation function is used to constrain the output to a suitable numerical range. Its expression is:
[0229] (26);
[0230] In formula (26): Represents the forecast map of future traffic flow, where The number of time steps for future predictions, which is consistent with the previous upsampling target.
[0231] Throughout the spatiotemporal deconvolution prediction process, the model gradually restores the temporal and spatial resolution reduced by convolution through multiple layers of deconvolution, while ensuring the continuous transmission of feature information. The upsampling operation not only restores the data size but, more importantly, "decodes" the complex spatiotemporal features extracted by the previous modules into interpretable traffic flow values through activation functions and batch normalization. This process, combined with the previous multi-scale 3D convolutional feature extraction, forms an end-to-end closed loop, ensuring that every data change from the input spatiotemporal matrix to the final predicted output has a clear mathematical definition and physical meaning.
[0232] Finally, the prediction loss is constructed based on the obtained prediction results :
[0233] (27);
[0234] In formula (27): Represents the true traffic matrix of the i-th sample (from the target spatiotemporal matrix Extract samples and form , each sample Corresponding to traffic data within a time window); Represents the prediction result of the i-th sample; is the total number of samples in the training set.
[0235] Furthermore, in this embodiment, the traffic flow prediction model takes into account the prediction loss, the InfoNCE loss of the dynamic contrastive learning module, and the loss of the environmental feature gated fusion module during training. These loss functions are weighted and summed using preset weights α, ξ, and η to form a joint loss function, which jointly guides the model optimization process.
[0236] The joint loss function adopts the form of weighted summation, namely:
[0237] (28);
[0238] In formula (28): α, ξ and η are used to balance the prediction loss , Dynamic Contrastive Learning Loss and gated fusion loss By adjusting the values of α, ξ, and η, the relative importance of the three losses in the total loss can be controlled, thereby achieving fine-tuning of the model training process.
[0239] Furthermore, to achieve real-time performance, this method employs a sliding window strategy, dynamically adjusting the window step size during the prediction phase based on the current rate of change of traffic. When drastic traffic fluctuations are detected, such as when the real-time rate of change of traffic (Rt) is high, the model automatically shortens the step size of the prediction window to more quickly respond to dynamic changes in traffic. Through backpropagation, the prediction error (such as the mean squared error (MSE)) is fed back to each deconvolution layer and preceding module, continuously optimizing model parameters and ultimately improving overall prediction accuracy and real-time responsiveness. This spatiotemporal deconvolution prediction module is closely integrated with the front-end multi-scale feature extraction and dynamic contrastive learning modules, ensuring a seamless transition from high-dimensional fusion features to prediction output, providing a solution for urban traffic flow prediction that is both accurate and real-time.
[0240] The following further explains the training, verification, and testing process of the model in this method in combination with specific application scenarios.
[0241] During the model training phase, two public datasets, TaxiBJ and BikeNYC, were used as the original data sources, of which TaxiBJ contains GPS trajectory data of taxis in Beijing, and BikeNYC covers public bicycle riding records in New York City. The data in the two datasets were preprocessed based on the data preprocessing method described above in this embodiment. After the data preprocessing was completed, the data was divided into a training set, a validation set, and a test set in a ratio of 6:2:2 to ensure time continuity. The input format of the training set is a three-dimensional spatiotemporal matrix for 12 consecutive hours, and the label is the traffic flow matrix for the next hour. In order to further improve the adaptability of the model to complex traffic scenarios, external environmental data (such as weather, temperature, holidays) are also preprocessed, encoded, and standardized, and adaptively fused with traffic flow data through an environmental feature gated fusion module to form a high-dimensional fusion feature that includes both spatiotemporal traffic characteristics and environmental impacts.
[0242] In terms of traffic trajectory data preprocessing, the original traffic trajectory data is first divided into fixed grids according to urban areas, such as TaxiBJ is divided into 32×32 grids, and BikeNYC is divided into 16×8 grids. The flow data in each grid is counted within a fixed time window (such as every 30 minutes or every 5 minutes) to generate a single-frame two-dimensional flow map. , and then stacked in chronological order to form a three-dimensional space-time tensor. To ensure consistent numerical scale, a maximum-minimum normalization method is applied to each grid, scaling the flow value to the range [0, 1]. The normalization parameters are based on training set statistics. Meanwhile, environmental data preprocessing includes data collection, temporal and spatial alignment, and encoding. Specifically, weather type is encoded using one-hot encoding, such as sunny: ;rain: ;Snow: Holidays are encoded using a binary value, with 0 representing weekdays and 1 representing holidays. Temperature data is normalized using the Z-score. The processed environmental data is assigned to the corresponding traffic grid using a spatial mapping method and then initially concatenated with the traffic flow tensor in the embedding layer. The environmental feature gated fusion module uses multi-head attention and dynamic gating mechanisms to achieve adaptive fusion, generating a fused feature representation that combines both spatiotemporal and environmental information.
[0243] During model training, AdamW was used as the optimizer, the initial learning rate was set to 0.001, and the learning rate was dynamically adjusted using a cosine annealing strategy. The minimum learning rate was limited to 1e-5 to prevent oscillations. During training, 32 samples were input per batch, the maximum number of training rounds was set to 100, and an early stopping mechanism was introduced. The patience value was set to 10 rounds, and the loss of the validation set was monitored to prevent overfitting. To enhance the generalization ability of the model, a Dropout layer (ratio 0.2) was added after the convolutional layer. At the same time, L2 weight decay was set with a coefficient of 1e-4, and gradient clipping was used with a threshold of 5.0 to avoid gradient explosion. After the relevant parameters were configured, the joint loss function constructed above was used to optimize the model training. In addition, to evaluate the consistency of the embedding space, the similarity difference between positive and negative sample pairs was calculated using the following formula:
[0244] (29).
[0245] The prediction accuracy is quantified by the mean absolute error (MAE) and the root mean square error (RMSE), and the formulas are:
[0246] (30);
[0247] (31).
[0248] If the mean absolute error (MAE) of the validation set does not decrease for three consecutive rounds, the learning rate is halved; if the similarity difference between positive and negative samples is insufficient, the contrast loss weight is adjusted, for example, to 0.5. During the training process, the environmental data is adaptively adjusted in its contribution at different spatiotemporal locations through the environmental feature gating fusion module, which generates gating weights. , which determines the proportion of environmental information in feature fusion. This mechanism allows factors such as weather, temperature, and holidays to effectively influence model parameters during backpropagation, thereby improving the model's prediction accuracy under abnormal environmental conditions.
[0249] During the model validation phase, the validation set is independently partitioned from the training data. Its core goal is to monitor the model's generalization ability and optimize hyperparameters. During the validation process, in addition to evaluating the embedding space consistency by calculating the similarity difference between positive and negative sample pairs using formula (29), the overall prediction accuracy is evaluated using the mean absolute error (MAE) and root mean square error (RMSE) metrics. If the validation set metrics do not improve over multiple rounds, the learning rate and contrast loss weight are dynamically adjusted to further improve model performance.
[0250] During the model testing phase, the test set is strictly independent of the training and validation data. For example, the test data for TaxiBJ was selected from the last two months of 2019. A sliding window strategy is used in the testing phase, with a fixed window length of 12 hours and an initial sliding step of 1 hour. When the traffic change rate Rt>0.3 is detected, the step size is dynamically shortened to 0.5 hours to enable a faster response to sudden traffic incidents. In addition to global MAE and RMSE, the test evaluation indicators also calculate local errors for traffic hotspots (such as commercial district grids) and record single-frame prediction delays, with a target of less than 30 milliseconds. In addition, cross-dataset tests are designed, such as TaxiBJ→BikeNYC and BikeNYC→TaxiBJ, to evaluate the model's generalization ability by comparing prediction results under different traffic modes.
[0251] In summary, throughout the entire process, the TaxiBJ and BikeNYC datasets were used throughout the training, validation, and testing phases. This combined preprocessing and deep fusion of environmental data, leveraging dynamic learning strategies, multi-objective joint loss functions, and rigorous evaluation mechanisms to systematically improve the accuracy and real-time performance of traffic flow predictions, providing a solid data support and model foundation for intelligent decision-making in complex traffic scenarios. Furthermore, this invention achieves significant performance improvements in traffic flow prediction through the deep integration of dynamic contrastive learning and multi-scale 3D convolution technology, particularly in handling sudden traffic events and complex environmental conditions.
[0252] Example 2
[0253] This embodiment provides a device for implementing a traffic flow prediction method based on dynamic contrastive learning and multi-scale 3D convolution, the device comprising:
[0254] A data acquisition module is used to acquire traffic trajectory data and environmental data and perform preprocessing operations on them to obtain a traffic feature matrix and an environmental feature vector, map the environmental feature vector to the spatial dimension of the traffic grid to obtain an environmental feature matrix, and concatenate the traffic feature matrix and the environmental feature matrix to obtain a target spatiotemporal matrix as a model input;
[0255] a model construction module for constructing a traffic flow prediction model comprising a multi-scale 3D convolution module, a dynamic contrastive learning module, an environmental feature gated fusion module, and a spatiotemporal deconvolution prediction module, taking the target spatiotemporal matrix as input data and constructing a joint loss function based on the dynamic contrastive learning loss, the gated fusion loss, and the prediction loss to optimize the traffic flow prediction model;
[0256] The multi-scale 3D convolution module is used to extract and fuse feature information of different scales of the traffic feature matrix in the target spatiotemporal matrix to generate traffic fusion features;
[0257] The dynamic contrastive learning module is used to calculate the flow difference between two consecutive time steps in the traffic fusion feature to obtain a real-time flow change rate, set a positive and negative sample generation strategy based on the real-time flow change rate, obtain positive and negative sample pairs based on the strategy, use the positive and negative sample pairs as training data, introduce a dynamic temperature coefficient, and construct a dynamic contrast loss for optimizing the traffic flow prediction model;
[0258] The environmental feature gating fusion module is used to perform a nonlinear transformation on the environmental feature matrix in the target spatiotemporal matrix to obtain a high-dimensional embedding representation of the environment, calculate dynamic gating weights based on the traffic fusion features and the high-dimensional embedding representation of the environment, and use the dynamic gating weights to calculate the target high-dimensional fusion features, and construct a gated fusion loss based on the traffic fusion features and the target high-dimensional fusion features for training the traffic flow prediction model;
[0259] The spatiotemporal deconvolution prediction module is used to perform an upsampling operation on the target high-dimensional fusion feature to generate a prediction map of future traffic flow; and to construct a prediction loss based on the prediction result to optimize the traffic flow prediction model.
[0260] Obviously, the above embodiments of the present invention are merely examples for the purpose of clearly illustrating the technical solutions of the present invention, and are not intended to limit the specific implementation methods of the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the claims of the present invention shall be included within the scope of protection of the claims of the present invention.
Claims
1. A traffic flow prediction method based on dynamic contrastive learning and multi-scale 3D convolution, characterized by: The method comprises: S1. Obtain traffic trajectory data and environmental data and perform preprocessing operations on them respectively to obtain a traffic feature matrix and an environmental feature vector, map the environmental feature vector to the spatial dimension of the traffic grid to obtain an environmental feature matrix, and concatenate the traffic feature matrix and the environmental feature matrix to obtain a target spatiotemporal matrix as a model input; S2. Constructing a traffic flow prediction model including a multi-scale 3D convolution module, a dynamic contrastive learning module, an environmental feature gated fusion module, and a spatiotemporal deconvolution prediction module, taking the target spatiotemporal matrix as input data, and constructing a joint loss function based on dynamic contrastive learning loss, gated fusion loss, and prediction loss to optimize the traffic flow prediction model; The multi-scale 3D convolution module is used to extract and fuse feature information of different scales of the traffic feature matrix in the target spatiotemporal matrix to generate traffic fusion features; The dynamic contrastive learning module is used to calculate the flow difference between two consecutive time steps in the traffic fusion feature to obtain a real-time flow change rate, set a positive and negative sample generation strategy based on the real-time flow change rate, obtain positive and negative sample pairs based on the strategy, use the positive and negative sample pairs as training data, introduce a dynamic temperature coefficient, and construct a dynamic contrast loss for optimizing the traffic flow prediction model; The environmental feature gating fusion module is used to perform a nonlinear transformation on the environmental feature matrix in the target spatiotemporal matrix to obtain a high-dimensional embedding representation of the environment, calculate dynamic gating weights based on the traffic fusion features and the high-dimensional embedding representation of the environment, and use the dynamic gating weights to calculate the target high-dimensional fusion features, and construct a gated fusion loss based on the traffic fusion features and the target high-dimensional fusion features for training the traffic flow prediction model; The spatiotemporal deconvolution prediction module is used to perform an upsampling operation on the target high-dimensional fusion feature to generate a prediction map of future traffic flow; and to construct a prediction loss based on the prediction result to optimize the traffic flow prediction model.
2. The traffic flow prediction method based on dynamic contrastive learning and multi-scale 3D convolution according to claim 1 is characterized in that: In S1, the traffic trajectory data is pre-processed, specifically including: The traffic trajectory data is cleaned and spatial discretized to obtain the traffic flow value of each grid in all time windows, and a corresponding single-frame two-dimensional traffic map is generated. ,in, the size of the regular grid representing the urban area where the traffic trajectories are located; A single-frame two-dimensional flow map generated by stacking each grid in all time windows in chronological order , forming a trajectory space-time matrix , Represents the time dimension; The trajectory spatiotemporal matrix is dynamically filled by combining historical time series and adjacent spatial information through spatiotemporal weighted interpolation. The missing values in , the formula is: (2); In formula (2): Represents the time step And the grid position is Traffic flow value; Indicates the time step, ranging from 1 to ; Represents the time step And the grid position is Traffic flow value; Indicates the location of the adjacent grid; Represents the time step and adjacent to the grid position Traffic flow value; is the weight coefficient of the time dimension; is the weight coefficient of the spatial dimension; M(i,j) represents the neighborhood of the current grid (i,j), including the local neighborhood range formed by its upper, lower, left, right, and diagonal adjacent grids; The interpolated trajectory space-time matrix Perform max-min normalization independently for each grid in : (3); In formula (3): Indicates grid position The normalized traffic flow value has a value range of [0, 1]; Indicates grid position The original traffic flow value of 、 Grid positions The maximum and minimum values of .
3. The traffic flow prediction method based on dynamic contrastive learning and multi-scale 3D convolution according to claim 1 is characterized in that: In S1, the environmental data includes weather type, holiday identifier, and temperature data. Preprocessing operations are performed on the environmental data, specifically including: Performing data cleaning on the environmental data and filling missing values in the cleaned environmental data includes: Interpolate and fill in the currently missing weather types based on the weather types of adjacent time periods; Linear interpolation is used to fill the missing values of the currently missing temperature data. The formula is: ,in, Represents the time step The original temperature value; Represents the time step The original temperature value; Represents the time step The original temperature value; And, performing an encoding operation on the filled environment data, including: Use one-hot encoding to encode the weather type, generating the dimension vector of The holiday identifier is encoded using binary coding, and the generated dimension is vector of The temperature data is converted into a scalar value by Z-score normalization, and its dimension is =1, the formula is: (4); In formula (4): Indicates the standardized temperature value; represents the mean of the temperature data in the training set; represents the standard deviation of the temperature data in the training set; The encoding results of the weather type, holiday identifier and temperature data are spliced in the feature dimension to form a unified environmental feature vector , where d= .
4. The traffic flow prediction method based on dynamic contrastive learning and multi-scale 3D convolution according to claim 3 is characterized in that: In S1, the weather type and holiday identifier vectors encoded in the environmental feature vector are used as global features, and feature mapping operations are performed to generate a global feature matrix, the formula of which is: (5); In formula (5): Represents the time step And the grid position is The global eigenvector of ; Represents the time step The global eigenvector of ; And, the standardized temperature value is used as the spatial distribution feature, and the feature mapping operation is performed to generate the spatial distribution feature matrix, whose formula is: (6); In formula (6): Represents the time step And the grid position is The spatial distribution characteristic vector of Indicates the sensors at time step Observed values of Indicates the number of sensors; Indicates grid position To Euclidean distance between sensors; is a smoothing constant used to prevent the denominator from being zero; The generated global feature matrix and spatial distribution feature matrix are spliced together to form an environmental feature matrix, whose formula is: (7); In formula (7): represents the environmental feature matrix; The traffic feature matrix and the environment feature matrix are embedded and spliced to obtain the target spatiotemporal matrix: (8); In formula (8): Represents the target spatiotemporal matrix.
5. The traffic flow prediction method based on dynamic contrastive learning and multi-scale 3D convolution according to claim 1 is characterized in that: In S2, the multi-scale 3D convolution module includes parallel coarse-grained branches, medium-grained branches and fine-grained branches; wherein the convolution kernel of the coarse-grained branch is , and with step length , that is: (9); In formula (9): represents the target spatiotemporal matrix; Represents the output feature tensor after coarse-grained branch processing; The convolution kernel of the medium-granularity branch , and the step size is set to 1, its expression is: (10); In formula (10): Represents the output feature tensor after medium-granularity branch processing; The fine-grained branch uses a 1×1×1 convolution kernel, which is expressed as: (11); In formula (11): Represents the output feature tensor after fine-grained branch processing; The feature tensors generated by each branch in the multi-scale 3D convolution module are fused to form a fused feature tensor , Represents the sum of the number of output channels of all branches of the multi-scale 3D convolution module; The channel attention mechanism is used to integrate the feature tensors generated by each branch in the multi-scale 3D convolution module, and its expression is: (12); In formula (12): Represents any branch of coarse, medium or fine; Represents the weight of each branch in the multi-scale 3D convolution module; is a learnable parameter; Indicates the Feature graph of each branch Perform global average pooling operation to obtain channel descriptors; Based on the above, the traffic fusion characteristics are finally obtained for: (13)。 6. The traffic flow prediction method based on dynamic contrastive learning and multi-scale 3D convolution according to claim 1 is characterized in that: In S2, the calculation formula of the real-time flow rate change rate is: (14); In formula (14): Indicates the real-time traffic change rate; Represents the time step The fused feature tensor of Represents the time step The fused feature tensor of The positive and negative sample generation strategies are set based on the real-time traffic change rate, including: If the real-time traffic change rate If the value is higher than the set threshold, it indicates an emergency scenario, and the positive sample is selected at the current time step. and its adjacent time steps and The fused feature tensor , the positive sample is represented as ; Negative samples are sampled from an area at least L grid units away from the current grid position in space. Negative samples are represented as ; If the real-time traffic change rate If the value is lower than the set threshold, it indicates a stable scenario, and the historical data of the same period is used as the positive sample. , and sample negative samples in the same area ; The traffic fusion feature Projection to low-dimensional embedding space through linear mapping , and the similarity between positive and negative sample pairs is measured by cosine similarity, the formula is: (15); In formula (15): and Represent the feature vectors of positive samples and negative samples in the low-dimensional embedding space respectively; The improved InfoNCE loss function is used to perform comparative training on positive and negative sample pairs. The improved InfoNCE loss function is: (16); In formula (16): represents the InfoNCE loss function; Represents the similarity between positive sample pairs; Represents the positive sample and the The similarity between negative samples; is the dynamic temperature coefficient, which is used to adjust the similarity distribution between positive and negative samples; Indicates the number of negative samples; Wherein, the dynamic temperature coefficient for: (17); In formula (17): 、 All are adjustment coefficients; is an exponential function.
7. The traffic flow prediction method based on dynamic contrastive learning and multi-scale 3D convolution according to claim 1 is characterized in that: In S2, a nonlinear transformation is performed on the environment feature matrix in the target spatiotemporal matrix to obtain a high-dimensional embedding representation of the environment: (18); In formula (18): represents the environmental feature matrix; represents a fully connected layer; Representing a high-dimensional embedding representation of the environment; The attention weights between traffic features and environmental features are calculated through a multi-head attention mechanism, including: Integrate traffic features Convert to query Q and embed the environment into a high-dimensional representation Mapping as Key The sum value V is: (19); In formula (19): Represents the query vector, which is composed of traffic fusion features By querying the fully connected layer Calculated; represents the key vector, represented by the high-dimensional embedding of the environment Through the key fully connected layer Calculated; Represents a value vector, represented by a high-dimensional embedding of the environment Through the value of the fully connected layer Calculated; Then we have: (20); In formula (20): represents the dimension of the key vector; Represents the key vector matrix Perform transpose operation; Calculating dynamic gating weights : (21); In formula (21): Represents the Sigmoid activation function; represents a gated fully connected layer; Through adaptive fusion of gated weights, the target high-dimensional fusion features are obtained : (22); Constructing the loss of the environment feature gated fusion module : (23); In formula (23): represents the gated fusion loss; Indicates the Traffic integration characteristics of samples; Indicates the The target high-dimensional fusion features of samples; Indicates the number of samples in the batch.
8. The traffic flow prediction method based on dynamic contrastive learning and multi-scale 3D convolution according to claim 1 is characterized in that: In S2, an upsampling operation is performed on the target high-dimensional fusion feature to generate a prediction map of future traffic flow, including: The first layer of 3D deconvolution operation is performed on the target high-dimensional fusion feature, and its expression is: (24); In formula (24): Represents the target high-dimensional fusion features; is the output of the first layer of 3D deconvolution; Then the second layer of 3D deconvolution operation is performed, and its expression is: (25); In formula (25): is the output of the second layer of 3D deconvolution; The prediction output is then used to generate a forecast map of future traffic flow: (26); In formula (26): A forecast graph showing future traffic flow, The number of time steps to predict for the future; Finally, the prediction loss is constructed based on the obtained prediction results : (27); In formula (27): represents the true traffic matrix of the i-th sample; Represents the prediction result of the i-th sample; is the total number of samples in the training set.
9. The traffic flow prediction method based on dynamic contrastive learning and multi-scale 3D convolution according to claim 1 is characterized in that: In S2, the joint loss function is constructed as: (28); In formula (28): α, ξ and η are used to balance the prediction loss , Dynamic Contrastive Learning Loss and gated fusion loss The preset weight coefficient of .
10. A device for implementing a traffic flow prediction method based on dynamic contrastive learning and multi-scale 3D convolution, characterized in that: The device comprises: A data acquisition module is used to acquire traffic trajectory data and environmental data and perform preprocessing operations on them to obtain a traffic feature matrix and an environmental feature vector, map the environmental feature vector to the spatial dimension of the traffic grid to obtain an environmental feature matrix, and concatenate the traffic feature matrix and the environmental feature matrix to obtain a target spatiotemporal matrix as a model input; a model construction module for constructing a traffic flow prediction model comprising a multi-scale 3D convolution module, a dynamic contrastive learning module, an environmental feature gated fusion module, and a spatiotemporal deconvolution prediction module, taking the target spatiotemporal matrix as input data and constructing a joint loss function based on the dynamic contrastive learning loss, the gated fusion loss, and the prediction loss to optimize the traffic flow prediction model; The multi-scale 3D convolution module is used to extract and fuse feature information of different scales of the traffic feature matrix in the target spatiotemporal matrix to generate traffic fusion features; The dynamic contrastive learning module is used to calculate the flow difference between two consecutive time steps in the traffic fusion feature to obtain a real-time flow change rate, set a positive and negative sample generation strategy based on the real-time flow change rate, obtain positive and negative sample pairs based on the strategy, use the positive and negative sample pairs as training data, introduce a dynamic temperature coefficient, and construct a dynamic contrast loss for optimizing the traffic flow prediction model; The environmental feature gating fusion module is used to perform a nonlinear transformation on the environmental feature matrix in the target spatiotemporal matrix to obtain a high-dimensional embedding representation of the environment, calculate dynamic gating weights based on the traffic fusion features and the high-dimensional embedding representation of the environment, and use the dynamic gating weights to calculate the target high-dimensional fusion features, and construct a gated fusion loss based on the traffic fusion features and the target high-dimensional fusion features for training the traffic flow prediction model; The spatiotemporal deconvolution prediction module is used to perform an upsampling operation on the target high-dimensional fusion feature to generate a prediction map of future traffic flow; and to construct a prediction loss based on the prediction result to optimize the traffic flow prediction model.
Citation Information
Patent Citations
Multi-graph convolutional neural network traffic prediction method based on data fusion
CN115482666A
Multi-modal traffic flow prediction method and system based on graph contrast learning
CN115601960A
Traffic flow prediction method based on time-varying fusion graph convolutional network
CN118262517A
Traffic flow prediction system based on deep learning and dynamic network analysis and application method thereof
CN118675324A