A traffic accident prediction method based on hard parameter sharing multi-task learning

Through the hard parameter sharing multi-task learning method, combined with multi-channel convolutional network, compression-stimulation network, Transformer network and long attention short-term memory network, the problems of low accuracy and incomplete results in existing traffic accident prediction are solved, and more accurate multi-task prediction is achieved.

CN116307103BActive Publication Date: 2025-08-19HENAN UNIVERSITY
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310121835.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-15
Publication Date
2025-08-19
Estimated Expiration
2043-02-15

AI Technical Summary

Technical Problem

The existing traffic accident prediction methods have problems with low prediction accuracy and incomplete results, and the deep learning model has shortcomings in dealing with spatial and temporal correlation, external factors and sample imbalance.

Method used

Using a method of shared multi-task learning based on hard parameters, a multi-task learning architecture is built through multi-channel convolutional network, compression-stimulation network, Transformer network and attention-long short-term memory network, a multi-task learning architecture is built, model parameters are shared, and combined with static and dynamic factor data is combined to construct a joint loss function for multi-task prediction.

Benefits of technology

A more comprehensive traffic accident prediction results are achieved, the prediction accuracy is improved, the sample imbalance problem is alleviated, the degree of influence of static factors and the time correlation of dynamic factors is captured, and more clear prediction results are provided.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116307103B_ABST
    Figure CN116307103B_ABST
Patent Text Reader

Abstract

The present invention proposes a traffic accident prediction method based on hard parameter sharing multi-task learning, which has the following steps: preprocessing the original traffic accident data; processing the data of external factors that affect the occurrence of traffic accidents to obtain static factor data and dynamic factor data respectively; extracting the features of various static factor data through a multi-channel convolutional network and a compression-excitation network; extracting the features of various dynamic factor data through a Transformer network; performing information fusion; constructing specific network layers according to different prediction tasks, and obtaining prediction values for different prediction tasks in the specific network layers; constructing a joint loss function for multiple prediction tasks, and using the Adam optimizer to obtain a prediction model; and using the prediction model to obtain prediction results for multiple traffic accident prediction tasks. The present invention realizes the joint learning of multiple traffic accident prediction tasks, provides more comprehensive and clearer traffic accident prediction results, and improves prediction accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of traffic accident prediction, and in particular to a traffic accident prediction method based on hard parameter sharing multi-task learning. Background Art

[0002] With the rapid development of cities and the dramatic increase in traffic volume, the frequency of traffic accidents has also increased significantly. According to the World Health Organization (WHO) 2018 Global Status of Road Safety report, approximately 1.35 million people die in road traffic accidents each year, and an additional 20 to 50 million suffer non-fatal injuries, many of whom become disabled. Road traffic accidents inflict enormous economic losses on individuals, families, and entire countries, accounting for 3% of the GDP of most countries. Traffic accident prediction can help governments and policymakers implement methods and strategies to reduce the losses caused by traffic accidents. For individuals, traffic accident prediction can help people avoid traffic accidents by providing early warning.

[0003] In the early days, traditional statistical and linear regression-based methods, such as support vector machines (SVMs) and autoregressive integrated moving averages (ARIMA), were widely used to predict traffic accidents. These methods treat the number of traffic accidents in a region as time series data. A limitation of these methods is that they fail to capture the complex spatial and temporal correlations between traffic accidents in different regions. In recent years, with the increasing availability of traffic data and the development of deep learning technology, various deep learning models, such as long short-term memory (LSTM) networks, convolutional neural networks (CNNs), autoencoders (AEs), and spatiotemporal attention-based models, have been applied to predict traffic accidents across entire cities. Deep learning models can effectively learn the nonlinear spatiotemporal correlations of traffic accident data, a significant improvement over traditional methods. However, these deep learning methods still have some challenges.

[0004] First, these deep learning methods primarily use a grid-like approach to regional division, dividing the entire city into a number of squares. This approach destroys the inherent properties of geography and disrupts spatially inherent geographic information, making it difficult to reconcile the predicted results with the original traffic zones. Second, most of these deep learning methods focus solely on predicting the risk index of future traffic accidents. The traffic risk index is a very vague metric, and the information available to non-experts is unclear and overly simplistic. Third, when considering the impact of external factors on traffic accidents, these deep learning methods often incorporate them into the model as inherent features, without considering the varying degrees of their impact. Finally, a common problem across all traffic accident prediction models is that, because traffic accidents are low-probability events, there are only a small number of non-zero samples over long periods of time. This leads to a serious sample imbalance, compromising the model's predictive performance. Summary of the Invention

