Traffic flow probability prediction model construction method based on dynamic time domain coding and application
By introducing dynamic time domain coding technology into the traffic flow probability prediction model, adaptive triangular position coding, learnable position coding and linear extended coding, the problem of insufficient timing feature extraction in univariate traffic flow prediction is solved, and the accuracy and generalization ability of prediction are improved.
Patent Information
- Application Number
- CN202510320438.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-18
- Publication Date
- 2025-06-24
AI Technical Summary
The existing univariate traffic flow probability prediction model has shortcomings in timing feature extraction, especially when dealing with variable-long time series data and different traffic scenarios, the lack of effective position encoding embedding mechanism, resulting in insufficient prediction accuracy and generalization capabilities.
A traffic flow probability prediction model construction method based on dynamic time domain encoding is adopted. Through adaptive triangular position coding, learnable position coding and linear extended encoding, multi-dimensional sequences are generated to enhance the timing feature extraction capability, and prediction is combined with time convolution network and gated loop unit.
It improves the accuracy and generalization ability of univariate traffic flow probability prediction, can be applied to prediction in different traffic flow scenarios, and overcomes the shortcomings of traditional models in timing feature extraction and position coding.
Smart Images

Figure CN120199069A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of traffic flow prediction, and more specifically, relates to a method for constructing a traffic flow probability prediction model based on dynamic time-domain coding and its application. Background Art
[0002] The rapid growth of the number of vehicles has brought great pressure on the existing traffic infrastructure. To address this challenge, cities need more intelligent traffic management systems to optimize the allocation of road resources. Traffic flow prediction plays a key role in intelligent transportation systems. By analyzing and predicting future road usage, it helps urban planners and traffic management departments make more reasonable decisions. Real-time traffic flow prediction data can assist traffic management departments in dynamically adjusting signal timings or formulating diversion strategies.
[0003] Traffic flow data belongs to time series data. Existing typical time series data prediction models include point prediction models and probabilistic time series prediction models; point prediction is a classic form of time series prediction, and the prediction model directly predicts the data. However, due to the influence of factors such as different time periods and holidays, the changes in traffic flow data are often uncertain, and it is difficult for traffic management departments to obtain intuitive data results and make decisions based on the point prediction results. The probabilistic time series prediction of traffic flow can predict a confidence interval, that is, predict the probability distribution of traffic flow data. Compared with point prediction, the confidence interval can provide more information and is more stable to noise.
[0004] Traffic flow probability prediction can be divided into univariate prediction and multivariate prediction. Multivariate prediction of traffic flow probability usually uses covariate information to assist in the prediction, and this information allows the neural network to extract traffic flow time series features. However, the dynamic dependence of this multivariate time series prediction makes the traffic flow prediction task very complex; in addition, the computational resources required for multivariate time series prediction are also large, and in practical applications, there are often only traffic flow sensors on the road, and no other data is available for use. Compared with multivariate prediction, univariate prediction of traffic flow probability directly extracts the time series relationship from the historical values of the traffic flow time series to complete the prediction task without using auxiliary information.
[0005] Existing single-variable traffic flow probability prediction models are generally neural network models based on deep learning. Considering that in the scenario of single-variable traffic flow probability prediction, there is less traffic flow data available for model training. To improve the prediction performance of the model, it is generally necessary to enhance its ability to extract temporal features. The position encoding embedding mechanism effectively increases the time series features. Currently, there are two main embedding mechanisms. One is the learnable position encoding embedding method. This embedding lacks extrapolation ability and can only process data smaller than the set word vector length. However, traffic flow data is variable-length time series data. When the length of the traffic flow sequence exceeds the set word vector length, this method cannot be used for temporal feature enhancement. The other is triangular position encoding, but this encoding lacks flexibility and cannot adjust the encoding during the training process. It is only applicable to traffic flow prediction in fixed traffic scenarios and has limited generalization ability. Therefore, for single-variable traffic flow probability prediction, a more effective position encoding embedding mechanism is needed to enhance the ability to extract temporal features. Summary of the Invention
[0006] In view of the above defects or improvement requirements of the prior art, the present invention provides a method and application for constructing a traffic flow probability prediction model based on dynamic time domain encoding, aiming to improve the accuracy and generalization ability of single-variable traffic flow probability prediction.
[0007] To achieve the above object, the present invention provides a method for constructing a traffic flow probability prediction model based on dynamic time domain encoding, including: constructing a traffic flow probability prediction model, and training the traffic flow probability prediction model with a training sample set. The training sample is traffic flow data including T historical time steps and alternating current flow data of τ prediction time steps, and the training sample is data obtained by slicing the traffic flow data collected from a single traffic flow sensor;
[0008] The traffic flow probability prediction model includes:
[0009] A dynamic time domain encoding network, including an adaptive triangular position encoding module for generating d segments of sine function position encoding and d segments of cosine function position encoding based on the input traffic flow data including T historical time steps, and a learnable position encoding module with network parameters including a segment of position encoding with a length of T and a dimension of c; wherein, the network parameters of the adaptive triangular position encoding module and the learnable position encoding module are learnable network parameters and are obtained by learning during model training;
[0010] A splicing network for splicing the sine function position encoding, the cosine function position encoding, the position encoding of the learnable position encoding module, and the traffic flow data including T historical time steps into a synthetic sequence with a dimension of 2d + c + 1;
[0011] A probability prediction network for obtaining probability distribution parameters corresponding to τ time steps based on the synthetic sequence; wherein the probability distribution parameters constitute the corresponding probability distribution.
[0012] Further, the probability prediction network includes a temporal convolutional network layer, a gated recurrent unit layer, and a post-processing network layer;
[0013] The temporal convolutional network layer is used to extract features of the synthetic sequence;
[0014] The gated recurrent unit layer is used to predict traffic flow information at the next time step t based on the features of the synthetic sequence, where t ∈ {T + 1, T + 2, …, T + τ};
[0015] The post-processing network layer includes a point prediction module and a probability prediction module; the point prediction module is used to predict the traffic flow data value at the next time step t based on the traffic flow information at the next time step t, and splice it with the traffic flow sample data of the nearest T - 1 time steps to form traffic flow data of length T and input it into the dynamic time domain encoding network for the next repetition until it is repeated τ times; the probability prediction module is used to predict the corresponding probability distribution parameters according to the traffic flow information at the next time step t, and finally obtain the probability distribution parameters corresponding to τ time steps; wherein the probability distribution parameters constitute the corresponding probability distribution.
[0016] Further, the dynamic time domain encoding network further includes a linear expansion encoding module;
[0017] The linear expansion encoding module is used to scale the traffic flow data containing T historical time steps to generate e segments of linear expansion encoding; the network parameters of the linear expansion encoding module are learnable network parameters obtained by learning during model training;
[0018] Correspondingly, the splicing network is further used to splice the sine function position encoding, the cosine function position encoding, the position encoding of the learnable position encoding module, the linear expansion encoding, and the traffic flow data containing T historical time steps into a synthetic sequence of 2d + c + e + 1 dimensions.
[0019] Further, the calculation formula of the adaptive triangular position encoding module is:
[0020]
[0021] Wherein, ATPE sin and ATPE cos respectively represent d segments of sine function position encoding and d segments of cosine function position encoding; A θ , ω θ , and bθ They are all learnable network parameters, corresponding to the amplitude, frequency, phase, and bias of trigonometric functions; pos represents the index of the time step, and pos ∈ {1, 2, …, T};
[0022] The learnable position encoding module is as follows:
[0023]
[0024] Among them, Θ LPE represents the network parameters of the learnable position encoding module;
[0025] The calculation formula of the linear expansion encoding module is:
[0026]
[0027] Among them, W LEE and b LEE are the network parameters of the linear expansion encoding module.
[0028] Furthermore, the sample generation method in the dataset is as follows:
[0029] Using the method of long - time - period random sampling, slice the traffic flow data collected from a single traffic flow sensor to obtain N traffic flow data sequences with a length of L as N samples; among them, each sample includes the traffic flow data of T historical time steps and the alternating current flow data of τ prediction time steps, and L = T + τ.
[0030] Furthermore, after obtaining the probability distribution of each time step, it further includes:
[0031] Sampling the probability distribution of each time step K times to obtain a set of point sets corresponding to each time step; using quantiles to describe the traffic flow probability distribution prediction results represented by each point set.
[0032] The present invention also provides a traffic flow probability prediction method based on dynamic time - domain encoding, including:
[0033] Input the traffic flow data of T historical time steps including the current time step into the trained traffic flow probability prediction model to obtain the alternating current flow data of τ prediction time steps; among them, the traffic flow probability prediction model is constructed by the traffic flow probability prediction model construction method described in any one of the above.
[0034] The present invention also provides an electronic device, including a computer - readable storage medium and a processor;
[0035] The computer - readable storage medium is used to store executable instructions;
[0036] The processor is used to read the executable instructions stored in the computer-readable storage medium and execute the traffic flow probability prediction model construction method described in any one of the above, or execute the traffic flow probability prediction method described above.
[0037] The present invention also provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, it implements the traffic flow probability prediction model construction method described in any one of the above, or implements the traffic flow probability prediction method described above.
[0038] The present invention also provides a computer program product, including a computer program. When the computer program runs on a computer, it causes the computer to execute the traffic flow probability prediction model construction method described in any one of the above, or execute the traffic flow probability prediction method described above.
[0039] Generally speaking, through the above technical solutions conceived by the present invention, the following beneficial effects can be achieved:
[0040] (1) The present invention constructs a traffic flow probability prediction model based on dynamic time-domain coding. The constructed dynamic time-domain coding network can encode the positions in the traffic flow time series, which is manifested as that the univariate traffic flow data input into the model is expanded into a multi-dimensional sequence through dynamic time-domain coding and then enters the subsequent probability prediction network for probability distribution prediction. The constructed dynamic time-domain coding network, as a more effective position coding embedding mechanism, breaks the symmetry of the traffic flow time series, emphasizes the importance of position information, increases the position information of the sequence, and further increases the time series information in the univariate traffic flow. Therefore, it can enhance the traffic flow time series feature extraction ability and improve the accuracy of univariate traffic flow probability prediction. The designed dynamic time-domain coding network includes an adaptive triangular position coding module and a learnable position coding module whose network parameters are obtained through training. The adaptive triangular position coding takes the parameters in the trigonometric function as the parameters that can be learned by the neural network, and uses the trigonometric function to perform position coding on the input data. It has the characteristics of being dynamic and automatically adjustable. The learnable position coding directly takes its neural network parameters as one of the position codings of the input data. Through the adaptive and learnable position coding methods, the designed dynamic time-domain coding network of the present invention can be applied to probability prediction in different traffic flow scenarios and has strong generalization ability. Moreover, through triangular position coding, the sequence length can be encoded into a position coding of the required length, so that the designed dynamic time-domain coding network of the present invention combines the advantages of triangular position coding and learnable position coding embedding methods, and at the same time overcomes the defects of both. The present invention solves the difficulty that the traffic flow collected by a single sensor lacks information and is difficult to predict, and improves the generalization ability.
[0041] (2) Preferably, the present invention extracts traffic flow features using a Temporal Convolutional Network (TCN) and predicts traffic flow data using a Gated Recurrent Unit (GRU). Meanwhile, the model adopts a probability prediction module to project the traffic flow prediction results into the parameter space of probability, realizing the probability prediction of traffic flow. The model combines the advantages of time-domain encoding, TCN, and GRU, improving the accuracy of traffic flow probability prediction.
[0042] (3) Preferably, the dynamic time-domain encoding network further includes a linear expansion encoding module. The linear expansion encoding uses the parameters of the affine transformation as the learnable parameters of the neural network to perform various affine transformations on the input traffic flow data, reducing the influence of dimensionality in different data situations. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 Schematic diagram of the traffic flow probability prediction model based on dynamic time-domain encoding in the embodiments of the present invention;
[0044] Figure 2 Schematic diagram of the dynamic encoding mechanism in the embodiments of the present invention;
[0045] Figure 3 Schematic diagram of the prediction process of the probability traffic flow prediction model in the embodiments of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0046] In order to make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0047] Embodiment 1
[0048] As Figure 1 shown, the embodiments of the present invention provide a method for constructing a traffic flow probability prediction model based on dynamic time-domain encoding, including:
[0049] Training a traffic flow probability prediction model using a data set to obtain a trained traffic flow probability prediction model; wherein, the samples in the data set are obtained by slicing the traffic flow data collected from a single traffic flow sensor, and each sample includes traffic flow data of T historical time steps and alternating current flow data of τ prediction time steps;
[0050] Among them, the traffic flow probability prediction model includes a dynamically time-encoded network (DTE), a splicing network, a temporal convolutional network (TCN), a gated recurrent unit (GRU), and a post-processing network connected in sequence; in the embodiments of the present invention, the output activation function of each neural network module uses the ReLU activation function.
[0051] The dynamically time-encoded network is used to perform three different positional encodings on each traffic flow sample, mainly including: an adaptive triangular positional encoding module, a learnable positional encoding module, and a linear extended encoding module; a traffic flow sample of length T is input into the dynamically time-encoded network. The adaptive triangular positional encoding module is used to generate corresponding d-segment sine function positional encodings and d-segment cosine function positional encodings according to the index of each time step of the input traffic flow data including T historical time steps, and d is taken according to experience. The network parameters of the learnable positional encoding module are a segment of positional encoding with length T and dimension c. The linear extended encoding module is used to scale the traffic flow data including T historical time steps to generate e-segment linear extended encodings; in the embodiments of the present invention, the linear extended encoding module is an optional module. The linear extended encoding takes the parameters of the affine transformation as the learnable parameters of the neural network, and performs various affine transformations on the input traffic flow data, reducing the dimensionality impact in different data cases. Among them, the network parameters of the three modules in the dynamically time-encoded network are all learned during the training of the traffic flow probability prediction neural network, that is, the network parameters (trigonometric function parameters) of the adaptive triangular positional encoding module, the network parameters of the learnable positional encoding module, and the network parameters of the linear extended encoding module are learnable network parameters.
[0052] The splicing network is used to splice the positional encoding output by the adaptive triangular positional encoding module and the positional encoding of the learnable positional encoding module with the original input traffic flow data (traffic flow data of T historical time steps) into a synthetic sequence of 2d + c + e + 1 dimensions and enter the TCN network.
[0053] The TCN network is used to extract the features of this synthetic sequence and input them into the GRU network.
[0054] The GRU network is used to predict the traffic flow information at the next time step t based on the features of the synthetic sequence, where t ∈ {T + 1, T + 2,..., T + τ}; this traffic flow information is input into the post-processing network.
[0055] The post - processing network includes a point prediction module and a probability prediction module; the point prediction module is used to predict the traffic flow data value at the next time step t based on the traffic flow information at the next time step t, and splice it with the traffic flow sample data of the nearest T - 1 length to form traffic flow data of length T and input it into the dynamic time - domain encoding network for repetition, repeating τ times; the probability prediction module is used to predict the corresponding probability distribution parameters according to the traffic flow information at the next time step t predicted by the GRU network, and finally obtain the probability distribution parameters corresponding to τ time steps; among them, the probability distribution parameters constitute the corresponding probability distribution.
[0056] During the training process, the generated traffic flow samples of length T are input into the traffic flow probability prediction model for forward propagation to obtain the probability distribution parameters corresponding to τ time steps, and the network parameters of the model are automatically updated. In the embodiments of the present invention, the loss value of the model is calculated by the loss function, and the Adam optimizer is used for backpropagation to update the model parameters. The loss function is the negative log - likelihood value of the probability distribution output by the model and the true value.
[0057] Preferably, in the embodiments of the present invention, the sample generation method in the dataset is as follows:
[0058] Using the method of long - time - period random sampling, the traffic flow data collected from a single traffic flow sensor is intercepted to obtain N traffic flow data with a fixed length as N samples; specifically including:
[0059] Randomly generate N indexes within the length of the traffic flow data collected from a single traffic flow sensor for a period of time; use a preset interception length L to segment the traffic flow data within this period of time to obtain N traffic flow sequence samples; among them, each traffic flow sequence sample includes the traffic flow data of T historical time steps and the alternating current flow data of τ prediction time steps, and L = T + τ.
[0060] Preferably, in the embodiments of the present invention, a temporal convolutional network (TCN) is used to extract traffic flow features, a gated recurrent unit (GRU) is used to predict traffic flow data, and a probability prediction module is used to project the traffic flow prediction result into the probability parameter space to realize the probability prediction of traffic flow.
[0061] The temporal convolutional network (TCN) is a general convolutional model for sequence modeling tasks, mainly composed of three parts: causal convolution, dilated convolution, and residual connection. Causal convolution ensures that the model follows the causality constraint, that is, information does not pass from the future back to the past. Dilated convolution enhances the model's ability to capture long - distance dependencies by expanding the receptive field of the convolution in an exponential manner. Among them, the TCN structure is known to those skilled in the art.
[0062] The gated recurrent unit (GRU) controls the flow of information by introducing two gating structures: the reset gate and the update gate, thereby establishing long-term dependencies. The reset gate of the GRU determines how much information needs to be discarded from the hidden state at the previous moment; the update gate controls how much information is retained from the current input and the hidden state h at the previous moment. t-1 Compared with the LSTM, the GRU does not have a separate internal state s, and the hidden state h is directly used to transmit information, so the computational cost is lower. Among them, the GRU structure is known to those skilled in the art.
[0063] The method of the present invention mainly integrates the dynamic time-domain encoding technology into the single-variable traffic flow probability prediction, which is manifested as that the single-variable traffic flow data input of the model enters the subsequent neural network after being expanded into a multi-dimensional sequence through dynamic time-domain encoding. After the single-variable traffic flow data input enters the dynamic time-domain encoding network, adaptive triangular position encoding is first performed. The adaptive triangular position encoding uses the neural network parameters as the parameters of the trigonometric function, and according to the time step index pos of the input traffic flow data, d sine and cosine position encodings with a length of T are respectively generated. The calculation formula is as follows:
[0064]
[0065] Among them, A θ , ω θ , and b θ are all learnable trigonometric function parameters, corresponding to the amplitude, frequency, phase and bias of the trigonometric function; pos represents the index of the time step, pos ∈ {1, 2,..., T}; the complete adaptive triangular position encoding is composed of the splicing of these two self-encodings:
[0066]
[0067] Among them, the concat function is the splicing function.
[0068] The learnable position encoding is a neural network parameter with a length of T and a dimension of c, which allows direct learning by the neural network. Its formula is as follows:
[0069]
[0070] Among them, Θ LPE represents the learnable position encoding neural network parameter.
[0071] The traffic flow data sample with a length of T is input into the linear expansion encoding module, and e scaled data are generated according to the scaling parameters learned by the neural network to reduce the influence of large variations between data samples. The calculation formula is:
[0072]
[0073] Among them, W LEE and b LEE are the parameters of the linearly extended coding neural network.
[0074] The above three encodings are concatenated with the single-variable input x (the original input flow data) to obtain a synthetic sequence. The calculation formula is as follows:
[0075]
[0076] Among them, the concatenation method and the synthetic sequence are as Figure 2 shown.
[0077] The synthetic sequence enters the TCN network for information fusion and temporal feature extraction. The calculation formula is as follows:
[0078]
[0079] Among them, f represents the output of the TCN network; g represents the dimension of the output of the TCN network.
[0080] The extracted information will enter the GRU network to predict the information h t of the flow data at the next time step t, where t ∈ {T + 1, T + 2,..., T + τ}.
[0081] Subsequently, the predicted information h t is input into the point prediction module. In the embodiment of the present invention, the point prediction module is a linear layer to obtain the numerical prediction x t at the next time step t. Subsequently, the above steps are repeated to recursively predict the information of length τ. The total recurrence calculation formula is as follows:
[0082] h t = GRU(f t-1 )
[0083] x t = W (x) h t + b (x)
[0084] f t = TCN([x t , ATPE t-T+1:t , LPE, LEE t-T+1:t )
[0085] Among them, W (x) and b (x) respectively represent the weight and bias of the linear layer, which are obtained by training; f t-1 represents the output of the TCN network at the current time step.
[0086] After all the target information of length τ has been predicted, the probability prediction module projects the information of all time steps into the parameter space of the probability distribution. Taking the Student's T distribution as an example, the distribution parameter calculation formula is as follows:
[0087] ν θ = 2 + softplus(W ν h + b ν )
[0088] μ θ = W μ h + b ν
[0089] σ θ = softplus(W σ h + b σ )
[0090] Among them, W ν , b ν , W μ , b ν , W σ and b σ are all neural network parameters of the probability prediction module; softplus represents the softplus function, h represents the traffic information of each time step, and the output of the final model is the parameter of the probability distribution. A probability distribution p θ (Y T+1:T+τ |ν θ , μ θ , σ θ ) can be constructed, where Y T+1:T+τ represents the random variable of τ time steps; ν θ , μ θ and σ θ are the probability distribution parameters output by the probability prediction module of the model; θ is the parameter of the traffic flow probability prediction neural network, including the above A θ , ω θ , b θ , Θ LPE , W LEE , b LEE , W (x) , b (x) , W ν , b ν , W μ , b ν , W σ and b σ etc. The complete architecture diagram of the model is as shown in Figure 1 .
[0091] The model parameters are learned through the backpropagation mechanism. Preferably, in the embodiments of the present invention, the loss function used is the negative log-likelihood function of the probability prediction distribution of the model and the true value (i.e., the label: the AC traffic flow data at τ prediction time steps), and this function can measure the deviation between the predicted probability distribution and the true value. Assuming that the output value (the probability prediction distribution output by the probability prediction module) conforms to the Student's T distribution, the probability density formula of this distribution is as follows:
[0092]
[0093] In the formula, ν is the degree of freedom of the Student's T distribution, μ is the mean of the Student's T distribution, and σ is the standard deviation of the Student's T distribution. Then the calculation formula of the loss function is as follows:
[0094] L(θ) = -logf StudentT (ν θ , μ θ , σ θ , x T:T+τ-1 ; θ)
[0095] In the formula, x T:T+τ-1 is the target moment data of length τ in the sample, that is, the AC traffic flow data at τ prediction time steps, θ is the parameter of the traffic flow probability prediction neural network, and ν θ , μ θ and σ θ are the probability distribution parameters output by the probability prediction module of the model.
[0096] After obtaining the probability distribution corresponding to each prediction time step, it further includes:
[0097] Sampling the probability distribution of each time step K times, and obtaining a set of point sets for each time step; using quantiles to describe each point set to represent the prediction result. In the present invention, the 10th percentile, the 25th percentile, the 75th percentile, and the 90th percentile are used to plot on the coordinate axis to describe the prediction result. The entire prediction process is as Figure 3 shown.
[0098] The model constructed by the present invention is trained on the San Francisco highway traffic flow dataset, and the dataset information is shown in Table 1:
[0099] Table 1 Dataset attributes used in the embodiments of the present invention
[0100]
[0101] The model is constructed using the PyTorch library, and the hyperparameters in the model are determined through multiple experiments. The batch_size of the training set is set to 32, and the batch_size of the test set is set to 1. The learning rate is set to 0.001, and the mean squared error continuous ranked probability score (CRPS), q-percentage coverage rate, mean absolute percentage error (MAPE), and mean absolute scaled error (MASE) are used to measure the prediction effect of the model.
[0102] Table 2 presents various metrics obtained by existing models (Timegrad, DeepAR, TFT) and the model constructed in the embodiment of the present invention on the traffic flow dataset.
[0103] Table 2 Comparison of Metrics between the Model in the Embodiment of the Present Invention and the Benchmark Model on the Traffic Flow Dataset
[0104]
[0105]
[0106] The results show that the model of the present invention has achieved the optimal values in all metrics, and the prediction accuracy has been significantly improved. Among them, CRPS is the most important metric. Compared with the CRPS score of the second-best model, the score of the model of the present invention is 1.83% lower. In addition, in terms of the coverage rate metric, the model in the embodiment of the present invention is also the best. From the perspectives of the two metrics of MASE and MAPE for evaluating the prediction effect, the model in the embodiment of the present invention also achieves the optimal performance.
[0107] Further analysis shows that the traffic flow dataset has strong periodicity. The model of the present invention introduces the DTE network, which can emphasize the positions of traffic flow data points in the sequence and learn the hidden patterns from the traffic flow dataset, which is not available in existing traffic flow prediction methods. Therefore, the present invention can well capture the time series information and make predictions, solve the difficulty of capturing features in univariate traffic flow data by deep learning-based traffic flow prediction methods, and accurately give the probability distribution range of the future trend of traffic flow, and give a general direction judgment on future traffic flow data.
[0108] In the embodiments of the present invention, dynamic time encoding (DTE) is deeply integrated into the univariate traffic flow prediction method. As an information enhancement network for model input, the dynamic time encoding network can perform adaptive triangular position encoding, learnable position encoding, and linear expansion encoding on the original traffic flow data during the prediction process. The generated position encoding information representing the traffic flow data enters the temporal convolutional network (TCN) together with the original data to obtain the fused traffic flow information. The fused traffic flow information is input into the gated recurrent unit (GRU) to predict the traffic flow information at the next time step. The traffic flow information at the next time step is used to calculate the traffic flow at this time point through a linear neural network and is concatenated with the segmented traffic flow data points. All the predicted traffic flow information is input into the probability layer to obtain the future traffic flow probability prediction result. The dynamic time encoding (DTE) designed by the present invention breaks the position symmetry of the traffic flow time series, increases the relative position information, and overcomes the defect that it is difficult to accurately predict the traffic flow in the traditional univariate traffic flow prediction model due to the lack of temporal information.
[0109] Embodiment 2
[0110] The embodiments of the present invention provide a traffic flow probability prediction method based on dynamic time encoding, mainly including:
[0111] Input the traffic flow data of T historical time steps including the current time step into the trained traffic flow probability prediction model to obtain the alternating current flow data of τ prediction time steps; wherein, the traffic flow probability prediction model is constructed by the construction method of the traffic flow probability prediction model based on dynamic time encoding in Embodiment 1.
[0112] For related technical solutions, refer to the description in Embodiment 1 and will not be elaborated here.
[0113] Embodiment 3
[0114] The embodiments of the present invention provide an electronic device, including a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements the steps of the construction method of the traffic flow probability prediction model based on dynamic time encoding in Embodiment 1 above, or implements the steps of the traffic flow probability prediction method based on dynamic time encoding in Embodiment 2 above.
[0115] The electronic device can be a computing device such as a desktop computer, a notebook, a palm computer, and a cloud server. The so-called processor can be a Central Processing Unit (CPU), or can also be other general-purpose processors, Digital Signal Processors (DSPs), Application-Specific Integrated Circuits (ASICs), Field-Programmable Gate Arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The memory can be used to store computer programs and / or modules. The processor realizes various functions of the electronic device by running or executing the computer programs and / or modules stored in the memory, and by calling the data stored in the memory.
[0116] The related technical solutions are the same as above and will not be elaborated here.
[0117] Embodiment 4
[0118] The embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements the steps of the method for constructing a traffic flow probability prediction model based on dynamic time-domain coding in Embodiment 1 above, or implements the steps of the traffic flow probability prediction method based on dynamic time-domain coding in Embodiment 2 above.
[0119] Specifically, the memory can include high-speed random access memory, and can also include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, at least one magnetic disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0120] The related technical solutions are the same as above and will not be elaborated here.
[0121] Embodiment 5
[0122] The embodiment of the present application provides a computer program product, including a computer program. When the computer program runs on a computer, it causes the computer to execute the steps of the method for constructing a traffic flow probability prediction model based on dynamic time-domain coding in Embodiment 1 above, or execute the steps of the traffic flow probability prediction method based on dynamic time-domain coding in Embodiment 2 above.
[0123] The related technical solutions are the same as above and will not be elaborated here.
[0124] Those skilled in the art can easily understand that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims
1. A method for constructing a traffic flow probability prediction model based on dynamic time domain coding, characterized in that: include: Constructing a traffic flow probability prediction model, and using a training sample set to train the traffic flow probability prediction model, the training sample is traffic flow data including T historical time steps and AC flow data of τ prediction time steps, and the training sample is data after slicing traffic flow data collected from a single traffic flow sensor; The traffic flow probability prediction model includes: A dynamic time-domain coding network, comprising an adaptive triangular position coding module for generating d-segment sine function position coding and d-segment cosine function position coding according to input traffic flow data containing T historical time steps, and a learnable position coding module whose network parameters are a segment of position coding containing a length of T and a dimension of c; wherein the network parameters of the adaptive triangular position coding module and the learnable position coding module are learnable network parameters, which are obtained by learning in model training; A splicing network, used for splicing the sine function position code, the cosine function position code, the position code of the learnable position code module and the traffic flow data containing T historical time steps into a synthetic sequence of 2d+c+1 dimensions; A probability prediction network is used to obtain probability distribution parameters corresponding to τ time steps based on the synthetic sequence; wherein the probability distribution parameters constitute the corresponding probability distribution.
2. The method for constructing a traffic flow probability prediction model according to claim 1, characterized in that: The probability prediction network includes a temporal convolutional network layer, a gated recurrent unit layer, and a post-processing network layer; The temporal convolutional network layer is used to extract features of the synthetic sequence; The gated recurrent unit layer is used to predict the traffic flow information at the next time step t based on the features of the synthetic sequence, t∈{T+1, T+2, …, T+τ}; The post-processing network layer includes a point prediction module and a probability prediction module; the point prediction module is used to predict the traffic flow data value of the next time step t based on the traffic flow information of the next time step t, and to combine it with the traffic flow sample data of the most recent T-1 time step to form traffic flow data of length T and input it into the dynamic time domain coding network for the next repetition until it is repeated τ times; the probability prediction module is used to predict the corresponding probability distribution parameters according to the traffic flow information of the next time step t, and finally obtain the probability distribution parameters corresponding to τ time steps; wherein, the probability distribution parameters constitute the corresponding probability distribution.
3. The method for constructing a traffic flow probability prediction model according to claim 1 or 2, characterized in that: The dynamic time domain coding network also includes a linear expansion coding module; The linear expansion coding module is used to scale the traffic flow data containing T historical time steps to generate e segments of linear expansion coding; the network parameters of the linear expansion coding module are learnable network parameters, which are obtained by learning in model training; Correspondingly, the splicing network is also used to splice the sine function position coding, the cosine function position coding, the position coding of the learnable position coding module, the linear expansion coding and the traffic flow data containing T historical time steps into a synthetic sequence of 2d+c+e+1 dimensions.
4. The method for constructing a traffic flow probability prediction model according to claim 3, characterized in that: The calculation formula of the adaptive triangular position encoding module is: Among them, ATPE sin and ATPE cos A represents the position coding of d-segment sine function and d-segment cosine function respectively; θ ,ω θ , and b θ are all learnable network parameters, corresponding to the amplitude, frequency, phase and bias of trigonometric functions; pos represents the index of the time step, pos∈{1, 2,…, T}; The learnable position encoding module is: Among them, Θ LPE Representing network parameters of the learnable position encoding module; The calculation formula of the linear expansion coding module is: Among them, W LEE and b LEE are network parameters of the linear expansion coding module.
5. The method for constructing a traffic flow probability prediction model according to claim 1 or 2, characterized in that: The samples in the dataset are generated as follows: The traffic flow data collected from a single traffic flow sensor is sliced by using a long-time random sampling method to obtain N traffic flow data sequences of length L as N samples; each sample includes traffic flow data of T historical time steps and traffic flow data of τ predicted time steps, L = T + τ.
6. The method for constructing a traffic flow probability prediction model according to claim 1 or 2, characterized in that: After obtaining the probability distribution of each time step, it also includes: The probability distribution of each time step is sampled K times to obtain a set of points corresponding to each time step; quantiles are used to describe each point set to represent the traffic flow probability distribution prediction result.
7. A traffic flow probability prediction method based on dynamic time domain coding, characterized in that: include: The traffic flow data of T historical time steps including the current time step are input into the trained traffic flow probability prediction model to obtain the traffic flow data of τ prediction time steps; wherein the traffic flow probability prediction model is constructed by the traffic flow probability prediction model construction method described in any one of claims 1-6.
8. An electronic device, characterized in that: comprising a computer readable storage medium and a processor; The computer-readable storage medium is used to store executable instructions; The processor is used to read the executable instructions stored in the computer-readable storage medium to execute the traffic flow probability prediction model construction method described in any one of claims 1-6, or to execute the traffic flow probability prediction method described in claim 7.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method for constructing a traffic flow probability prediction model as described in any one of claims 1 to 6 is implemented, or the method for predicting traffic flow probability as described in claim 7 is implemented.
10. A computer program product, characterized in that It includes a computer program, which, when running on a computer, enables the computer to execute the traffic flow probability prediction model construction method described in any one of claims 1 to 6, or execute the traffic flow probability prediction method described in claim 7.