A flow determination method, device, equipment and medium based on spatiotemporal data
By introducing spatiotemporal feature layer and self-attention mechanism into the spatiotemporal network model, the problem of poor feature extraction effect in the space-time domain in the prior art is solved, and accurate prediction of the traffic in the target area is achieved.
Patent Information
- Application Number
- CN202210470739.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-28
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2042-04-28
AI Technical Summary
The existing network model has poor feature extraction effect in the space-time field, ignoring the characteristics of space-time data, resulting in poor results.
A traffic determination method based on spatiotemporal data is designed, and the historical traffic data in the target area is analyzed through a preset spatiotemporal network model, and the spatiotemporal feature layer and self-attention mechanism are used to extract spatiotemporal features to accurately predict traffic data in the target area.
This method can accurately determine the relationship between flow changes in each region and historical flow, and the flow flow relationship between different regions, thereby achieving accurate prediction of the traffic in the target region.
Smart Images

Figure CN114862010B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, equipment and medium for determining flow based on spatiotemporal data. Background Art
[0002] In recent years, deep learning has achieved great success in natural language processing and computer vision. These successes rely on the development of big data and hardware computing power on the one hand, and on the development of neural network architecture on the other. In specific application scenarios, such as target detection, many targeted and customized feature extraction network models have been developed. However, there are few targeted network models in the spatiotemporal field, and the existing network models extract features by borrowing from models in other fields. These models often ignore the characteristics of spatiotemporal data, so the results are unsatisfactory. Summary of the invention
[0003] In order to solve the above technical problem or at least partially solve the above technical problem, the embodiments of the present invention provide a method, apparatus, device and medium for determining flow based on spatiotemporal data.
[0004] In a first aspect, an embodiment of the present invention provides a method for determining traffic based on spatiotemporal data, comprising: obtaining first historical traffic data in a target area; inputting the historical traffic data as input data into a preset spatiotemporal network model to obtain target traffic data of the target area within a target time period; wherein the preset spatiotemporal network model includes a spatiotemporal feature layer, the spatiotemporal feature layer obtains multiple convolutional features of the historical traffic data through convolution kernels of multiple scales, and determines the spatiotemporal features of the historical traffic data from the multiple convolutional features through a self-attention mechanism, so that the preset spatiotemporal network model determines the target traffic data of the target area within the target time period based on the spatiotemporal features.
[0005] In an optional embodiment, the method further includes: when the preset spatiotemporal network model includes multiple adjacent spatiotemporal feature layers, inputting the output data of a previous spatiotemporal feature layer among the multiple adjacent spatiotemporal feature layers into a subsequent spatiotemporal feature layer to determine the spatiotemporal characteristics of the output data.
[0006] In an optional embodiment, the method further includes: when the preset spatiotemporal network model also includes a first convolutional layer, inputting the historical traffic data into the first convolutional layer, obtaining high-dimensional features of the historical traffic data, and inputting the high-dimensional features into the spatiotemporal feature layer.
[0007] In an optional embodiment, the method further includes: when the preset spatiotemporal network model also includes a second convolutional layer, inputting the spatiotemporal features into the second convolutional layer, and downsampling the spatiotemporal features to obtain target traffic data of the target area within a target time period.
[0008] In an optional embodiment, the method also includes training to obtain the preset spatiotemporal network model according to the following steps: gridding the training area to determine multiple grid areas; for each of the grid areas, obtaining the second historical traffic data of the grid area in multiple time periods; splicing the second historical traffic data of the multiple grid areas in the same time period to obtain the second traffic characteristic data of the same time period; obtaining a historical traffic sequence based on the second traffic characteristic data in the multiple time periods, and using the historical traffic sequence as a training data set; training the training data set to obtain the preset spatiotemporal network model.
[0009] In an optional embodiment, training the training data set to obtain the preset spatiotemporal network model includes: determining the size of a sliding window; extracting input samples from the historical traffic sequence using the sliding window, the data volume of the input samples being consistent with the size of the sliding window; extracting output samples from the historical traffic sequence based on the extracted input samples, the output samples serving as labels corresponding to the input samples; and training based on the input samples and the labels to obtain the preset spatiotemporal network model.
[0010] In an optional embodiment, determining the size of the sliding window includes: determining the size of the sliding window to be N;
[0011] Extracting input samples from the historical traffic sequence using the sliding window includes: determining a starting time; extracting historical traffic data corresponding to the starting time from the historical traffic sequence, and extracting historical traffic data corresponding to (N-1) moments before the starting time, and using the historical traffic data corresponding to the starting time and the historical traffic data corresponding to (N-1) moments before the starting time as input samples;
[0012] Extracting output samples from the historical traffic sequence according to the extracted input samples includes: extracting historical traffic data corresponding to a next moment after the starting moment from the historical traffic sequence as output samples.
[0013] In an optional embodiment, obtaining the first historical traffic data in the target area includes: rasterizing the target area to determine a plurality of grid areas; for each of the grid areas, obtaining the first historical traffic data of the grid area; determining the first traffic characteristic data of the target area based on the first historical traffic data of each of the grid areas; inputting the historical traffic data as input data into a preset space-time network model includes: inputting the first traffic characteristic data of the target area as input data into a preset space-time network model.
[0014] In a second aspect, an embodiment of the present invention provides a flow determination device based on spatiotemporal data, comprising: an acquisition module for acquiring first historical flow data in a target area; a determination module for inputting the historical flow data as input data into a preset spatiotemporal network model to obtain target flow data of the target area within a target time period; wherein the preset spatiotemporal network model includes at least one spatiotemporal feature layer, the spatiotemporal feature layer obtains multiple convolution features of the historical flow data through convolution kernels of multiple scales, and determines the spatiotemporal features of the historical flow data from the multiple convolution features through a self-attention mechanism, so that the preset spatiotemporal network model determines the target flow data of the target area within the target time period based on the spatiotemporal features.
[0015] In an optional embodiment, the determination module is also used to: when the preset spatiotemporal network model includes multiple adjacent spatiotemporal feature layers, input the output data of a previous spatiotemporal feature layer among the multiple adjacent spatiotemporal feature layers into a subsequent spatiotemporal feature layer to determine the spatiotemporal characteristics of the output data.
[0016] In an optional embodiment, the determination module is also used to: when the preset spatiotemporal network model also includes a first convolutional layer, input the historical traffic data into the first convolutional layer, obtain high-dimensional features of the historical traffic data, and input the high-dimensional features into the spatiotemporal feature layer.
[0017] In an optional embodiment, the determination module is also used to: when the preset spatiotemporal network model also includes a second convolutional layer, input the spatiotemporal features into the second convolutional layer, and downsample the spatiotemporal features to obtain the target traffic data of the target area within the target time period.
[0018] In an optional embodiment, the device also includes a training module, which is used to: grid-divide the training area to determine multiple grid areas; for each of the grid areas, obtain the second historical traffic data of the grid area in multiple time periods; splice the second historical traffic data of the multiple grid areas in the same time period to obtain the second traffic characteristic data of the same time period; obtain a historical traffic sequence based on the second traffic characteristic data in the multiple time periods, and use the historical traffic sequence as a training data set; train the training data set to obtain the preset spatiotemporal network model.
[0019] In an optional embodiment, the training module is also used to: determine the size of the sliding window; use the sliding window to extract input samples from the historical traffic sequence, and the data volume of the input samples is consistent with the size of the sliding window; based on the extracted input samples, extract output samples from the historical traffic sequence, and the output samples serve as labels corresponding to the input samples; and perform training based on the input samples and the labels to obtain the preset spatiotemporal network model.
[0020] In an optional embodiment, the training module is also used to determine the size of the sliding window as N; determine the starting time; extract the historical traffic data corresponding to the starting time from the historical traffic sequence, and extract the historical traffic data corresponding to the (N-1) moments before the starting time, and use the historical traffic data corresponding to the starting time and the historical traffic data corresponding to the (N-1) moments before the starting time as input samples; extract the historical traffic data corresponding to the next moment after the starting time from the historical traffic sequence as an output sample.
[0021] In an optional embodiment, the acquisition module is also used to: grid-divide the target area to determine multiple grid areas; for each of the grid areas, obtain the first historical flow data of the grid area; determine the first flow characteristic data of the target area based on the first historical flow data of each of the grid areas; and input the historical flow data as input data into a preset space-time network model, including: inputting the first flow characteristic data of the target area as input data into a preset space-time network model.
[0022] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; the memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform the following steps: obtaining first historical traffic data in a target area; inputting the historical traffic data as input data into a preset spatiotemporal network model to obtain target traffic data of the target area within a target time period; wherein the preset spatiotemporal network model includes at least one spatiotemporal feature layer, and the spatiotemporal feature layer obtains multiple convolution features of the historical traffic data through convolution kernels of multiple scales, and determines the spatiotemporal features of the historical traffic data from the multiple convolution features through a self-attention mechanism, so that the preset spatiotemporal network model determines the target traffic data of the target area within the target time period based on the spatiotemporal features.
[0023] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the method for determining flow based on spatiotemporal data according to an embodiment of the present invention is implemented.
[0024] One or more technical solutions in the above embodiments have at least some or all of the following advantages:
[0025] The historical traffic data in the target area is analyzed through a preset spatiotemporal network model to determine the target traffic data of the target area within the target time period, wherein the preset spatiotemporal network model includes a spatiotemporal feature layer, and the spatiotemporal feature layer includes convolution kernels of multiple scales, so as to provide receptive fields of different sizes for different areas, and use the attention mechanism to dynamically select receptive fields for each area, which can accurately determine the relationship between the traffic changes and historical traffic in each area and determine the relationship between the traffic flows between different areas, so as to accurately predict the traffic in the target area. The traffic determination method based on spatiotemporal data of the embodiment of the present invention can monitor, predict and control the traffic at the city level, provide more accurate passenger flow prediction, thereby realizing more refined control schemes and more refined urban planning; the method can be applied to the discovery of dense traffic areas in cities, advertising placement, dynamic advertising space pricing and other scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0027] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or related technical descriptions are briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0028] Figure 1 A schematic diagram schematically shows a spatiotemporal feature layer of a spatiotemporal network model according to an embodiment of the present invention;
[0029] Figure 2 The schematic diagram of the structure of the spatiotemporal network model of the embodiment of the present invention is schematically shown;
[0030] Figure 3 A schematic diagram schematically shows the main steps of the method for training a spatiotemporal network model according to an embodiment of the present invention;
[0031] Figure 4 A flowchart schematically shows the sub-steps of the method for training a spatiotemporal network model according to an embodiment of the present invention;
[0032] Figure 5 The flowchart of the flow determination method based on spatiotemporal data according to an embodiment of the present invention is schematically shown;
[0033] Figure 6 The structure diagram of the flow determination device based on spatiotemporal data according to an embodiment of the present invention is schematically shown;
[0034] Figure 7 The system architecture of the flow determination method based on spatiotemporal data applicable to the embodiment of the present invention is schematically shown;
[0035] Figure 8 The structural block diagram of an electronic device provided by an embodiment of the present invention is schematically shown. DETAILED DESCRIPTION
[0036] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0037] In the field of spatiotemporal prediction, neural networks can currently be used to model spatiotemporal data. For example, residual neural networks can be introduced in ST-ResNet to extract spatiotemporal features. Among them, spatiotemporal features include features of two dimensions: temporal dependency and spatial dependency. Temporal dependency refers to the relationship between traffic changes and historical traffic in each area, and spatial dependency refers to the relationship between traffic flows between different areas. In residual neural networks, fixed-size receptive fields are used, such as 3*3, 5*5, etc., and parameters of spatial positions are shared, which has spatial invariance. However, in the field of spatiotemporal prediction, application scenarios do not satisfy this spatial invariance relationship. For example, in the scenario of predicting traffic, changes in traffic and changes in traffic flow will be affected by residents' activities, such as the impact of residents' daily travel. Therefore, the relationship between traffic in different urban areas and surrounding areas is different, and it does not have spatial invariance. In addition, the use of fixed-size receptive fields does not reflect the differences between different regions. For example Figure 1 As shown in the figure, the traffic flow of a city is analyzed, and the Pearson correlation coefficient of the traffic flow in different areas is calculated for a period of time. Two areas of the city are selected for comparison with other areas. The results are shown in the figure. Figure 1 As shown in the figure, the traffic at different locations in the city is quite different, and the relationship between different locations and the surrounding areas is different. Therefore, using only convolutional neural networks cannot model spatiotemporal data well.
[0038] In order to solve the above technical problems or at least partially solve the above technical problems, an embodiment of the present invention provides a traffic determination method based on spatiotemporal data, which analyzes the historical traffic data in the target area through a preset spatiotemporal network model to determine the target traffic data of the target area within the target time period, wherein the preset spatiotemporal network model includes a spatiotemporal feature layer, which includes convolution kernels of multiple scales, so as to provide receptive fields of different sizes for different areas, and use an attention mechanism to dynamically select a receptive field for each area, which can accurately determine the relationship between the traffic changes and historical traffic in each area and determine the relationship between the traffic flows between different areas, thereby accurately predicting the traffic in the target area.
[0039] The spatiotemporal network model of the embodiment of the present invention includes a spatiotemporal feature layer, which is mainly used to solve the problem of inconsistent receptive fields at different locations. For the same area, the spatiotemporal feature layer first uses different convolution kernels to extract spatiotemporal features, and then uses an attention mechanism to automatically select effective features for the feature results extracted in this area, thereby extracting the spatiotemporal features of the spatiotemporal data, so as to achieve the use of different convolution kernels for different areas, that is, to achieve the use of different receptive fields for different areas to extract spatiotemporal features. Among them, spatiotemporal data is data with both time and space dimensions, such as pedestrian flow data and vehicle flow data in a city. To facilitate the understanding of the spatiotemporal network model in the embodiment of the present invention, the following is an example of a spatiotemporal network model. Figure 1 Take as an example the spatiotemporal network model of the present invention is described.
[0040] Figure 1 The structure diagram of the spatiotemporal feature layer of the spatiotemporal network model of the embodiment of the present invention is schematically shown. Figure 1 In , H and W represent the number of grids in the longitude and latitude directions after the area is rasterized. c and c' represent the number of channels of the flow in the area, such as inflow, outflow, and resident flow. K1 and K2 represent the sizes of different convolution kernels, such as 3*3, 5*5, 7*7, etc. Figure 1 As shown, this embodiment uses two convolution kernels of different sizes to extract spatiotemporal features for two different regions within the original range, and the size of the convolution kernel is dynamically selected through a self-attention mechanism.
[0041] Combination Figure 1 The implementation process of the spatiotemporal feature layer of the spatiotemporal network model of the embodiment of the present invention is as follows:
[0042] First, this embodiment sets a convolution kernel set K = {3*3, 5*5, 7*7, 9*9, 11*11} of various scales. Then, for the input feature map X of the original region, at each position (x i ,y j ), using different convolution kernels to calculate the feature map:
[0043] f3|=Conv3(X);
[0044] f5|=Conv5(X);
[0045] f7|=Conv7(X);
[0046] f9|=Conv9(X);
[0047] f 11 |=Conv 11 (X).
[0048] Therefore, for a given position (x i ,y j ), and obtained the convolution features under the action of convolution kernels of different scales k=3, 5, 7, 9, 11.
[0049] After obtaining multiple convolutional features, the spatiotemporal feature layer uses the self-attention mechanism to select effective features from the multiple convolutional features. The specific process is as follows:
[0050]
[0051]
[0052]
[0053]
[0054] Among them, W k It is a learnable parameter matrix used to increase the capacity of the spatiotemporal network model and can model complex relationships. k1 and k2 are the sizes of the convolution kernels. is the feature after mapping, It calculates the correlation between the output features of two different convolution kernels. Softmax() is a normalization function. is the normalized weight, s i,j It is the features fused by different convolution kernels, that is, the spatiotemporal features.
[0055] In summary, for the same area, the spatiotemporal network model of the embodiment of the present invention first uses different convolution kernels to extract spatiotemporal features in the spatiotemporal feature layer, and then uses an attention mechanism to automatically select effective features for the feature results extracted in this area, thereby extracting the spatiotemporal features of the spatiotemporal data, thereby realizing the use of different convolution kernels for different areas, that is, realizing the use of different receptive fields for different areas to extract spatiotemporal features, which reflects the differences between different areas and fully considers the characteristics of spatiotemporal data.
[0056] In an optional embodiment, the spatiotemporal network model of the embodiment of the present invention may include one spatiotemporal feature layer, or may include multiple adjacent spatiotemporal feature layers, in which the output data of the previous spatiotemporal feature layer is the input data of the next spatiotemporal feature layer. In this embodiment, in order to fully consider the relationship between sub-regions that are far apart in the original region, multiple adjacent spatiotemporal feature layers may be used.
[0057] In an optional embodiment, the spatiotemporal network model of the embodiment of the present invention may include a first convolutional layer and a second convolutional layer in addition to the spatiotemporal feature layer. Figure 2As shown, the spatiotemporal network model includes a first convolutional layer, two spatiotemporal feature layers and a second convolutional layer. Among them, the first convolutional layer is used to extract high-dimensional features, that is, to extract the high-dimensional features of the original input data, and then the spatiotemporal feature layer extracts the spatiotemporal features, and the second convolutional layer performs a dimensionality reduction operation on the spatiotemporal features to obtain the results to be predicted. This embodiment reduces the amount of calculation and improves efficiency while improving the accuracy of the model through the first convolutional layer and the second convolutional layer.
[0058] In order to obtain the above-mentioned spatiotemporal network model, it is necessary to obtain training samples for training. As an example, the training process of the spatiotemporal network model is as follows: Figure 3 As shown, the process includes:
[0059] Step S301: gridding the training area to determine a plurality of grid areas;
[0060] Step S302: for each of the grid areas, obtaining second historical traffic data of the grid area in multiple time periods;
[0061] Step S303: splicing the second historical flow data of the plurality of grid areas in the same time period to obtain the second flow characteristic data of the same time period;
[0062] Step S304: obtaining a historical traffic sequence according to the second traffic characteristic data in the multiple time periods, and using the historical traffic sequence as a training data set;
[0063] Step S305: training the training data set to obtain the preset spatiotemporal network model.
[0064] In the process of training the spatiotemporal network model, it is first necessary to obtain training sample data. In this embodiment, the training area is rasterized to obtain multiple grid areas. The training area can be a city or an area in a city. Furthermore, the training area can be a target area, can include the target area, or can be contained in the target area (that is, the training area is in the target area). When the training area and the target area have the same range, the spatiotemporal network model obtained by training is most accurate in predicting the traffic in the target area. After obtaining multiple grid areas, the second historical traffic data x∈R of each grid area is counted. n×m×f , m and n represent the length and width of the grid area respectively, and f represents the flow characteristics of each grid area, such as the resident flow, inflow flow, and outflow flow of the grid area. In this embodiment, the flow characteristics of the grid area can be counted with a time step of 30 minutes. For a given grid area D ij , count the inflow flow in time segment t (within half an hour): at time t-1, it is not in grid area D ijAt time t, in the grid area D ij Statistical outflow flow in time segment t (within half an hour): at time t-1 in grid area D ij At time t, it is not in the grid area D ij Statistical time segment t (within half an hour) of the resident flow: t-1 time in the grid area D ij At time t, it is also in the grid area D ij After determining the second historical traffic data of each grid area, the second historical traffic data of multiple grid areas in the same time period are spliced to obtain the second traffic characteristic data of the same time period (the traffic characteristic data includes time dependence and space dependence). For example, the second historical traffic data of multiple grid areas at time t are spliced to obtain X t , concatenate the second historical traffic data at time t+1 to get X t+1 , thus obtaining the historical traffic sequence {X1, X2, …, X t , X t+1 Then, the historical traffic sequence is used as a training data set for training to obtain the spatiotemporal network model.
[0065] Specifically, Figure 4 As shown, the process of training the spatiotemporal network model by using the historical traffic sequence as a training data set includes:
[0066] Step S401: Determine the size of the sliding window;
[0067] Step S402: extracting input samples from the historical traffic sequence using the sliding window, wherein the data volume of the input samples is consistent with the size of the sliding window;
[0068] Step S403: extracting output samples from the historical traffic sequence according to the extracted input samples, and the output samples are used as labels corresponding to the input samples;
[0069] Step S404: Perform training based on the input samples and the labels to obtain the preset spatiotemporal network model.
[0070] After obtaining the historical traffic sequence, construct input samples and output samples of the spatiotemporal network model based on the historical traffic sequence. Specifically, this embodiment adopts a sliding window method to construct training samples. More specifically, the process includes: setting the size of the sliding window to N, that is, the size of the sliding window is N; determining the starting time; extracting the historical traffic data corresponding to the starting time from the historical traffic sequence, and extracting the historical traffic data corresponding to the (N-1) moments before the starting time, and using the historical traffic data corresponding to the starting time and the historical traffic data corresponding to the (N-1) moments before the starting time as input samples; extracting the historical traffic data corresponding to the next moment after the starting time from the historical traffic sequence as output samples. For example, extracting data with a historical length of N as training data at time t, and making a prediction for the next step in the future, then:
[0071]
[0072] Among them, X t ,X t-1 ,…,X t-N+1 represents the input sample, X t+1 Represents the output sample, that is, the label.
[0073] After constructing the input and output samples, the BP algorithm is used for training to learn the parameters in the network. The BP algorithm (Error Back Propagation) consists of two processes: forward propagation of signals and back propagation of errors. It is expected to adaptively adjust the connection weights between neurons during the training process of the neural network to find the best mapping function between input and output, so that the objective function or loss function is minimized and tasks such as classification and regression are completed.
[0074] After obtaining the above-mentioned spatiotemporal network model, the spatiotemporal network model can be used to predict the target traffic data of the target area within the target time period. For example, using a sliding window, the historical traffic characteristics of the last period of time are proposed: Input = (X L ,X L-1 ,…,X L-N+1 ), and then use the trained spatiotemporal network model to make predictions to obtain the target flow data of the target area predicted by the spatiotemporal network model in the target time period. In an optional embodiment, when predicting the flow data of the target area, the input data of the spatiotemporal network model may not be obtained from the second historical flow data.
[0075] Specifically, Figure 5 As shown in FIG. 1 , the process of using the spatiotemporal network model to predict the traffic flow in the target area includes:
[0076] Step S501: Acquire first historical traffic data in a target area, wherein the traffic data includes resident traffic, inflow traffic, and outflow traffic.
[0077] Step S502: Input the historical traffic data as input data into a preset spatiotemporal network model to obtain the target traffic data of the target area within the target time period; wherein the preset spatiotemporal network model includes a spatiotemporal feature layer, and the spatiotemporal feature layer obtains multiple convolution features of the historical traffic data through convolution kernels of multiple scales, and determines the spatiotemporal features of the historical traffic data from the multiple convolution features through a self-attention mechanism, so that the preset spatiotemporal network model determines the target traffic data of the target area within the target time period according to the spatiotemporal features.
[0078] Among them, the process of obtaining the first historical flow data in the target area may include rasterizing the target area to determine multiple grid areas; for each of the grid areas, obtaining the first historical flow data of the grid area; based on the first historical flow data of each of the grid areas, determining the first flow characteristic data of the target area, and inputting the first flow characteristic data of the target area as input data into a preset spatiotemporal network model to obtain a prediction result, that is, the target flow data of the target area within the target time period.
[0079] In the application scenario of this embodiment, the predicted traffic data is spatiotemporal data, which has particularity. The relationship between the traffic change and historical traffic in each area, as well as the relationship between traffic flows in different areas are different. Therefore, if the spatiotemporal network model is trained with the historical traffic data of the target area as training data, the effect of the spatiotemporal network model in predicting the traffic in the target area is better than predicting the traffic in other areas. If it is necessary to predict the traffic in other areas, the spatiotemporal network model needs to be transferred for learning.
[0080] Figure 6 The schematic diagram schematically shows the main modules of the flow determination device 600 based on spatiotemporal data according to an embodiment of the present invention, as shown in FIG. Figure 6 As shown, the flow determination device 600 based on spatiotemporal data includes:
[0081] An acquisition module 601 is used to acquire first historical traffic data in a target area;
[0082] Determination module 602 is used to input the historical traffic data as input data into a preset spatiotemporal network model to obtain the target traffic data of the target area within the target time period; wherein the preset spatiotemporal network model includes at least one spatiotemporal feature layer, the spatiotemporal feature layer obtains multiple convolution features of the historical traffic data through convolution kernels of multiple scales, and determines the spatiotemporal features of the historical traffic data from the multiple convolution features through a self-attention mechanism, so that the preset spatiotemporal network model determines the target traffic data of the target area within the target time period based on the spatiotemporal features.
[0083] The flow determination device based on spatiotemporal data of an embodiment of the present invention analyzes the historical flow data in the target area through a preset spatiotemporal network model to determine the target flow data of the target area within the target time period, wherein the preset spatiotemporal network model includes a spatiotemporal feature layer, and the spatiotemporal feature layer includes convolution kernels of multiple scales, so as to provide receptive fields of different sizes for different areas, and use the attention mechanism to dynamically select the receptive field for each area, which can accurately determine the relationship between the flow changes and historical flow of each area and determine the relationship between the flow flows between different areas, thereby accurately predicting the flow of the target area.
[0084] In an optional embodiment, the determination module is also used to: when the preset spatiotemporal network model includes multiple adjacent spatiotemporal feature layers, input the output data of a previous spatiotemporal feature layer among the multiple adjacent spatiotemporal feature layers into a subsequent spatiotemporal feature layer to determine the spatiotemporal characteristics of the output data.
[0085] In an optional embodiment, the preset spatiotemporal network model also includes a first convolutional layer; the determination module is also used to: input the historical traffic data into the first convolutional layer, obtain high-dimensional features of the historical traffic data, and input the high-dimensional features into the spatiotemporal feature layer.
[0086] In an optional embodiment, the preset spatiotemporal network model also includes a second convolutional layer; the determination module is also used to: input the spatiotemporal features into the second convolutional layer, and downsample the spatiotemporal features to obtain target traffic data of the target area within the target time period.
[0087] In an optional embodiment, the device also includes a training module, which is used to: grid-divide the training area to determine multiple grid areas; for each of the grid areas, obtain the second historical traffic data of the grid area in multiple time periods; splice the second historical traffic data of the multiple grid areas in the same time period to obtain the second traffic characteristic data of the same time period; obtain a historical traffic sequence based on the second traffic characteristic data in the multiple time periods, and use the historical traffic sequence as a training data set; train the training data set to obtain the preset spatiotemporal network model.
[0088] In an optional embodiment, the training module is also used to: determine the size of the sliding window; use the sliding window to extract input samples from the historical traffic sequence, and the data volume of the input samples is consistent with the size of the sliding window; based on the extracted input samples, extract output samples from the historical traffic sequence, and the output samples serve as labels corresponding to the input samples; and perform training based on the input samples and the labels to obtain the preset spatiotemporal network model.
[0089] In an optional embodiment, the training module is also used to determine the size of the sliding window as N; determine the starting time; extract the historical traffic data corresponding to the starting time from the historical traffic sequence, and extract the historical traffic data corresponding to the (N-1) moments before the starting time, and use the historical traffic data corresponding to the starting time and the historical traffic data corresponding to the (N-1) moments before the starting time as input samples; extract the historical traffic data corresponding to the next moment after the starting time from the historical traffic sequence as an output sample.
[0090] In an optional embodiment, the acquisition module is also used to: grid-divide the target area to determine multiple grid areas; for each of the grid areas, obtain the first historical flow data of the grid area; determine the first flow characteristic data of the target area based on the first historical flow data of each of the grid areas; and input the historical flow data as input data into a preset space-time network model, including: inputting the first flow characteristic data of the target area as input data into a preset space-time network model.
[0091] Figure 7 The system architecture of the flow determination method based on spatiotemporal data applicable to the embodiment of the present invention is schematically shown.
[0092] like Figure 7As shown, the system architecture 800 applicable to the flow determination method based on spatiotemporal data of the embodiment of the present invention includes: terminal devices 801, 802, 803, a network 804 and a server 805. The network 804 is used to provide a medium for a communication link between the terminal devices 801, 802, 803 and the server 805. The network 804 may include various connection types, such as wired, wireless communication links or optical fiber cables.
[0093] The terminal devices 801, 802, 803 interact with the server 805 via the network 804 to receive or send messages, etc. Various communication client applications may be installed on the terminal devices 801, 802, 803.
[0094] The server 805 may be a server that provides various services. The server may analyze and process the received request or message, and feed back the result obtained after the data processing to the terminal device.
[0095] It should be noted that the flow determination method based on spatiotemporal data provided in the embodiment of the present invention can generally be executed by the server 805. The flow determination method based on spatiotemporal data provided in the embodiment of the present invention can also be executed by a server or server cluster that is different from the server 805 and can communicate with the terminal devices 801, 802, 803 and / or the server 805.
[0096] It should be understood that Figure 7 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0097] Figure 8 The schematic diagram of an electronic device according to an embodiment of the present invention is schematically shown. Figure 8 As shown, the electronic device 800 provided in the embodiment of the present invention includes a processor 801, a communication interface 802, a memory 803 and a communication bus 804, wherein the processor 801, the communication interface 802 and the memory 803 communicate with each other through the communication bus 804; the memory 803 is used to store at least one executable instruction; the processor 801 is used to implement the traffic determination method based on spatiotemporal data as described above when executing the executable instruction stored in the memory.
[0098] Specifically, when implementing the above model iteration method, the above executable instructions cause the above processor to perform the following steps:
[0099] Obtaining the first historical traffic data in the target area;
[0100] The historical traffic data is input as input data into a preset spatiotemporal network model to obtain the target traffic data of the target area within a target time period. The preset spatiotemporal network model includes a spatiotemporal feature layer. The spatiotemporal feature layer obtains multiple convolution features of the historical traffic data through convolution kernels of multiple scales, and determines the spatiotemporal features of the historical traffic data from the multiple convolution features through a self-attention mechanism.
[0101] The above-mentioned memory 803 can be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk or a ROM. The memory 803 has a storage space for program codes for executing any method steps in the above-mentioned method. For example, the storage space for program codes may include various program codes for implementing various steps in the above method respectively. These program codes can be read from or written into one or more computer program products. These computer program products include program code carriers such as hard disks, compact disks (CDs), memory cards or floppy disks. Such computer program products are usually portable or fixed storage units. The storage unit may have a storage segment or storage space arranged similarly to the memory 803 in the above-mentioned electronic device. The program code can be compressed, for example, in an appropriate form. Generally, the storage unit includes a program for executing the method steps according to an embodiment of the present invention, that is, a code that can be read by a processor such as 801, which, when run by an electronic device, causes the electronic device to execute various steps in the method described above.
[0102] The embodiment of the present invention further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the flow determination method based on spatiotemporal data as described above is implemented.
[0103] The computer-readable storage medium may be included in the device / apparatus described in the above embodiment; or it may exist independently without being assembled into the device / apparatus. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present invention is implemented.
[0104] According to an embodiment of the present invention, the computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, apparatus, or device.
[0105] The above-mentioned various technical solutions provided by the embodiments of the present invention can be implemented in hardware in all or part of the steps, or in software modules running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or a digital signal processor (DSP) can be used in practice to implement some or all functions of some or all components in the electronic device according to the embodiments of the present invention. The embodiments of the present invention can also be implemented as a device or apparatus program (e.g., a computer program and a computer program product) for executing part or all of the methods described herein. The program implementing the embodiments of the present invention can be stored on a computer-readable medium, or can have the form of one or more signals. Such a signal can be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.
[0106] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or step from another entity or step, and do not necessarily require or imply any such actual relationship or order between these entities or steps. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "include one..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0107] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A flow determination method based on spatiotemporal data, characterized in that: include: Obtaining the first historical traffic data in the target area; The historical traffic data is input as input data into a preset spatiotemporal network model to obtain the target traffic data of the target area within the target time period; wherein the preset spatiotemporal network model includes a spatiotemporal feature layer, the spatiotemporal feature layer obtains multiple convolution features of the historical traffic data through convolution kernels of multiple scales, and determines the spatiotemporal features of the historical traffic data from the multiple convolution features through a self-attention mechanism for dynamically selecting the size of the convolution kernel, so that the preset spatiotemporal network model determines the target traffic data of the target area within the target time period according to the spatiotemporal features; The preset spatiotemporal network model is obtained by training according to the following steps: Divide the training area into grids and determine multiple grid areas; For each of the grid areas, obtaining second historical traffic data of the grid area in multiple time periods; splicing the second historical flow data of the plurality of grid areas in the same time period to obtain the second flow characteristic data of the same time period; Obtaining a historical traffic sequence according to the second traffic characteristic data in the multiple time periods, and using the historical traffic sequence as a training data set; The training data set is trained to obtain the preset spatiotemporal network model.
2. The method according to claim 1, characterized in that The method also includes: when the preset spatiotemporal network model includes multiple adjacent spatiotemporal feature layers, inputting output data of a previous spatiotemporal feature layer among the multiple adjacent spatiotemporal feature layers into a subsequent spatiotemporal feature layer to determine the spatiotemporal characteristics of the output data.
3. The method according to claim 1, characterized in that The method also includes: when the preset spatiotemporal network model also includes a first convolutional layer, inputting the historical traffic data into the first convolutional layer, acquiring high-dimensional features of the historical traffic data, and inputting the high-dimensional features into the spatiotemporal feature layer.
4. The method according to claim 3, characterized in that The method also includes: when the preset spatiotemporal network model also includes a second convolutional layer, inputting the spatiotemporal features into the second convolutional layer, and performing a downsampling operation on the spatiotemporal features to obtain target traffic data of the target area within a target time period.
5. The method according to claim 1, characterized in that Training the training data set to obtain the preset spatiotemporal network model includes: Determine the size of the sliding window; Extracting input samples from the historical traffic sequence using the sliding window, wherein the data volume of the input samples is consistent with the size of the sliding window; Extracting output samples from the historical traffic sequence according to the extracted input samples, and using the output samples as labels corresponding to the input samples; Training is performed based on the input samples and the labels to obtain the preset spatiotemporal network model.
6. The method according to claim 5, characterized in that Determining the size of the sliding window includes: determining the size of the sliding window to be N; Extracting input samples from the historical traffic sequence using the sliding window includes: determining a starting time; extracting historical traffic data corresponding to the starting time from the historical traffic sequence, and extracting historical traffic data corresponding to (N-1) moments before the starting time, and using the historical traffic data corresponding to the starting time and the historical traffic data corresponding to (N-1) moments before the starting time as input samples; Extracting output samples from the historical traffic sequence according to the extracted input samples includes: extracting historical traffic data corresponding to a next moment after the starting moment from the historical traffic sequence as output samples.
7. The method according to claim 6, characterized in that Acquiring the first historical traffic data in the target area includes: Performing grid division on the target area to determine a plurality of grid areas; For each of the grid areas, obtaining first historical traffic data of the grid area; Determining first flow characteristic data of the target area according to first historical flow data of each grid area; Inputting the historical traffic data as input data into a preset space-time network model includes: inputting the first traffic characteristic data of the target area as input data into a preset space-time network model.
8. A flow determination device based on spatiotemporal data, characterized in that: include: An acquisition module, used for acquiring first historical traffic data in a target area; A determination module, used to input the historical traffic data as input data into a preset spatiotemporal network model to obtain the target traffic data of the target area within the target time period; wherein the preset spatiotemporal network model includes at least one spatiotemporal feature layer, the spatiotemporal feature layer obtains multiple convolution features of the historical traffic data through convolution kernels of multiple scales, and determines the spatiotemporal features of the historical traffic data from the multiple convolution features through a self-attention mechanism for dynamically selecting the size of the convolution kernel, so that the preset spatiotemporal network model determines the target traffic data of the target area within the target time period according to the spatiotemporal features; The preset spatiotemporal network model is obtained by training according to the following steps: Divide the training area into grids and determine multiple grid areas; For each of the grid areas, obtaining second historical traffic data of the grid area in multiple time periods; splicing the second historical flow data of the plurality of grid areas in the same time period to obtain the second flow characteristic data of the same time period; Obtaining a historical traffic sequence according to the second traffic characteristic data in the multiple time periods, and using the historical traffic sequence as a training data set; The training data set is trained to obtain the preset spatiotemporal network model.
9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform the following steps: Obtaining the first historical traffic data in the target area; Inputting the historical traffic data as input data into a preset spatiotemporal network model to obtain the target traffic data of the target area within the target time period; wherein the preset spatiotemporal network model includes at least one spatiotemporal feature layer, the spatiotemporal feature layer obtains multiple convolution features of the historical traffic data through convolution kernels of multiple scales, and determines the spatiotemporal features of the historical traffic data from the multiple convolution features through a self-attention mechanism for dynamically selecting the size of the convolution kernel, so that the preset spatiotemporal network model determines the target traffic data of the target area within the target time period according to the spatiotemporal features; The preset spatiotemporal network model is obtained by training according to the following steps: Divide the training area into grids and determine multiple grid areas; For each of the grid areas, obtaining second historical traffic data of the grid area in multiple time periods; splicing the second historical flow data of the plurality of grid areas in the same time period to obtain the second flow characteristic data of the same time period; Obtaining a historical traffic sequence according to the second traffic characteristic data in the multiple time periods, and using the historical traffic sequence as a training data set; The training data set is trained to obtain the preset spatiotemporal network model.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Traffic flow prediction system and method and model training method
CN110674987A
Urban area flow prediction system and method for vehicle track big data
CN113724504A