[0005] In response to the technical problems of low prediction accuracy and incomplete prediction results in existing traffic accident prediction methods, the present invention proposes a traffic accident prediction method based on hard parameter sharing multi-task learning. By constructing a hard parameter sharing bottom layer to share the model parameters of multiple traffic accident prediction tasks, multiple tasks are combined and influence each other, thereby achieving comprehensive traffic accident prediction; and due to the mutually reinforcing nature of multi-task learning, the accuracy of each prediction task will be higher than that of a single prediction.

[0006] To achieve the above objectives, the technical solution of the present invention is implemented as follows: a traffic accident prediction method based on hard parameter sharing multi-task learning, the steps of which are as follows:

[0007] Step S1: Preprocess the original traffic accident data to obtain historical data for multiple prediction tasks;

[0008] Step S2: Processing the data of external factors that affect the occurrence of traffic accidents in the pre-processed historical data to obtain static factor data and dynamic factor data respectively;

[0009] Step S3: Use multi-channel convolutional networks, squeeze-and-excite networks, Transformer networks, and attention long short-term memory networks to build the hard parameter sharing bottom layer of the multi-task learning architecture;

[0010] Step S4: extracting the features of various static factor data through the combined action of the multi-channel convolutional network and the compression-excitation network to obtain static factor correlation information;

[0011] Step S5: Extract the features of various dynamic factor data through the Transformer network to obtain the correlation information of dynamic factors that affect the occurrence of traffic accidents over time;

[0012] Step S6: Fusing the static factor correlation information and the dynamic factor correlation information with the historical data of multiple prediction tasks to extract the impact of external factors on traffic accidents and obtain information fusion data; processing the information fusion data using the attention long short-term memory network to capture the complex temporal correlation of traffic accidents;

[0013] Step S7: constructing specific network layers according to different prediction tasks, extracting specific representations of different prediction tasks in the specific network layers, and obtaining prediction values of different prediction tasks;

[0014] Step S8: Construct a joint loss function for multiple prediction tasks, divide the historical data of multiple prediction tasks into a training set and a test set in a ratio of 8:2, and use the Adam optimizer and the training set to optimize the hard parameter shared bottom layer and specific network layers to obtain a prediction model;

[0015] Step S9: Save the trained prediction model, use the test set to predict the prediction model, and obtain prediction results for multiple traffic accident prediction tasks.

[0016] Preferably, the multiple prediction tasks include: a task of predicting a traffic accident risk index, a task of predicting whether a traffic accident will occur, and a task of predicting a traffic accident risk level.

[0017] Preferably, the preprocessing in step S1 is implemented by weighting the historical data of the traffic accident risk index prediction task according to the number and severity of traffic accidents that occurred in a certain period of time in the original traffic accident data to obtain a traffic accident risk index value:

[0018]

[0019] Among them, Δt is the time interval, d is the area, and s is the severity of the injury, which is divided into 4 levels according to slight injury with consciousness, slight injury without consciousness, severe injury, and death. score is the number of people with injury severity s in area d and time interval Δt; Δt,d It represents the traffic accident risk index value in area d and time interval Δt;

[0020] For the historical data of the task of predicting whether a traffic accident will occur, the Boolean value is used for binary classification based on the original data of the traffic accident. If a traffic accident occurs in a certain area d within a certain time interval, it is recorded as 1, and if it does not occur, it is recorded as 0;

[0021] For the historical data of the task of predicting traffic accident risk levels, the traffic accident risk index values of all times and all regions are arranged in ascending order, and the same values are eliminated. Then, the risk index is divided into three value ranges according to the ratio of 6:3:1, and recorded as low risk, medium risk and high risk levels respectively.

[0022] Preferably, the method for obtaining static factor data and dynamic factor data in step S2 is: summarizing and integrating the data of factors that do not change with time among the external factors affecting traffic accidents in the original data of traffic accidents as static factor data; summarizing and integrating the data of factors that change with time among the external factors affecting traffic accidents in the original data of traffic accidents as dynamic factor data; factors that do not change with time include points of interest, road characteristics or administrative area population; factors that change with time include weather, traffic flow or date.

[0023] Preferably, the processing method of the multi-channel convolutional network and the compression-excitation network in step S4 is: each static factor data is regarded as a feature channel and input into the multi-channel convolutional network, and the multi-channel convolutional network compresses its number of channels to the same as the batch size through the action of multiple channel convolution layers, and learns and aggregates the representation of the features of different static factor data on the local receptive field;

