Traffic flow prediction method, system, device and storage medium based on adversarial network
By using BIDAF-GAN bidirectional attention flow adversarial network and hexagonal traffic link map in road traffic prediction, the problem of complex data and insufficient impact of spatial position relationship is solved, and efficient traffic prediction is achieved.
Patent Information
- Application Number
- CN202210704931.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-21
- Publication Date
- 2025-05-16
- Estimated Expiration
- 2042-06-21
AI Technical Summary
The existing technology has problems in the prediction of road traffic flows, insufficient impact on the position relationship between vehicles and vehicles, complex network model training and inconvenient calculations, and inadequate consideration of the impact of weather and social activity events.
A traffic flow prediction method based on BIDAF-GAN bidirectional attention flow adversarial network is proposed. Through vector transformation, arranging it into a hexagonal traffic link diagram, integrating spatial information and velocity information, constructing a sample set and using a bidirectional attention flow adversarial network for training to predict traffic flow.
It realizes data compression and spatial information amplification, simplifies the model training process, reduces the computing needs, and can effectively capture the impact of spatial position relationships between vehicles and external factors on vehicle flow, improving prediction accuracy.
Smart Images

Figure CN115099328B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a road traffic flow prediction technology, in particular to a traffic flow prediction technology based on an adversarial network. Background Art
[0002] As people's consumption level continues to improve, the number of cars is increasing, and road congestion has become a constant concern for urban managers and drivers and passengers. By predicting road traffic flow, drivers and passengers can plan their travel routes reasonably, reduce travel waiting time, and urban managers can pay attention to road traffic conditions, optimize traffic management plans, increase traffic control, and relieve traffic pressure. These requirements are becoming more and more urgent.
[0003] Traffic flow prediction is a core focus issue that drivers and passengers are mainly concerned about, and is an important part of the travel level of the OEM's automotive ecosystem. Making full use of big data to predict traffic flow is a basic service capability for OEMs in the practice of concepts such as smart cars and digital cars in the data age.
[0004] The invention patent with the publication number CN112613630A and the name of “A short-term traffic demand forecasting method integrating multi-scale spatiotemporal statistical information” proposes a multi-scale division method for urban traffic demand statistical areas with multi-scale hexagonal partitions, and calculates the traffic demand of each area at different spatiotemporal scales; constructs a convolutional long short-term memory traffic demand forecasting model integrating multi-scale hexagonal travel demand spatiotemporal information; trains the model based on historical data, and uses the trained model to make real-time forecasts of the demand of each area. Combining multi-scale hexagonal partitions with deep learning, it captures the multi-scale spatiotemporal demand information of the region and effectively improves the prediction accuracy. Calculate the spatiotemporal demand of each partition at different scales to obtain the high-scale partition numbers of each level corresponding to the benchmark partition, construct the corresponding input and output samples, and divide the training set and test set at the time scale r in proportion; use the convolutional long short-term memory model to predict the spatiotemporal series, and for the demand values at each spatial scale obtained by each prediction, screen out a group with small errors for the calculation of the overall loss function of the model, train the model based on historical data, and perform real-time demand prediction, evaluate the prediction results at the corresponding spatial scales, and establish the optimal multi-spatiotemporal scale traffic demand prediction model.
[0005] However, the above hexagonal partition is a hexagonal spatial division of the original map. The spatial position will not change, the spatial direction cannot be converted and the space cannot be expanded, and the spatial position relationship between the car and the workshop is weakly affected.
[0006] The invention patent with publication number CN112330952B and name “A traffic flow prediction method based on generative adversarial network” constructs a traffic physical topology structure graph network: constructs a traffic physical topology structure graph network according to the spatial connection relationship between road sections in the traffic road network, regards road sections as nodes, and connects connected road sections as corresponding nodes, thereby obtaining a traffic physical topology structure graph network; constructs an initial neighborhood traffic graph network and a high-order neighborhood traffic graph network: uses the constructed traffic physical topology structure graph network as the initial neighborhood traffic graph network, and regards the neighboring nodes of the adjacent nodes of the original node in the initial neighborhood traffic graph network as the nodes in the second-order neighborhood of the original node, thereby constructing a second-order neighborhood traffic graph network, and so on, thereby obtaining a high-order neighborhood traffic graph network; constructs a generator of a generative adversarial network GAN: the generator of the generative adversarial network is used to generate Traffic data, the graph attention network GAT is used in the generator for feature extraction. Based on the obtained initial neighborhood traffic graph network and multiple high-order neighborhood traffic graph networks, the node information in the neighborhood of each node in the traffic graph network is extracted and the predicted traffic data is generated, where the node information represents the time series traffic data information of the detector on the road section; the discriminator of the generative adversarial network GAN is constructed: the discriminator of the generative adversarial network is used to determine whether the input traffic data is true. The discriminator of the generative adversarial network uses a multi-layer fully connected network to distinguish the true or false of the traffic data; the generative adversarial network GAN is used to generate traffic data: the mutual game between the generator and the discriminator in the generative adversarial network finally generates predicted traffic data close to the real traffic data, and the predicted traffic data is verified with the real traffic data to calculate the error.
[0007] The G generative network in the above-mentioned adversarial network is based on the graph attention layer. The data is complex and the computation is large. It is necessary to construct the initial neighborhood traffic graph network and the high-order neighborhood traffic graph network according to the connection relationship of the nodes in the traffic graph. Due to the spatial destruction of the vector hexagons, the connection relationship of the nodes in the traffic graph is destroyed. The traffic simulation effect is poor using the graph network-based structure.
[0008] The invention patent with application number CN202010741049.8A and name "A method for predicting urban traffic flow based on deep learning fusion model" includes the following steps: constructing a traffic flow prediction data attribute library; dividing the urban road network into different blocks according to different uses, preprocessing the historical traffic flow data and counting the traffic flow in different time periods respectively, constructing a traffic flow input matrix, and establishing a binary vector graph; constructing 3DLSACN, that is, combining LSTM and CNN three-dimensional convolutional model and Resnet residual network as a deep learning fusion model for traffic flow feature extraction, using the established binary vector graph as input for feature extraction, extracting spatiotemporal features and periodic features respectively and fusing them to obtain preliminary fusion results; manually extracting external influencing factors to form external features and fusing them with the preliminary fusion results again, and finally outputting the required predicted traffic flow information.
[0009] The above road network division establishes a binary vector map. There is no spatial destruction in essence, and it is still the division of the original space. In addition, supervised deep learning is used, and the training data only has sample data, which requires the use of a complex network structure. Summary of the invention
[0010] In view of the problems existing in the prior art of road traffic flow prediction, such as complex original data, insufficient influence of the spatial position relationship between vehicles, complex training network model, inconvenient calculation, and insufficient consideration of the impact of weather and general social events on traffic flow, the present invention innovatively proposes vector transformation and arrangement into a hexagonal traffic link diagram at the data processing level, integrating spatial information and speed information into one diagram, so that the data is compressed and transformed to a certain extent, and the spatial ratio is enlarged to increase more spatial information; at the same time, the BIDAF-GAN bidirectional attention flow adversarial network structure is used to train and predict traffic flow. On the one hand, less model depth is used to carry out calculations, so that model training does not require expensive hardware support.
[0011] The technical solution of the present invention to solve the above technical problems is to propose a traffic flow prediction method based on the BIDAF-GAN bidirectional attention flow adversarial network. The traffic flow data of different vehicles on each road in each direction are arranged into a hexagonal flow link diagram H in the same direction through vector transformation; the comprehensive information such as traffic flow, vehicle speed, GPS location information, map, weather information, social activities, etc. at a certain moment in the H diagram is obtained to construct a sample set, and the sample set is divided into a training set and a test set in proportion; the training set is input into the bidirectional attention flow adversarial network BIDAF-GAN for training until the loss function converges on the test set to obtain a traffic flow prediction model to obtain a prediction network structure GNET; the comprehensive data of a road in the H diagram at a certain moment is input into the prediction network structure GNET to obtain traffic flow prediction information for the road. Specifically,
[0012] A traffic flow prediction method based on a BIDAF-GAN bidirectional attention flow adversarial network comprises the following steps: arranging vehicles and comprehensive information traveling on roads in all directions within a predetermined range into a hexagonal flow link diagram in the same direction through vector transformation, wherein each hexagonal flow link diagram represents a spatial position information diagram H of each vehicle at a fixed distance under a certain period T, and the road number is marked as N; each vehicle in the H diagram is a dot, and all vehicles and vehicle speeds entering the H diagram in period T are obtained to obtain the flow S of all roads in the H diagram T-N , the average speed of all cars V T-N-mean , mark the weather conditions W of different roads at different times in Figure H T-N , collect social activity events around the road, and obtain activity information P of different roads according to the period T and the location of the activity event T-N ; Obtain relevant comprehensive information in the H graph to construct a sample set, divide the sample set into a training set and a test set in proportion, input the training set into a bidirectional attention stream adversarial network for training, until the loss function converges on the test set to obtain a bidirectional attention stream adversarial network to construct a traffic flow prediction model; Input the comprehensive road data at a certain moment into the prediction model to predict the traffic flow information of the road, the encoding structure in the bidirectional attention stream adversarial network structure generates camouflage data and the influencing factors of the loss function, the generation structure obtains the relationship between the data in the comprehensive information in the hexagonal traffic link diagram, and the relationship between the comprehensive information data of the current cycle and the previous cycle, the activation function obtains nonlinear information, and the discriminant structure judges the difference in predicted data.
[0013] Further preferably, the vector conversion includes: converting all roads in different directions into roads in the same direction, dividing the road into intervals according to a fixed length, expanding the space between two intervals so that the two intervals are changed from a rectangle to a regular hexagon, and reflecting the proportion of the space expansion in the GPS positioning data of the vehicle at the same time.
[0014] Further optimization, the adversarial network generates a structure to obtain the relationship between the data in the comprehensive information in the hexagonal traffic link diagram, and the relationship between the comprehensive information data of the current cycle and the previous cycle, and the activation function obtains nonlinear information; the random perturbation operator in the coding structure forms camouflaged data according to the input predicted traffic, and the KL divergence is used as an influencing factor of the sorting loss function. The coding structure obtains the characteristics of the data itself, amplifies the amount of information, and obtains high-dimensional information.
[0015] Further preferably, the training includes: converting the flow data H corresponding to the hexagonal flow link diagram of the T+1th period T+1 After random perturbation, the disguised data ZK is obtained; H T+1 Input the discriminant structure DNET of the adversarial network to obtain the predicted output D1, and verify the true H T+1Whether it can be judged correctly; input ZK into the generation structure GNET of the adversarial network to obtain the predicted output G1, which is used to solidify the parameters of the generation structure GNET, so that the predicted output G1 is closer to the flow of the next cycle T+1, and then input G1 into the discriminant model to determine whether it is generated by simulating ZK flow data; obtain W in the hexagonal flow link diagram T-N , P T-N , H T Input the generative structure GNET of the adversarial network to obtain the output G2, and verify whether it can predict the traffic of the next cycle T+1; input G2 into the discriminative structure DNET of the adversarial network to obtain the output D2, and verify whether the deviation between the original data and the actual value can be judged after being predicted by GNET; G1 passes through the output D3 of the discriminative structure DNET of the adversarial network to verify whether the disguised data can be identified; repeat the above process until the loss converges on the test set.
[0016] Further preferably, the verification is performed on the real H T+1 Whether it can be judged correctly is as follows: According to the loss function, the predicted output D1 is compared with the traffic data H obtained from the H graph. T+1 Compare whether they are consistent. If they are consistent, it means that the discriminant model can accurately identify the input H T+1 is the true value, and the loss function is: loss1=BCEWithLogitsLoss(D1,true).
[0017] Further preferably, the verification of whether the original data can be predicted by GNET and the deviation from the actual value includes identifying that the output D2 of the discriminant structure DNET is generated by real data according to the loss function Loss2, wherein Loss2 = BCEWithLogitsLoss(D2, True).
[0018] Further preferably, the predicted output G1 is input into the output D3 of the adversarial network discriminant structure DNET to verify whether the disguised data ZK can be identified, and it is determined whether G1 is generated by simulated data according to the loss function Loss3, wherein Loss3 = BCEWithLogitsLoss(D2, False).
[0019] Further optimization, according to the sub-loss functions of different network results corresponding to the fake data and the real traffic data, the formula: d_loss = loss1 + loss2 is called to calculate the loss function d_loss so that the discriminant structure DNET can distinguish the disguised data and the real data as much as possible, and the formula is called: g_loss = 0.3*Loss3 + 0.7*MSELoss (H T+1 , ZK) calculates the loss function g_loss so that the error between the output prediction result and the flow value of the next period is small enough, MSELoss(H T+1, ZK) is the disguised data and the real traffic data H of T+1 period T+1 The mean square loss function.
[0020] The present invention also proposes a traffic flow prediction system based on the BIDAF-GAN bidirectional attention flow adversarial network, which arranges the vehicles and comprehensive information traveling on each road in each direction within a predetermined range into a hexagonal flow link diagram in the same direction through vector transformation. Each hexagonal flow link diagram represents a spatial position information diagram H of each vehicle at a fixed distance under a certain period T, and the road number is marked as N; each vehicle in the H diagram is a dot, and all vehicles and vehicle speeds entering the H diagram in period T are obtained to obtain the flow S of all roads in the H diagram T-N , the average speed of all cars V T-N-mean , mark the weather conditions W of different roads at different times in Figure H T-N , collect social activity events around the road, and obtain activity information P of different roads according to the period T and the location of the activity event T-N ; Obtain relevant comprehensive information in the H graph to construct a sample set, divide the sample set into a training set and a test set in proportion, input the training set into a bidirectional attention flow adversarial network BIDAF-GAN for training, until the loss function converges on the test set to obtain a bidirectional attention flow adversarial network to construct a traffic flow prediction model, the bidirectional attention flow adversarial network structure includes: an input structure INPUT_NET, a generation structure GNET, a discrimination structure DNET, and an encoding structure ENCODE, the encoding structure generates camouflage data and an influencing factor of the loss function, and the generation structure and the discrimination structure use the same structure and different activation functions.
[0021] Further preferably, the generation structure GNET includes 1 attention flow layer structure ATTENTION_FLOW_LAYER, 1 long short-term memory network structure LSTM, and 1 activation function ReLU. The attention flow layer structure, the long short-term memory network structure, and the activation function ReLU are serially connected. The attention flow layer structure obtains the relationship between the data in the comprehensive information in the hexagonal flow link diagram, the long short-term memory network captures the relationship between the comprehensive information data of the current cycle and the previous cycle, and the activation function obtains nonlinear information; the encoding structure ENCODE includes 1 convolution structure Conv1d, 1 activation function ReLU, 3 fully connected layer structures Linear, 1 random perturbation operator, and 1 KL divergence operator from the input end to the result end. The random perturbation operator forms camouflaged data according to the input predicted traffic. KL divergence is used as an influencing factor of the sorting loss function. The encoding structure obtains the characteristics of the data itself, amplifies the amount of information, and obtains high-dimensional information.
[0022] Further preferably, the vector conversion includes: converting all roads in different directions into roads in the same direction, dividing the road into intervals according to a fixed length, expanding the space between two intervals so that the two intervals are changed from a rectangle to a regular hexagon, and reflecting the proportion of the space expansion in the GPS positioning data of the vehicle at the same time.
[0023] Further preferably, the training includes: converting the flow data H corresponding to the hexagonal flow link diagram of the T+1th period T+1 After random perturbation, the disguised data ZK is obtained; H T+1 Input the discriminant structure DNET of the adversarial network to obtain the predicted output D1, and verify the true H T+1 Whether it can be judged correctly; input ZK into the generation structure GNET of the adversarial network to obtain the predicted output G1, which is used to solidify the parameters of the generation structure GNET, so that the predicted output G1 is closer to the flow of the next cycle T+1, and then input G1 into the discriminant model to determine whether it is generated by simulating ZK flow data; obtain W in the hexagonal flow link diagram T-N , P T-N , H T Input the generative structure GNET of the adversarial network to obtain the output G2, and verify whether it can predict the traffic of the next cycle T+1; input G2 into the discriminative structure DNET of the adversarial network to obtain the output D2, and verify whether the deviation between the original data and the actual value can be judged after being predicted by GNET; G1 passes through the output D3 of the discriminative structure DNET of the adversarial network to verify whether the disguised data can be identified; repeat the above process until the loss converges on the test set.
[0024] Further preferably, the verification is performed on the real H T+1 Whether it can be judged correctly is as follows: According to the loss function, the predicted output D1 is compared with the traffic data H obtained from the H graph. T+1 Compare whether they are consistent. If they are consistent, it means that the discriminant model can accurately identify the input H T+1 is the true value, and the loss function is: loss1=BCEWithLogitsLoss(D1,true).
[0025] Further preferably, the verification of whether the original data can be predicted by GNET and the deviation from the actual value includes identifying that the output D2 of the discriminant structure DNET is generated by real data according to the loss function Loss2, wherein Loss2 = BCEWithLogitsLoss(D2, True).
[0026] Further preferably, the predicted output G1 is input into the output D3 of the adversarial network discriminant structure DNET to verify whether the disguised data ZK can be identified, and it is determined whether G1 is generated by simulated data according to the loss function Loss3, wherein Loss3 = BCEWithLogitsLoss(D2, False).
[0027] The present invention also proposes an electronic device, comprising: a processor and a memory; wherein the processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to implement the traffic flow prediction system based on the BIDAF-GAN bidirectional attention flow adversarial network as described above.
[0028] The present invention also proposes a computer-readable storage medium, on which a program or instruction is stored, and the program or instruction can be loaded and executed by a processor to execute the traffic flow prediction method based on the BIDAF-GAN bidirectional attention flow adversarial network as described above.
[0029] The present invention is aimed at the original spatial position of roads and vehicles. On the one hand, it converts the spatial direction so that different road directions are converted into the same direction, that is, the north-south road is converted into the east-west road. On the other hand, based on the conversion of the spatial direction, the space is expanded, that is, the distance between two vehicles traveling in the same direction and close to each other in the original data is 1 meter apart. When the vector is hexagonal after the spatial conversion, the difference between the two vehicles is 1.5 meters. The present invention uses a bidirectional attention flow + fully connected layer mechanism, and has an independent encoding structure for obtaining data feature information to enhance the flow simulation effect. The present invention uses an adversarial network, and data training will be interfered by random values. Compared with general rasterized maps, the H map has many advantages such as increased vehicle speed information, spatial information amplification to facilitate the model to obtain spatial position, and small-scale spatial distortion to facilitate the model to capture the impact of narrow roads on traffic flow. The BIDAF-GAN bidirectional attention flow adversarial network structure can be freely extended to multiple data for joint prediction, and can expand multiple other non-traffic data that affect traffic flow, without changing network parameters, and the training network structure has moderate complexity. Servers with 8G GPUs can train and predict faster without the need for large servers. The training network fully learns the mutual influence between time, space, weather, and events. The model uses the same network structure for training multiple times to avoid a larger, deeper, and more complex model. The prediction model only occupies about 10% of the training network, and the calculation in the prediction stage is faster. The bidirectional attention flow can obtain the mutual influence between different lanes, and can also find the weights of the attention parameters that affect different factors. The model shares a GNET or DNET multiple times, which can continuously deepen the information acquisition of the input data and achieve a better fit. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 The vehicles are arranged into a hexagonal flow link diagram in the same direction through vector transformation;
[0031] Figure 2 Schematic diagram of the BIDAF-GAN bidirectional attention stream adversarial network structure;
[0032] Figure 3 Comparison chart between the true value of a road and the predicted value of BIDAF-GAN. DETAILED DESCRIPTION
[0033] In order to facilitate a clear understanding of the present invention, and to make the technical problems, technical solutions and advantages to be solved by the present invention clearer, the present invention will be described in detail below in conjunction with the accompanying drawings and specific embodiments. In the following description, specific details such as specific configurations and components are provided only to help fully understand the embodiments of the present invention. Therefore, it should be clear to those skilled in the art that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present invention. In addition, for clarity and brevity, the description of known functions and structures is omitted. It should be understood that the embodiments are only for the purpose of illustrating the present invention, not for limiting the scope of protection of the present invention.
[0034] Compared with general rasterized images, H images have many advantages, such as increased vehicle speed information, spatial information amplification, which makes it easier for the model to obtain spatial positions and the positional relationship between vehicles, and small-scale spatial distortion, which makes it easier for the model to capture the impact of narrow roads on traffic flow. Figure 1 The figure shows a schematic diagram of a hexagonal traffic link diagram in which vehicles are arranged in the same direction through vector transformation. The road number is marked as N. The GPS positioning information of vehicles in a fixed period, the speed of the vehicle, the road traffic map, the weather (rainy days, foggy days, snowy days, general weather), social events (city-level sports events, performing arts activities, literary exhibitions) and other related information are obtained. The GPS positioning information, vehicle speed, traffic map and other related information are combined into a single Figure 3 The data is recorded as traffic flow data X. The traffic flow data X, all vehicles in all directions and on all roads are arranged into a hexagonal flow link diagram in the same direction through vector transformation. The vehicles traveling on the roads within the predetermined range are arranged into a hexagonal flow link diagram in the same direction through vector transformation, and the spatial position information diagram H of the vehicles is constructed. Each hexagonal flow link diagram represents the spatial position information diagram H of each vehicle at a fixed distance at a certain period time T. The hexagonal flow link diagram is constructed by vector transformation based on the GPS positioning information of the road, the vehicle, the speed information, and the GPS positioning information of the road.
[0035] The vector conversion process can be carried out in the following way: convert all roads in different directions into roads in the same direction, that is, convert roads from southeast to northwest into east-west roads; divide the intervals on the road according to fixed lengths, and expand the space between two intervals so that the two intervals are changed from a rectangle to a regular hexagon; and reflect the proportion of the space expansion in the vehicle's GPS positioning data at the same time.
[0036] Each vehicle in the H graph is represented by a dot. If the dots are dense, it means the traffic volume is high, and if the dots are sparse, it means the traffic volume is low. Obtain all the vehicles and their speeds that enter the H graph at time T, and obtain the traffic volume S of all roads in the H graph. T-N , the average speed of all cars V T-N-mean , the background color depth in H is determined by V T-N-mean / V max The value of V max It is the maximum speed of all traffic flow data in the H graph. In order to make the speed more intuitive and integrate the speed into the image space, so that the model can capture the information between the speed and space, the darker the background color, the faster the speed.
[0037] According to the period T, the weather conditions W of different roads at different times in the H map are obtained according to the weather forecast information. T-N , collect social activity events around the road, and obtain activity information P of different roads according to the cycle time T and the location of the activity event T-N . The weather information W of the Nth road at time T T-N , social activity information P of the Nth road at time T T-N , traffic information S of the Nth road at time T T-N , the traffic data H of all roads in the hexagonal traffic link diagram at time T T The training set and test set are divided according to the ratio. The sampling frequency of social activity information and weather information is consistent with the frequency of the H graph, that is, social activities and weather conditions occurring at the same time. Social activity information and weather information are input into the model as independent data.
[0038] A bidirectional attention adversarial network BIDAF-GAN is constructed to train H-graphs, social activity information, weather information and other data, and the optimal network is trained as a traffic flow prediction model.
[0039] like Figure 2 The figure shows the schematic diagram of the BIDAF-GAN bidirectional attention stream adversarial network structure. The bidirectional attention stream adversarial network structure consists of multiple substructures, namely the input structure INPUT_NET, the generation structure GNET, the discrimination structure DNET, and the encoding structure ENCODE.
[0040] Input structure INPUT_NET gets W T-N, P T-N , H T , the H image is pixelated to read the specific image pixel data, and the other data is the original data. The output result is passed to the next step to generate the structure.
[0041] The generated structure GNET includes 1 attention flow layer structure ATTENTION_FLOW_LAYER, 1 long short-term memory network structure LSTM, and 1 activation function ReLU. The attention flow layer structure, the long short-term memory network structure, and the activation function ReLU are connected in series. Among them, the attention flow layer structure mainly obtains the relationship between a single data and all data, and can also obtain the relationship between a single data and the traffic conditions of the previous time. In this embodiment, the attention flow layer structure is based on the output of the input structure INPUT_NET, and the long short-term memory network structure is mainly to deepen the capture of the relationship between the current time and the previous time. The activation function is mainly to add nonlinear factors to the model to obtain nonlinear information.
[0042] The encoding structure ENCODE includes 1 convolution structure Conv1d, 1 activation function ReLU, 3 fully connected layer structures Linear, 1 random perturbation operator, and 1 KL divergence operator, namely relative entropy, from the input end to the result end. The random perturbation operator forms new disguised data by combining with the input. KL divergence is used as an influencing factor of the sorting loss function.
[0043] The Conv1d, 1 activation function ReLU, and 3 fully connected layer structures Linear in the encoding structure are mainly used to obtain the characteristics of the data itself. Through these structures, the amount of information is amplified to obtain high-dimensional information. 1 random perturbation operator and 1 KL divergence operator are mainly used to simulate data in subsequent training, which is one of the core functions of building adversarial networks.
[0044] The discriminant structure DNET contains 1 attention flow layer structure ATTENTION_FLOW_LAYER, 1 long short-term memory network structure LSTM, 3 fully connected layer structures Linear, and 1 activation function SIGMOD. The structure in the discriminant structure is similar to the generative structure, and uses an activation function SIGMOD that is different from the generative structure. It is mainly used to determine whether the simulated data can be identified by the discriminant structure.
[0045] Through the relevant sample parameters in the sample set, W T-N , P T-N , S T-N , H T, train the BIDAF-GAN bidirectional attention flow adversarial network, and obtain the training optimized generation structure GNET+discrimination structure DNET as the traffic flow prediction network model. The loss function can use the binary cross entropy loss BCEWithLogitsLoss and the mean square loss function MSELoss. Both loss functions themselves calculate the deviation between the true value and the predicted value.
[0046] Training the BIDAF-GAN bidirectional attention flow adversarial network includes: obtaining the flow data H at time T+1 of the H graph T+1 , the flow data H corresponding to the hexagonal flow link diagram of the T+1th period T+1 The disguised data after random perturbation is recorded as ZK.
[0047] The flow data H of the T+1th period T+1 Through the adversarial network input structure input discriminant structure DNET to obtain the predicted output D1, judge whether D1 is the real data True, and verify the real H T+1 Can the judgment be correct? Compare the predicted output D1 with the flow data H obtained from the H diagram T+1 Compare whether they are consistent. If they are consistent, it means that the discriminant model can accurately identify the input H T+1 is the true value. At this time, the adversarial network loss function loss1 is: loss1 = BCEWithLogitsLoss(D1, true), where BCEWithLogitsLoss is an S-type classification cross loss function. BCEWithLogitsLoss = BCELoss(predicted value, true value), BCEWithLogitsLoss first processes the predicted value through the S-type function, and then uses the binary cross entropy loss to calculate the deviation between the true value and the S-type function processed value. Sigmoid is an S-type function.
[0048] ZK inputs the generated structure GNET through the input structure INPUT_NET to obtain the predicted output G1. The G1 obtained by simulating the ZK traffic through the generated structure GNET is used to solidify the parameters of the generated structure GNET, so that the output result is closer to the traffic of the next cycle T+1. Then G1 is input into the discriminant model to determine whether it is generated by simulating ZK traffic data. T+1 The encoding structure ENCODE can generate disguised data, wherein the encoding structure ENCODE includes random perturbations, and the encoding structure ENCODE can be fully learned so that the disguised data better fits the original data and is more similar to the original data.
[0049] Put W T-N , P T-N , H TInput together or ZK input separately, and obtain the mutual influence and weight between the local data (such as a car) and the overall data (such as the traffic of the entire road) in the input information through the attention flow layer structure. The long short-term memory network obtains the periodic influence of traffic at different times. The activation function adds nonlinear information to all data input to the activation function, increases the complexity of the model, and makes the data mapping more complex when the data flows in each module, and obtains more information items.
[0050] W T-N , P T-N , H T The output G2 (G2 is the traffic volume of the next cycle predicted based on the training data) is obtained by inputting the input structure INPUT_NET, and checking whether it can predict the traffic volume of the next cycle T+1. Dnet is used to determine whether G2 is the real result, and Loss2 is used for gradient descent to help the training mechanism optimize the parameters, so as to find the parameters with the highest accuracy of the adversarial network. Using the back propagation technology, the partial derivative of the loss function to the DNET network weight is first calculated, and the gradient of the loss function to the weight vector is formed as the basis for modifying the weight, and then the impact on the Gnet network weight is calculated, so that the predicted value continues to approach the real traffic value.
[0051] The output G2 obtained by the generation structure GNET is input into the discriminant structure DNET to obtain the output D2, and the original data can be judged to have a deviation from the actual value after being predicted by GNET. According to the loss function Loss2, the discriminant model can identify whether the output D2 of DNET is generated by real data, where Loss2 = BCEWithLogitsLoss(D2,True).
[0052] The predicted output G1 is input into the output D3 of the discriminant structure DNET to check whether the disguised data can be identified. According to the formula: Loss3 = BCEWithLogitsLoss (D2, False), it is determined whether G1 is generated by simulated data. False means failure.
[0053] The above training is performed until the loss converges on the test set. The convergence process is a stable loss result. According to the loss sub-loss functions of different network results corresponding to fake data and real data, the loss function d_loss is determined so that the discriminant structure DNET can distinguish the fake data and the real data as much as possible, and the loss function g_loss is determined so that the error between the output prediction result and the traffic value of the next cycle is small enough. Among them, the above loss function can be calculated according to the formula,
[0054] d_loss=loss1+loss2,g_loss=0.3*Loss3+0.7*MSELoss(H T+1,ZK).
[0055] d_loss is mainly based on whether the input data judged by Dnet is fake data or real data, and the two types of data are separated as much as possible; loss1 / loss2 / loss3 are the loss sub-loss functions of fake data and real data corresponding to different network results, respectively, MSELoss (H T+1 , ZK) is the disguised data Z and the real traffic data H T+1 The mean square loss function. It is used to refine the loss results and improve accuracy. g_loss is used to calculate whether the error between the predicted result output by Gnet and the actual traffic value of the next cycle is small enough, so as to make the two data consistent as much as possible. At the same time, the role of Loss3 is to allow Gnet to take into account the ability to separate the two data. Under the action of g_loss and d_loss, the two form a confrontation and eventually converge in balance. d_loss and g_loss rely on the deviation between the true value and the predicted value. Through the back propagation technology, the partial derivative of the loss function to each network weight is calculated layer by layer, forming the gradient of the loss function to the weight vector, which is used as the basis for modifying the weight. The learning of the network is completed in the process of weight modification. When the error reaches the expected value or the network error converges to equilibrium, the network training ends.
[0056] After the network training is completed, the weight of GNET is selected, and the optimal weight information is saved when the error reaches the expected value or the network error converges to equilibrium. The weight is loaded into the Gnet network. When the driver starts the vehicle or plans the driving route, the data of weather, social activities and current traffic flow map transmitted by the cloud platform is input into the prediction network model after the above-mentioned hexagonal transformation. The output is the final traffic data of each road in the next cycle.
[0057] like Figure 3 The figure shows the comparison between the real value of a road and the predicted value of BIDAF-GAN. It can be seen that BIDAF-GAN is better than other known methods. Figure 3 It describes the difference between the BIDAF-GAN prediction value and the actual traffic. The true in the legend is the actual traffic.
[0058] The above-described embodiment is only one embodiment of the present invention. Any common changes and substitutions made by those skilled in the art within the scope of the technical solution of the present invention should be included in the protection scope of the present invention.
Claims
1. A traffic flow prediction method based on BIDAF-GAN bidirectional attention flow adversarial network, characterized in that: The method comprises the following steps: arranging the vehicles and comprehensive information traveling on each road in each direction within a predetermined range into a hexagonal flow link diagram in the same direction through vector transformation, wherein each hexagonal flow link diagram represents a spatial position information diagram H of each vehicle between fixed distances in a certain period T; each vehicle in the H diagram is a dot, and all vehicles and vehicle speeds entering the H diagram in the period T are obtained to obtain the flow S of all roads in the H diagram. T-N , the average speed of all cars V T-N-mean , mark the weather conditions W of different roads at different times in Figure H T-N , collect activity events around the road, and determine the activity information P of different roads according to the period T and the location of the activity event T-N ; Obtain relevant comprehensive information in the H graph to construct a sample set, divide the sample set into a training set and a test set in proportion, input the training set into a bidirectional attention stream adversarial network for training, the encoding structure in the bidirectional attention stream adversarial network structure generates camouflaged data and the influencing factors of the loss function, the generating structure obtains the relationship between the data in the comprehensive information of the current cycle in the hexagonal traffic link graph, and the relationship between the comprehensive information data of the current cycle and the previous cycle, the activation function obtains nonlinear information, and the discriminant structure judges the difference in the predicted data until the loss function converges on the test set to construct a traffic flow prediction model; input the comprehensive data of the road at a certain moment into the prediction model to predict the traffic flow information of the road; The vector conversion includes: converting all roads in different directions into roads in the same direction, dividing the intervals on the road according to fixed lengths, expanding the space between two intervals so that the two intervals are transformed from a rectangle into a regular hexagon, and reflecting the proportion of the space expansion on the GPS positioning data of the vehicle at the same time.
2. The prediction method according to claim 1, characterized in that: The adversarial network generation structure obtains the relationship between the data in the comprehensive information in the hexagonal traffic link diagram, captures the relationship between the comprehensive information data of the current cycle and the previous cycle, and the activation function obtains nonlinear information; the random perturbation operator in the encoding structure forms camouflaged data according to the input predicted traffic, and the KL divergence is used as an influencing factor of the sorting loss function. The encoding structure obtains the characteristics of the data itself, amplifies the amount of information, and obtains high-dimensional information.
3. The prediction method according to any one of claims 1 to 2, characterized in that: The training includes: converting the flow data H corresponding to the hexagonal flow link diagram of the T+1th period T+1 After random perturbation, the disguised data ZK is obtained; H T+1 Input the discriminant structure DNET of the adversarial network to obtain the predicted output D1 and verify the predicted H T+1 Whether it is consistent with the real traffic of the next cycle; input ZK into the generation structure GNET of the adversarial network to obtain the predicted output G1, and solidify the parameters of the generation structure GNET with isomorphism G1, so that the predicted output G1 is closer to the real traffic of the next cycle, and then input G1 into the discriminant model to determine whether it is generated by simulating ZK traffic data; obtain W in the hexagonal traffic link diagram T-N , P T-N , H T Input the generative structure GNET of the adversarial network to obtain the output G2, and verify whether it can predict the real traffic of the next cycle; input G2 into the discriminative structure DNET of the adversarial network to obtain the output D2, and verify whether the deviation of the original data from the real traffic value can be judged after being predicted by GNET; G1 passes through the output D3 of the discriminative structure DNET of the adversarial network to verify whether the disguised data can be identified; repeat the above process until the loss converges on the test set.
4. The prediction method according to claim 3, characterized in that: The predicted H T+1 Whether it is consistent with the actual flow of the next cycle is specifically: according to the sub-loss function, the predicted output D1 is compared with the flow data H obtained from the H graph T+1 Compare whether they are consistent. If they are consistent, it means that the discriminant model can accurately identify the input H T+1 is the true value, and the sub-loss function is: Loss1=BCEWithLogitsLoss(D1,true).
5. The prediction method according to claim 4, characterized in that: The verification of whether the original data can be predicted by GNET and whether it can be judged that it deviates from the actual value includes: identifying the output D2 of the discriminant structure DNET as being generated by real data according to the sub-loss function Loss2, wherein Loss2=BCEWithLogitsLoss(D2,True), using DNET to determine whether G2 is a real result, and using Loss2 to perform gradient descent optimization to find the parameters of the adversarial network under the highest accuracy, and calculating the partial derivative of the DNET network weight according to Loss2 to form the gradient of the loss function to the weight vector, which is used as the basis for modifying the weight so that the predicted value continues to approach the real traffic value.
6. The prediction method according to claim 5, characterized in that: The predicted output G1 is input into the output D3 of the adversarial network discriminant structure DNET to verify whether the disguised data ZK can be recognized, and whether G1 is generated by simulated data is determined according to the sub-loss function Loss3, where Loss3 = BCEWithLogitsLoss(D2,False).
7. The prediction method according to claim 6, characterized in that: According to the sub-loss functions of different network results corresponding to the fake data and the real traffic data, the formula is called: d_Loss = Loss1 + Loss2 to calculate the loss function d_Loss so that the discriminant structure DNET can distinguish the disguised data and the real data as much as possible, and the formula is called: g_Loss = 0.3*Loss3+0.7*MSELoss(H T+1 , ZK) calculates the loss function g_Loss so that the error between the output prediction result and the flow value of the next cycle is small enough, MSELoss (H T+1 , ZK) is the disguised data and the real traffic data H of the T+1 period T+1 The mean square loss function.
8. A traffic flow prediction system based on BIDAF-GAN bidirectional attention flow adversarial network, characterized in that: The vehicles and comprehensive information traveling on each road in each direction within the predetermined range are arranged into a hexagonal flow link diagram in the same direction through vector transformation. Each hexagonal flow link diagram represents the spatial position information diagram H of each vehicle at a fixed distance under a certain period T; each vehicle in the H diagram is a dot, and all vehicles and vehicle speeds entering the H diagram in period T are obtained to obtain the flow S of all roads in the H diagram T-N , the average speed of all cars V T-N-mean , mark the weather conditions W of different roads at different times in Figure H T-N , collect social activity events around the road, and determine the activity information P of different roads according to the period T and the location of the activity event T-N ; Obtain relevant comprehensive information in the H graph to construct a sample set, divide the sample set into a training set and a test set in proportion, input the training set into a bidirectional attention flow adversarial network for training, until the loss function converges on the test set to obtain a bidirectional attention flow adversarial network to construct a traffic flow prediction model, the bidirectional attention flow adversarial network structure includes: an input structure INPUT_NET, a generation structure GNET, a discrimination structure DNET, and an encoding structure ENCODE, the encoding structure generates camouflage data and an influencing factor of the loss function, the generation structure and the discrimination structure use the same structure and different activation functions; vector conversion includes: converting all roads in different directions into roads in the same direction, dividing the intervals on the road according to a fixed length, expanding the space between two intervals, so that the two intervals are changed from a rectangle to a regular hexagon, and the ratio of the space expansion is simultaneously reflected in the GPS positioning data of the vehicle.
9. The prediction system according to claim 8, characterized in that The generated structure GNET contains 1 attention flow layer structure ATTENTION_FLOW_LAYER, 1 long short-term memory network structure LSTM, and 1 activation function ReLU. The attention flow layer structure, the long short-term memory network structure, and the activation function ReLU are connected in series. The attention flow layer structure obtains the relationship between the data of the current cycle in the comprehensive information in the hexagonal flow link diagram. The long short-term memory network captures the relationship between the comprehensive information data of the current cycle and the previous cycle. The activation function obtains nonlinear information; the encoding structure ENCODE includes 1 convolution structure Conv1d, 1 activation function, 3 fully connected layer structures, 1 random perturbation operator, and 1 KL divergence operator from the input end to the result end. The random perturbation operator forms camouflaged data according to the input predicted traffic. The KL divergence operator is an influencing factor of the sorting loss function. The encoding structure obtains the characteristics of the data itself, amplifies the amount of information, and obtains high-dimensional information.
10. The prediction system according to claim 8, characterized in that The training includes: converting the flow data H corresponding to the hexagonal flow link diagram of the T+1th period T+1 After random perturbation, the disguised data ZK is obtained; H T+1 Input the discriminant structure DNET of the adversarial network to obtain the predicted output D1, and verify whether the real traffic of the next cycle can be correctly judged; input ZK into the generative structure GNET of the adversarial network to obtain the predicted output G1, which is used to solidify the parameters of the generative structure GNET, so that the predicted output G1 is closer to the real traffic of the next cycle, and then input G1 into the discriminant model to determine whether it is generated by simulating ZK traffic data; obtain W in the hexagonal traffic link diagram T-N , P T-N , H T Input the generative structure GNET of the adversarial network to obtain the output G2, and verify whether it can predict the real traffic of the next cycle; input G2 into the discriminative structure DNET of the adversarial network to obtain the output D2, and verify whether the deviation between the original data and the actual value can be judged after being predicted by GNET; G1 passes through the output D3 of the discriminative structure DNET of the adversarial network to verify whether the disguised data can be identified; repeat the above process until the loss converges on the test set.
11. The prediction system according to claim 10, characterized in that: The verification is to determine whether the actual flow rate in the next cycle can be correctly determined by: according to the sub-loss function Loss1, the predicted output D1 is compared with the flow data H obtained from the H graph. T+1 Compare whether they are consistent. If they are consistent, it means that the discriminant model can accurately identify the input H T+1 is the real traffic value, and the sub-loss function is: Loss1=BCEWithLogitsLoss(D1,true).
12. The prediction system according to claim 11, characterized in that The verification of whether the original data can be predicted by GNET and whether it can be deviated from the actual value includes identifying the output D2 of the discriminant structure DNET as being generated by real data according to the sub-loss function Loss2, wherein Loss2=BCEWithLogitsLoss(D2,True).
13. The prediction system according to claim 12, characterized in that: The predicted output G1 is input into the output D3 of the adversarial network discriminant structure DNET to verify whether the disguised data ZK can be recognized, and whether G1 is generated by simulated data is determined according to the sub-loss function Loss3, where Loss3 = BCEWithLogitsLoss(D2,False).
14. The prediction system according to any one of claims 13, characterized in that: According to the sub-loss functions of different network results corresponding to fake data and real traffic data, the formula is called: d_Loss = Loss1 + Loss2 to calculate the loss function d_Loss so that the discriminant structure DNET can distinguish the disguised data and the real traffic data as much as possible, and the formula is called: g_Loss = 0.3*Loss3+0.7*MSELoss(H T+1 , ZK) calculates the loss function g_Loss so that the error between the output prediction result and the flow value of the next cycle is small enough, where MSELoss (H T+1 , ZK) is the disguised data and the real traffic data H of the T+1 period T+1 The mean square loss function.
15. An electronic device, characterized in that: include: A processor and a memory; wherein the processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to implement the traffic flow prediction system based on the BIDAF-GAN bidirectional attention flow adversarial network as described in any one of claims 8 to 14.
16. A computer-readable storage medium, characterized in that: The readable storage medium stores a program or instruction, which can be loaded and executed by a processor to execute the traffic flow prediction method based on the BIDAF-GAN bidirectional attention flow adversarial network as described in any one of claims 1 to 7.
Citation Information
Patent Citations
A Traffic Flow Prediction Method Based on Generative Adversarial Networks
CN112330952B
Short-term traffic demand prediction method fusing multi-scale space-time statistical information
CN112613630A
Urban traffic flow prediction method based on deep learning fusion model
CN111861027A
Building energy consumption prediction method based on deep cascade generative adversarial network and related products
CN112183826A