[0024] The data output by the multi-channel convolutional network is input into the compression-excitation network. The data output by the multi-channel convolutional network is compressed along the spatial dimension through the adaptive global average pooling layer, and each two-dimensional feature channel is converted into a real number. Then, weights are generated for each feature channel through two fully connected layers and two activation layers. The parameters are learned to explicitly model the correlation between feature channels. Finally, the dot product is performed channel by channel with the data output by the multi-channel convolutional network to complete the correlation weighted processing of the static factor data, and the weighted static factor data containing correlation, namely the static factor correlation information, is obtained. The activation functions of the two activation layers are ReLu activation function and Sigmoid activation function, respectively.

[0025] Preferably, the method for obtaining the dynamic factor correlation information in step S5 is as follows: inputting the dynamic factor data into the Transformer network, calculating the dynamic correlation weights of the dynamic factors of different attributes in their subspaces through the multi-head self-attention layer, and then merging the information in different subspaces in the multi-head self-attention joint layer; sending the merged data into the feedforward network through residual connection and normalization, and obtaining the weighted dynamic factor data containing dynamic correlation, i.e., dynamic factor correlation information, through the output data of the feedforward network through residual connection and normalization;

[0026] The information fusion in step S6 is implemented by combining historical data, static factor correlation information and dynamic factor correlation information of multiple prediction tasks to obtain information fusion data including historical data, static factor correlation information and dynamic factor correlation information.

[0027] Preferably, the processing method of the attention long short-term memory network in step S7 is: inputting the information fusion data into the attention long short-term memory network, and learning the time correlation in continuous time through the LSTM module, and the implementation process is expressed as follows:

[0028] f t =σ(W f [h t-1 ,X]+b f )

[0029] i t =σ(W i [h t-1 ,X]+b i )

[0030] c t =f t ⊙c t-1 +i t ⊙tanh(W c [h t-1 ,X]+b c );

[0031] o t =σ(W o [h t-1 ,X]+b o )

[0032] h t =o t ⊙tanh(c t )

[0033] Among them, f t is the output of the forget gate, i t and o t are the outputs of the input gate and output gate, c t and h t are the output and hidden state of each LSTM module respectively; W f 、W i 、W o are all learnable parameters, σ is the sigmoid activation function, h t-1 is the hidden state of the previous LSTM module, X is the input of the attention long short-term memory network, and b f 、b i 、b c 、b oare bias parameters, c t-1 is the output of the previous LSTM unit, ⊙ represents the dot product operation, and tanh represents the activation function;

[0034] Then for the hidden state h of the unit t The output of adopts the attention mechanism to adjust the correlation weights of long-term time and short-term time. The implementation process is:

[0035]

[0036] Where m is the number of time steps, W q and W k are all hyperparameters; Q is the query value, K t is the key value, α t is the attention value, Attention is the attention score, Softmax is the softmax function, and output is the output of the attention long short-term memory network.

[0037] Preferably, the parameters of different prediction tasks in the hard parameter sharing bottom layer are shared;

[0038] The specific network layers all use a multi-layer perceptron network to process the output data of the attention long short-term memory network to extract the specific representation of each prediction task and obtain the corresponding prediction value; the multi-layer perceptron network consists of two fully connected layers and is used to model the nonlinear relationship between features.

[0039] Preferably, the joint loss function of the multiple prediction tasks is:

[0040]

[0041] Among them, Loss BCE The loss function of binary cross entropy for predicting whether a traffic accident will occur is Loss CCE The loss function of the classification cross entropy for the task of predicting the risk level of traffic accidents is Loss MSE is the mean square error loss function for the task of predicting the traffic accident risk index. λ1, λ2, and λ3 are all hyperparameters that are adjusted through model training.

[0042] The loss function of the binary cross entropy is:

[0043]

[0044] Among them, Loss BCE is the binary cross entropy loss function, n is the total number of data in the validation set, y i is the true value of the corresponding data, is the predicted value of the corresponding data, and log represents the logarithmic function with base 10;

[0045] The loss function of the classification cross entropy is:

[0046]

[0047] Among them, Loss CCE is the classification cross entropy loss function, batch represents the batch size in the model;

[0048] The loss function of the mean square error is:

[0049]

[0050] Preferably, the method for obtaining the prediction model in step S8 is: using the Adam optimizer and the training set to optimize the hard parameter shared bottom layer and the specific network layer, adjusting all hyperparameters to a suitable range until the joint loss function Loss no longer decreases and terminating the training;

[0051] The implementation method of step S9 is: saving the parameters of the prediction model when the joint loss function is minimized as the parameters of the prediction model, using the test set to predict the prediction model, and obtaining the prediction results of the task of predicting the traffic accident risk index, the task of predicting whether a traffic accident will occur, and the task of predicting the traffic accident risk level.

[0052] Compared with the existing technology, the beneficial effects of the present invention are as follows: the present invention realizes the joint learning of three traffic accident prediction tasks, and can provide more comprehensive and clearer traffic accident prediction results. In addition, the present invention effectively alleviates the sample imbalance problem existing in the traffic accident prediction task by introducing a learnable joint loss function, improves the fitting effect of the model, and improves the accuracy of the prediction results. At the same time, the present invention captures the importance of each factor in the static factors affecting traffic accidents through the joint action of the multi-channel convolutional network and the compression-excitation network in the model, uses the Transformer network to capture the dynamic correlation between dynamic factors and traffic accidents over time, and uses the attention long short-term memory network to capture the complex time correlation of traffic accidents, which can achieve accurate traffic accident prediction. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0054] Figure 1 Flowchart of the present invention.

[0055] Figure 2 This is a framework diagram for data processing of the present invention.

[0056] Figure 3 This is a flow chart of the multi-channel convolutional network and compression-excitation network processing of static factor data in the present invention. DETAILED DESCRIPTION

[0057] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without creative work are within the scope of protection of the present invention.

[0058] like Figure 1 As shown in the figure, a traffic accident prediction method based on hard parameter sharing multi-task learning first establishes a shared underlying network based on static factor data, dynamic factor data, and historical data of multiple prediction tasks, which can achieve accurate traffic accident prediction tasks. Then, specific network layers are constructed for different prediction tasks. Multilayer perceptron networks are used in specific network layers to extract specific representations of the tasks. Finally, a prediction model is constructed to obtain the corresponding prediction values. The specific steps include:

[0059] Step S1: Preprocess the original traffic accident data of the Seoul2016 dataset and the Seoul2018 dataset to obtain historical data for multiple prediction tasks.

[0060] The implementation method of the pre-processing in step S1 is specifically as follows:

[0061] S1.1: For the historical data of the traffic accident risk index prediction task, the traffic accident risk index value is obtained by weighting the number and severity of traffic accidents that occurred within a certain period of time based on the original traffic accident data of the Seoul2016 dataset and the Seoul2018 dataset. The calculation method is:

[0062]

[0063] Among them, Δt is the time interval, d is the area, and s is the severity of the injury, which is divided into 4 levels according to slight injury with consciousness, slight injury without consciousness, severe injury, and death. score is the number of people with injury severity s in area d and time interval Δt; Δt,d It represents the traffic accident risk index value in area d and time interval Δt.

[0064] S1.2: For the historical data of the traffic accident prediction task, a binary classification is performed based on the original traffic accident data of the Seoul2016 dataset and the Seoul2018 dataset. If a traffic accident occurs in a certain area d within a certain time interval, it is recorded as 1, and if it does not occur, it is recorded as 0.

[0065] S1.3: For the historical data used in the traffic accident risk level prediction task, sort the traffic accident risk index values for all time periods and all regions obtained in step S1.1 from smallest to largest, remove duplicate values, and then categorize the risk index into three ranges with a ratio of 6:3:1, representing low, medium, and high risk levels. This risk index categorization makes risk assessment more scientific and data management more efficient. The Seoul2016 and Seoul2018 real-world datasets offer higher data accuracy, helping to better evaluate model performance and improve both accuracy and reliability.

[0066] Step S2: Process the data of external factors that may affect the occurrence of traffic accidents recorded in the Seoul2016 dataset and the Seoul2018 dataset to obtain static factor data and dynamic factor data respectively.

[0067] The specific implementation method of obtaining the static factor data and the dynamic factor data in step S2 is:

[0068] The static factor data were collected from the Seoul2016 and Seoul2018 datasets, including those that do not change over time, such as points of interest, road characteristics, and administrative area population. The dynamic factor data were collected from the Seoul2016 and Seoul2018 datasets, including those that change over time, such as weather, traffic volume, and date.

[0069] Distinguishing static data from dynamic data and processing them separately can help us analyze data more accurately and quickly, thereby obtaining more valuable results.

[0070] Step S3: Through the joint action of the multi-channel convolutional network and the compression-excitation network, the characteristics of various static factor data are extracted to obtain the correlation weights that affect the occurrence of traffic accidents, that is, the static factor correlation information.

[0071] The implementation method of step S3 is specifically as follows:

[0072] S3.1: Input the static factor data generated in step S2.1 into the multi-channel convolutional network. Figure 3As shown, each static factor data is treated as a feature channel and input into a multi-channel convolutional network. Through multiple channel convolutional layers, the number of channels is compressed to the same as the batch size, thereby learning and aggregating the representations of the features of different static factors in the local receptive field. The multi-channel convolutional network can extract the core features of the data, allowing the model to process data more efficiently. In addition, compressing the number of channels to the same as the batch size reduces the number of model parameters, thereby reducing training time and memory requirements.

[0073] S3.2: Input the data output by the multi-channel convolutional network in step S3.1 into the squeeze-excite network. Figure 3 As shown, an adaptive global average pooling layer compresses the output data of a multi-channel convolutional network along the spatial dimension, converting each two-dimensional feature channel into a real number with a global receptive field. Two fully connected layers and two activation functions are then used to generate weights for each feature channel. The parameters of these weights can be learned to explicitly model the correlation between feature channels. Finally, a channel-by-channel dot product is performed with the output data of the multi-channel convolutional network to weight the correlation of the static factor data and obtain weighted static factor data that includes correlations. The activation functions of the two activation layers are the ReLu and Sigmoid activation functions, respectively. The squeeze-and-excite network selectively enhances useful feature channels and suppresses useless ones, thereby extracting the correlation between various static factors that influence traffic accidents and improving the network's generalization ability. The squeeze-and-excite network also controls unnecessary information in the feature map, reducing overfitting. The combination of a multi-channel convolutional network and a squeeze-and-excite network for processing static factor data can rationally adjust the weights of various factors influencing traffic accidents, making traffic accident prediction more realistic, reasonable, rapid, and accurate.

[0074] Step S4: Extract the features of various dynamic factor data through the Transformer network to obtain the correlation information of dynamic factors that affect the occurrence of traffic accidents over time.

[0075] The implementation method of step S4 is specifically as follows:

[0076] S4.1: Input the dynamic factor data generated in step S2.2 into the Transformer network, calculate the dynamic correlation weights of the dynamic factors of different attributes in their subspaces through the multi-head self-attention layer, and then merge the information in different subspaces in the multi-head self-attention joint layer. This process can be expressed as:

[0077] MultiHead(Q,K,V)=Concat(head1,…,head h )W O

[0078] head i =Attention(QW i Q ,KW i K ,VW i V )

[0079] Among them, W O 、W i Q 、W i K 、W i V It is a hyperparameter, Concat() represents the concatenation operation, Attention() represents the calculation of the attention score, Q is the query value, K is the key value, and V is the attention value.

[0080] S4.2: The output data from step S4.1 is fed into the feedforward network through residual connections and normalization. Residual connections and normalization are used to reduce overfitting and prevent vanishing gradients. The feedforward network consists of two fully connected layers to exploit nonlinear relationships between features and enhance their expressiveness.

[0081] S4.3: The output data from step S4.2 is normalized through residual connections to obtain weighted dynamic factor data containing dynamic correlations, i.e., dynamic factor correlation information. Residual connections are used to prevent vanishing / exploding gradients and improve model performance. Normalization eliminates data inconsistencies and improves model stability and reliability.

[0082] Step S5: Information fusion is performed on the static factor correlation information and the dynamic factor correlation information with the historical data of multiple prediction tasks to extract the impact of external factors on traffic accidents and obtain information fusion data.

[0083] like Figure 2 As shown, the data generated by step S1, i.e., the historical data of multiple prediction tasks, the data generated by step S3.2, i.e., the static factor correlation information, and the data generated by step S4.3, i.e., the dynamic factor correlation information, are spliced to obtain fused data containing historical data, static factor correlation information, and dynamic factor correlation information, so that the impact of historical data, static factors, and dynamic factors on traffic accidents can be considered at the same time in the subsequent network.

[0084] Step S6: Use the attention long short-term memory network to process the information fusion data to capture the complex temporal correlation of traffic accidents.

[0085] The step S6 is specifically as follows: inputting the information fusion data generated in step S5 into the attention long short-term memory network, and learning the time correlation in the continuous time through the LSTM module. The implementation process can be expressed as follows:

[0086] f t =σ(W f [h t-1 ,X]+b f )

[0087] i t =σ(W i [h t-1 ,X]+b i )

[0088] c t =f t ⊙c t-1 +i t ⊙tanh(W c [h t-1 ,X]+b c );

[0089] o t =σ(W o [h t-1 ,X]+b o )

[0090] h t =o t ⊙tanh(c t )

[0091] Among them, f t is the output of the forget gate, i t and o t are the outputs of the input gate and output gate, c t and h t are the output and hidden state of each LSTM unit respectively. W f 、W i 、W o are all learnable parameters, σ is the sigmoid activation function, h t-1 is the hidden state of the previous LSTM unit, X is the input of the attention long short-term memory network, and b f 、b i 、b c 、b o are bias parameters, c t-1 is the output of the previous LSTM unit, ⊙ represents the dot product operation, and tanh represents the tanh activation function.

[0092] Then for the hidden state h of the unit tThe output of adopts the attention mechanism to adjust the correlation weights of long-term time and short-term time. Its implementation process can be expressed as:

[0093] Q=W q h t

[0094] K t =W k h t

[0095] α t =K t Τ Q

[0096] Attention=Softmax(α1,…,α m )

[0097]

[0098] Where m is the number of time steps, W q and W k are all hyperparameters. Q is the query value, K t is the key value, α t is the attention value, Attention is the attention score, Softmax is the softmax function, and output is the output of the attention long short-term memory network.

[0099] The attention long-short-term memory (LSTM) network processes information fusion data to capture the complex temporal dependencies of traffic accidents. Each LSTM module determines whether information from the current moment will be output to the next moment. The output of the attention long-short-term memory network is comprehensive feature data that influences the occurrence of traffic accidents. This data is then passed as input to specific network layers for different prediction tasks.

[0100] Step S7: Utilize the hard parameter sharing multi-task learning architecture and use the multi-layer perceptron network to extract specific representations of different prediction tasks and obtain prediction values.

[0101] The implementation method of step S7 is specifically as follows:

[0102] S7.1: If Figure 2 As shown, the networks mentioned in steps S3, S4, S5, and S6 serve as the hard parameter sharing layer of the multi-task learning architecture. The parameters of different prediction tasks are shared within this hard parameter sharing layer. Hard parameter sharing utilizes the same shared layer across multiple tasks and implements parameter sharing through a shared weight matrix and bias vector. This ensures the independence of each task while leveraging the relationships and similarities between all tasks to improve model performance.

[0103] S7.2: Build specific network layers for each prediction task. Use a multilayer perceptron (MLP) network in each layer to extract task-specific representations and ultimately obtain the corresponding predictions. The MLP network consists of two fully connected layers, which model nonlinear relationships between features. In each task-specific layer, the model calculates its loss function and updates its parameters to minimize the combined loss function.

[0104] S7.3: Use binary cross entropy as the loss function for the task of predicting whether a traffic accident will occur:

[0105]

[0106] Among them, Loss BCE is the binary cross entropy loss function, n is the total number of data in the validation set, y i is the true value of the corresponding data, It is the predicted value of the corresponding data, log represents the logarithmic function with base 10; the binary cross entropy loss function is used to judge the quality of the prediction results of a two-classification model.

[0107] S7.4: Use categorical cross entropy as the loss function for the task of predicting traffic accident risk level:

[0108]

[0109] Among them, Loss CCE is the categorical cross entropy loss function, and batch represents the batch size in the model. The categorical cross entropy loss function is used to measure the probability error in discrete classification tasks.

[0110] S7.5: Use mean squared error as the loss function for the task of predicting traffic accident risk index:

[0111]

[0112] The mean square error is a loss function that reflects the degree of difference between the estimator and the estimated quantity.

[0113] Step S8: Construct a joint loss function for multiple tasks and use the Adam optimizer to optimize the prediction model.

[0114] The implementation method of step S8 is specifically as follows:

[0115] S8.1: The joint loss function is:

[0116]

[0117] Among them, Loss BCEis the loss function of the binary cross entropy in step S7.3, Loss CCE is the loss function of the classification cross entropy in step S7.4, Loss MSE is the mean square error loss function in step S7.5, λ1, λ2, and λ3 are all hyperparameters that are adjusted through model training.

[0118] S8.2: Divide the historical data of multiple prediction tasks into training and test sets in an 8:2 ratio. Use the Adam optimizer and the training set to optimize the process involving the multi-task learning model based on hard parameter sharing. The specific steps are: 1. Initialize the parameters; 2. Calculate the gradient; 3. Calculate the quadratic momentum; 4. Adjust the learning rate; 5. Update the parameters; 6. Repeat steps 2-5 until the joint loss function Loss no longer decreases and terminate the training.

[0119] Step S9: Save the trained prediction model, use the test set to predict the prediction model, and obtain prediction results for multiple traffic accident prediction tasks.

[0120] The specific steps of step S9 are: saving the parameters of the prediction model when the joint loss function obtained in step S8.2 is minimized as the parameters of the prediction model, using the test set to predict the prediction model, and obtaining the prediction results of the task of predicting the traffic accident risk index, the task of predicting whether a traffic accident will occur, and the task of predicting the traffic accident risk level.

[0121] The present invention proposes a multi-task learning method based on a hard parameter sharing architecture, which realizes the joint learning of three traffic accident prediction tasks, and can provide more comprehensive and clearer traffic accident prediction results. In addition, the present invention effectively alleviates the sample imbalance problem existing in the traffic accident prediction task by introducing a learnable joint loss function, improves the fitting effect of the model, and improves the accuracy of the prediction results. At the same time, the present invention captures the importance of each factor in the static factors affecting traffic accidents through the joint action of the multi-channel convolutional network and the compression-excitation network in the model, uses the Transformer module to capture the dynamic correlation between dynamic factors and traffic accidents over time, and uses the attention long short-term memory network to capture the complex time correlation of traffic accidents, which can achieve accurate traffic accident prediction.

[0122] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A traffic accident prediction method based on hard parameter sharing multi-task learning, characterized in that: The steps are as follows: Step S1: Preprocess the original traffic accident data to obtain historical data for multiple prediction tasks; Step S2: Processing the data of external factors that affect the occurrence of traffic accidents in the pre-processed historical data to obtain static factor data and dynamic factor data respectively; Step S3: Use multi-channel convolutional networks, squeeze-and-excite networks, Transformer networks, and attention long short-term memory networks to build the hard parameter sharing bottom layer of the multi-task learning architecture; Step S4: extracting the features of various static factor data through the combined action of the multi-channel convolutional network and the compression-excitation network to obtain static factor correlation information; The processing method of the multi-channel convolutional network and the compression-excitation network in step S4 is as follows: each static factor data is regarded as a feature channel and input into the multi-channel convolutional network, and the multi-channel convolutional network compresses the number of its channels to the same as the batch size through the action of multiple channel convolution layers, and learns and aggregates the representation of the features of different static factor data in the local receptive field; The data output by the multi-channel convolutional network is input into the compression-excitation network. The data output by the multi-channel convolutional network is compressed along the spatial dimension through an adaptive global average pooling layer, converting each two-dimensional feature channel into a real number. Then, two fully connected layers and two activation layers are used to generate weights for each feature channel. The parameters are learned to explicitly model the correlation between feature channels. Finally, the dot product is summed channel by channel with the data output by the multi-channel convolutional network to complete the correlation weighting processing of the static factor data, obtaining weighted static factor data containing correlation, namely static factor correlation information. Step S5: Extract the features of various dynamic factor data through the Transformer network to obtain the correlation information of dynamic factors that affect the occurrence of traffic accidents over time; Step S6: Fusing the static factor correlation information and the dynamic factor correlation information with the historical data of multiple prediction tasks to extract the impact of external factors on traffic accidents and obtain information fusion data; processing the information fusion data using the attention long short-term memory network to capture the complex temporal correlation of traffic accidents; Step S7: constructing specific network layers according to different prediction tasks, extracting specific representations of different prediction tasks in the specific network layers, and obtaining prediction values of different prediction tasks; The specific network layers all use a multi-layer perceptron network to process the output data of the attention long short-term memory network to extract the specific representation of each prediction task and obtain the corresponding prediction value; the multi-layer perceptron network consists of two fully connected layers for modeling the nonlinear relationship of features; Step S8: Construct a joint loss function for multiple prediction tasks, divide the historical data of multiple prediction tasks into a training set and a test set in a ratio of 8:2, and use the Adam optimizer and the training set to optimize the hard parameter shared bottom layer and specific network layers to obtain a prediction model; Step S9: Save the trained prediction model, use the test set to predict the prediction model, and obtain prediction results for multiple traffic accident prediction tasks.

2. The traffic accident prediction method based on hard parameter sharing multi-task learning according to claim 1 is characterized in that: The multiple prediction tasks include: a task of predicting a traffic accident risk index, a task of predicting whether a traffic accident will occur, and a task of predicting a traffic accident risk level.

3. The traffic accident prediction method based on hard parameter sharing multi-task learning according to claim 2 is characterized in that: The implementation method of the pre-processing in step S1 is as follows: for the historical data of the task of predicting the traffic accident risk index, the traffic accident risk index value is obtained by weighting the original data of traffic accidents according to the number and severity of traffic accidents that occurred within a certain period of time: Among them, Δt is the time interval, d is the area, and s is the severity of the injury, which is divided into 4 levels according to slight injury with consciousness, slight injury without consciousness, severe injury, and death. score is the number of people with injury severity s in area d and time interval Δt; Δt,d It represents the traffic accident risk index value in area d and time interval Δt; For the historical data of the task of predicting whether a traffic accident will occur, a binary classification is performed based on the original data of the traffic accident. If a traffic accident occurs in a certain area d within a certain time interval, it is recorded as 1, and if it does not occur, it is recorded as 0; For the historical data of the task of predicting traffic accident risk levels, the traffic accident risk index values of all times and all regions are arranged in ascending order, and the same values are eliminated. Then, the risk index is divided into three value ranges according to the ratio of 6:3:1, and recorded as low risk, medium risk and high risk levels respectively.

4. The traffic accident prediction method based on hard parameter sharing multi-task learning according to claim 2 or 3 is characterized in that: The method for obtaining the static factor data and the dynamic factor data in step S2 is: summarizing and integrating the data of the factors that do not change over time among the external factors affecting the traffic accident in the original traffic accident data as the static factor data; The data of factors that change over time among the external factors that affect traffic accidents in the original traffic accident data are summarized and integrated as dynamic factor data; factors that do not change over time include points of interest, road characteristics or administrative area population; factors that change over time include weather, traffic flow or date.

5. The traffic accident prediction method based on hard parameter sharing multi-task learning according to claim 4 is characterized in that: The method for obtaining the dynamic factor correlation information in step S5 is as follows: inputting the dynamic factor data into the Transformer network, calculating the dynamic correlation weights of the dynamic factors of different attributes in their subspaces through the multi-head self-attention layer, and then merging the information in different subspaces in the multi-head self-attention joint layer; sending the merged data into the feedforward network through residual connection and normalization, and obtaining the weighted dynamic factor data containing dynamic correlation, i.e., the dynamic factor correlation information, through the output data of the feedforward network through residual connection and normalization; The information fusion in step S6 is implemented by combining historical data, static factor correlation information and dynamic factor correlation information of multiple prediction tasks to obtain information fusion data including historical data, static factor correlation information and dynamic factor correlation information.

6. The traffic accident prediction method based on hard parameter sharing multi-task learning according to claim 5 is characterized in that: The processing method of the attention long short-term memory network in step S7 is: inputting the information fusion data into the attention long short-term memory network, and learning the time correlation in the continuous time through the LSTM module. The implementation process is expressed as follows: f t =σ(W f [h t-1 ,X]+b f ) i t =σ(W i [h t-1 ,X]+b i ) c t =f t ⊙c t-1 +i t ⊙tanh(W c [h t-1 ,X]+b c ); the t =σ(W o [h t-1 ,X]+b o ) h t =o t ⊙tanh(c t ) Among them, f t is the output of the forget gate, i t and o t are the outputs of the input gate and output gate, c t and h t are the output and hidden state of each LSTM module respectively; W f 、W i 、W o are all learnable parameters, σ is the sigmoid activation function, h t-1 is the hidden state of the previous LSTM module, X is the input of the attention long short-term memory network, and b f 、b i 、b c 、b o are bias parameters, c t-1 is the output of the previous LSTM unit, ⊙ represents the dot product operation, and tanh represents the activation function; Then for the hidden state h of the unit t The output of adopts the attention mechanism to adjust the correlation weights of long-term time and short-term time. The implementation process is: Where m is the number of time steps, W q and W k are all hyperparameters; Q is the query value, K t is the key value, α t is the attention value, Attention is the attention score, Softmax is the softmax function, and output is the output of the attention long short-term memory network.

7. The traffic accident prediction method based on hard parameter sharing multi-task learning according to claim 5 or 6, characterized in that: The parameters of different prediction tasks in the hard parameter sharing layer are shared.

8. The traffic accident prediction method based on hard parameter sharing multi-task learning according to claim 7 is characterized in that: The joint loss function of the multiple prediction tasks is: Among them, Loss BCE The loss function of binary cross entropy for predicting whether a traffic accident will occur is Loss CCE The loss function of the classification cross entropy for the task of predicting the risk level of traffic accidents is Loss MSE is the mean square error loss function for the task of predicting the traffic accident risk index. λ1, λ2, and λ3 are all hyperparameters that are adjusted through model training. The loss function of the binary cross entropy is: Among them, Loss BCE is the binary cross entropy loss function, n is the total number of data in the validation set, y i is the true value of the corresponding data, is the predicted value of the corresponding data, and log represents the logarithmic function with base 10; The loss function of the classification cross entropy is: Among them, Loss CCE is the classification cross entropy loss function, batch represents the batch size in the model; The loss function of the mean square error is:

9. The traffic accident prediction method based on hard parameter sharing multi-task learning according to claim 8 is characterized in that: The method for obtaining the prediction model in step S8 is: using the Adam optimizer and the training set to optimize the hard parameter shared bottom layer and the specific network layer, adjusting all hyperparameters to a suitable range until the joint loss function Loss no longer decreases and terminating the training; The implementation method of step S9 is: saving the parameters of the prediction model when the joint loss function is minimized as the parameters of the prediction model, using the test set to predict the prediction model, and obtaining the prediction results of the task of predicting the traffic accident risk index, the task of predicting whether a traffic accident will occur, and the task of predicting the traffic accident risk level.

Citation Information

Patent Citations

  • Traffic accident prediction method based on space-time diagram convolutional network

    CN113268916A