Traffic risk analysis method and device based on graph neural network
Through a graph neural network-based method, the historical trajectory and lane line information of the intelligent agent are encoded and decoded to construct a risk analysis model. This solves the problem that the existing traffic risk analysis methods cannot adequately describe the future intentions and potential risks of traffic participants, and achieves higher analysis depth and accuracy.
Patent Information
- Application Number
- CN202510684885.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-26
- Publication Date
- 2025-09-05
Smart Images

Figure CN120599809A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of autonomous driving risk analysis, and in particular to a traffic risk analysis method and analysis device based on graph neural networks. Background Art
[0002] With the development of social economy, autonomous driving of automobiles is becoming more and more popular. However, current autonomous driving decision-making technology still faces a series of challenges in complex mixed traffic scenarios. Among them, how to correctly analyze traffic risks is an issue that needs to be solved urgently.
[0003] In related technologies, technicians can analyze traffic risks by using simple one-dimensional risk analysis methods or methods based on field theory. The simple one-dimensional risk analysis method performs rapid risk assessment through a single key indicator; the field theory-based method can quantify the risk intensity of each location in the traffic environment by constructing a dynamic risk field, and can simultaneously consider the impact of spatial position and dynamic interaction.
[0004] However, in related technologies, simple one-dimensional risk analysis methods are difficult to accurately describe the omnidirectional traffic risks existing on the road and have limited effectiveness in complex and time-varying traffic environments. Although the analysis method based on field theory can analyze various types of risks omnidirectionally and is suitable for complex and changeable traffic scenarios, the depth of risk analysis of traffic participants is limited, and it is difficult to accurately describe the future intentions and potential risks of traffic participants, which urgently needs to be improved. Summary of the Invention
[0005] The present application provides a traffic risk analysis method and analysis device based on graph neural network to solve the problems of traffic risk analysis methods in related technologies, such as limited depth of risk analysis of traffic participants and difficulty in accurately describing the future intentions and potential risks of traffic participants.
[0006] The first aspect of the present application provides a traffic risk analysis method based on a graph neural network, comprising the following steps: obtaining historical trajectory information of at least one intelligent agent and lane line information of a map; encoding using a graph encoder based on the historical trajectory information and the lane line information to obtain adjacency matrix features; encoding using an attention mechanism based on the adjacency matrix features to obtain an attention mechanism encoding result; using a multimodal query password that obeys a normal distribution, decoding using a cross-attention mechanism based on the attention mechanism encoding result to obtain a cross-attention mechanism decoding result; based on the cross-attention mechanism decoding result, using a multi-layer perceptron to decode the predicted trajectory, and using cross loss and regression loss to calculate the predicted trajectory loss to obtain a decoding result; based on the decoding result, using a deconvolution network to decode, and using a probability loss function to calculate the risk matrix loss, and performing model training and verification to obtain a risk analysis model based on a graph neural network to predict traffic risks.
[0007] Through the above technical solution, the embodiment of the present application can first encode the acquired historical trajectory information and lane line information twice, converting the complex traffic scene into a structured representation that can be understood by the machine, realizing the capture of long-distance dependencies, dynamically adjusting the weights of the adjacency matrix features, and improving the depth of traffic risk analysis; then, based on the encoding results, a multi-layer perceptron and a deconvolutional neural network are used for decoding to obtain the predicted trajectory loss and risk matrix loss to train the risk analysis model, integrate the complex and dynamic human-vehicle-road driving environment elements into a unified and explainable decision-making evaluation objective model, use subjective driving data to fit the objective evaluation model, and improve the accuracy, generalization and adaptability of the decision-making evaluation.
[0008] Optionally, in one embodiment of the present application, the adjacency matrix feature is represented as:
[0009]
[0010] in, is the feature vector of feature j in layer l, g enc is a multi-layer perceptron, It is the maximum pooling layer, which obtains the maximum value of the input feature vector in the time series direction after passing through the multi-layer perceptron. For the splicing layer, is the l-th layer input vector for feature j.
[0011] Through the above technical solution, the embodiment of the present application can construct a solution expression for the adjacency matrix features using the historical trajectory information of the intelligent body and the information of the lane centerline as parameters, providing reliable data guidance and basis for subsequent encoding using the attention mechanism, and effectively ensuring the smooth implementation of subsequent encoding.
[0012] Optionally, in one embodiment of the present application, the use of a probability loss function to calculate the risk matrix loss includes: randomly selecting multiple loss points of the risk matrix; and calculating the risk probability value of each loss point to determine the risk matrix loss.
[0013] Through the above technical solution, the embodiment of the present application can iteratively train the model by determining the risk matrix loss, calculate the difference between the predicted value and the true value based on the loss function, generate gradients through back propagation, guide the parameters to be updated in the direction of reducing the error, and improve the model prediction accuracy.
[0014] Optionally, in one embodiment of the present application, the calculation formula of the risk probability value is:
[0015]
[0016] Among them, d is the distance between the selected point and the predicted point, σ is an empirical value related to the heading angle and speed, θ is the angle difference between the angle between the selected point and the risk source vehicle and the heading angle of the vehicle, and v is the speed of the risk source vehicle.
[0017] Through the above technical solution, the embodiment of the present application can convert abstract risks into specific probability values by calculating risk probability values, and can dynamically adjust the weight of the loss function according to the risk probability, associate risk probability with loss, and provide a transparent decision-making basis.
[0018] Optionally, in one embodiment of the present application, the calculation formulas for the cross loss and regression loss are respectively:
[0019]
[0020] L reg =αL ADE +(1-α)L FDE (10)
[0021] Among them, L cls is the cross entropy loss function, N is the number of samples, K is the number of categories, is the prediction score of sample i for category K, k * is the true category of sample i, ∈ is a constant, L reg is the regression loss, L FDE is the distance deviation between the predicted trajectory and the last predicted point of the true trajectory, L ADE is the average distance deviation between the predicted trajectory and the true trajectory, and α is a proportional coefficient.
[0022] Through the above technical solution, the embodiment of the present application can obtain a more accurate predicted trajectory decoding result by determining the cross loss and regression loss and using the cross loss and regression loss to coordinately train the trajectory prediction.
[0023] A second aspect of the present application provides a traffic risk analysis device based on a graph neural network, comprising: an acquisition module for acquiring historical trajectory information of at least one intelligent agent and lane line information of a map;
[0024] The first encoding module is used to encode the historical trajectory information and the lane line information using a graph encoder to obtain adjacency matrix features; the second encoding module is used to encode the adjacency matrix features using an attention mechanism to obtain an attention mechanism encoding result; the first decoding module is used to use a multimodal query password that obeys a normal distribution and decode the attention mechanism encoding result using a cross-attention mechanism to obtain a cross-attention mechanism decoding result; the second decoding module is used to decode the predicted trajectory using a multi-layer perceptron based on the cross-attention mechanism decoding result, and calculate the predicted trajectory loss using cross loss and regression loss to obtain a decoding result; the analysis module is used to decode based on the decoding result using a deconvolution network, calculate the risk matrix loss using a probability loss function, and perform model training and verification to obtain a risk analysis model based on a graph neural network to predict traffic risks.
[0025] Through the above technical solution, the embodiment of the present application can first encode the acquired historical trajectory information and lane line information twice, converting the complex traffic scene into a structured representation that can be understood by the machine, realizing the capture of long-distance dependencies, dynamically adjusting the weights of the adjacency matrix features, and improving the depth of traffic risk analysis; then, based on the encoding results, a multi-layer perceptron and a deconvolutional neural network are used for decoding to obtain the predicted trajectory loss and risk matrix loss to train the risk analysis model, integrate the complex and dynamic human-vehicle-road driving environment elements into a unified and explainable decision-making evaluation objective model, use subjective driving data to fit the objective evaluation model, and improve the accuracy, generalization and adaptability of the decision-making evaluation.
[0026] Optionally, in one embodiment of the present application, the adjacency matrix feature is represented as:
[0027]
[0028] in, is the feature vector of feature j in layer l, g enc is a multi-layer perceptron, It is the maximum pooling layer, which obtains the maximum value of the input feature vector in the time series direction after passing through the multi-layer perceptron. For the splicing layer, is the l-th layer input vector for feature j.
[0029] Through the above technical solution, the embodiment of the present application can construct a solution expression for the adjacency matrix features using the historical trajectory information of the intelligent body and the information of the lane centerline as parameters, providing reliable data guidance and basis for subsequent encoding using the attention mechanism, and effectively ensuring the smooth implementation of subsequent encoding.
[0030] Optionally, in one embodiment of the present application, the analysis module includes: a selection unit for randomly selecting multiple loss points of the risk matrix; and a calculation unit for calculating the risk probability value of each loss point to determine the risk matrix loss.
[0031] Through the above technical solution, the embodiment of the present application can iteratively train the model by determining the risk matrix loss, calculate the difference between the predicted value and the true value based on the loss function, generate gradients through back propagation, guide the parameters to be updated in the direction of reducing the error, and improve the model prediction accuracy.
[0032] Optionally, in one embodiment of the present application, the calculation formula of the risk probability value is:
[0033]
[0034] Among them, d is the distance between the selected point and the predicted point, σ is an empirical value related to the heading angle and speed, θ is the angle difference between the angle between the selected point and the risk source vehicle and the heading angle of the vehicle, and v is the speed of the risk source vehicle.
[0035] Through the above technical solution, the embodiment of the present application can convert abstract risks into specific probability values by calculating risk probability values, and can dynamically adjust the weight of the loss function according to the risk probability, associate risk probability with loss, and provide a transparent decision-making basis.
[0036] Optionally, in one embodiment of the present application, the calculation formulas for the cross loss and regression loss are respectively:
[0037]
[0038] L reg =αL ADE +(1-α)L FDE (10)
[0039] Among them, L cls is the cross entropy loss function, N is the number of samples, L is the number of categories, is the prediction score of sample i for category L, k * is the true category of sample i, ∈ is a constant, L reg is the regression loss, L FDE is the distance deviation between the predicted trajectory and the last predicted point of the true trajectory, L ADEis the average distance deviation between the predicted trajectory and the true trajectory, and α is a proportional coefficient.
[0040] Through the above technical solution, the embodiment of the present application can obtain a more accurate predicted trajectory decoding result by determining the cross loss and regression loss and using the cross loss and regression loss to coordinately train the trajectory prediction.
[0041] The third aspect of the present application provides an electronic device, comprising: a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor executes the program to implement a traffic risk analysis method based on a graph neural network as described in the above embodiment.
[0042] The fourth aspect of the present application provides a computer-readable storage medium, which stores a computer program. When the program is executed by a processor, it implements the above-mentioned traffic risk analysis method based on graph neural network.
[0043] The fifth aspect of the present application provides a computer program product, which stores a computer program that, when executed by a processor, implements the above-mentioned traffic risk analysis method based on graph neural network.
[0044] The embodiments of the present application can perform graph encoding and attention mechanism encoding based on the acquired historical trajectory and lane line information of the intelligent agent, and then perform cross-attention mechanism decoding and deconvolution network decoding in sequence based on the encoding results to obtain a risk analysis model based on a graph neural network to predict traffic risks. The embodiments of the present application can effectively integrate the complex and dynamic human-vehicle-road driving environment elements into a unified and interpretable objective model for decision evaluation. The objective evaluation model is fitted with subjective driving data to obtain a generalized autonomous driving decision performance evaluation method that integrates subjective and objective factors, thereby improving the accuracy, generalization, and adaptability of decision evaluation. This solves the problems of the traffic risk analysis methods in related technologies, such as the limited depth of risk analysis of traffic participants and the difficulty in accurately describing the future intentions and potential risks of traffic participants.
[0045] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0047] Figure 1 A flow chart of a traffic risk analysis method based on a graph neural network provided according to an embodiment of the present application;
[0048] Figure 2 Schematic diagram of a flow chart of a traffic risk analysis method based on a graph neural network according to a specific embodiment of the present application;
[0049] Figure 3 This is a schematic diagram of risk analysis results of a traffic risk analysis method based on a graph neural network according to a specific embodiment of the present application;
[0050] Figure 4 Schematic diagram of the structure of a traffic risk analysis device based on a graph neural network according to an embodiment of the present application;
[0051] Figure 5 A schematic diagram of the structure of an electronic device provided according to an embodiment of the present application. DETAILED DESCRIPTION
[0052] The following describes in detail embodiments of the present application, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.
[0053] The following describes a graph neural network-based traffic risk analysis method and apparatus according to an embodiment of the present application with reference to the accompanying drawings. To address the issues mentioned in the background art center regarding the limited depth of risk analysis for traffic participants and the difficulty in accurately describing the future intentions and potential risks of traffic participants, the present application provides a graph neural network-based traffic risk analysis method. In this method, graph encoding and attention mechanism encoding can be performed based on the acquired historical trajectory and lane line information of the intelligent agent. Cross-attention mechanism decoding and deconvolution network decoding are then performed sequentially based on the encoded results to obtain a graph neural network-based risk analysis model to predict traffic risks. This effectively integrates the complex and dynamic human-vehicle-road driving environment elements into a unified, interpretable objective model for decision evaluation. The objective evaluation model is fitted using subjective driving data to obtain a generalized autonomous driving decision performance evaluation method that integrates subjective and objective factors, thereby improving the accuracy, generalization, and adaptability of decision evaluation. This method addresses the issues mentioned in the background art regarding the limited depth of risk analysis for traffic participants and the difficulty in accurately describing the future intentions and potential risks of traffic participants.
[0054] Specifically, Figure 1 A flow chart of a traffic risk analysis method based on a graph neural network provided in an embodiment of the present application.
[0055] like Figure 1 As shown in FIG, the traffic risk analysis method based on graph neural network includes the following steps:
[0056] In step S101, historical trajectory information of at least one intelligent agent and lane line information of a map are obtained.
[0057] Among them, the intelligent agent in the embodiment of the present application can be understood as a vehicle, and the historical trajectory information of the intelligent agent includes but is not limited to the historical trajectory information of the intelligent agent to be analyzed and the historical trajectory information of the surrounding intelligent agents; the lane line information of the map includes but is not limited to the center line information and boundary line information of the lanes around the intelligent agent.
[0058] During the actual implementation process, the embodiments of the present application can obtain the vehicle's historical trajectory information and lane line information through other information collection devices such as sensors installed on the vehicle and around the road. For example, the embodiments of the present application can obtain the vehicle's own historical trajectory through the inertial navigation and lidar of the on-board terminal; obtain the historical trajectory of surrounding vehicles through the camera and millimeter-wave radar of the on-board terminal; and obtain lane line information through high-precision maps and intelligent roadside equipment.
[0059] The embodiments of the present application can obtain multi-dimensional vehicle driving information and traffic environment information by collecting historical trajectory information and lane line information, integrating complex and dynamic human-vehicle-road driving environment element information to improve the depth and accuracy of risk analysis.
[0060] In step S102 , a graph encoder is used to encode the historical trajectory information and lane line information to obtain adjacency matrix features.
[0061] A graph encoder can be understood as a neural network model that maps graph-structured data into a low-dimensional vector representation. It is primarily used to capture complex patterns in nodes, edges, and global topological relationships within a graph. It can consist of an input layer, a message passing layer, and an output layer. Adjacency matrix features can be understood as numerical features extracted from the adjacency matrix that describe the graph structure or node relationships. These features can be used for graph neural networks, graph embedding, or traditional graph analysis tasks.
[0062] As an implementable approach, the embodiment of the present application can process the acquired historical trajectory information and lane line information after acquiring the acquired information to obtain the information input required by the image encoder; the processing process is as follows:
[0063]
[0064] in, is the agent’s vector at each moment, is the x-coordinate of the position of the i-th agent at time t, is the y coordinate of the position of the i-th agent at time t, is the x-direction velocity of the ith agent at time t, is the velocity of the ith agent in the y direction at time t.
[0065] The coordinate system takes the position of the agent with predicted risk as the origin, the orientation of the agent is in the x-direction, and the coordinate system conforms to the right-hand system.
[0066]
[0067] in, is the vector of the lane line at each sampling point is the x-coordinate of the k-th sampling point of the i-th lane line, is the y coordinate of the kth sampling point of the i-th lane line.
[0068]
[0069] Among them, Fagent is the temporal processing of the agent vector, which represents the concatenation of the vector at time t, time t+1, and the difference between time t+1 and time t. After Fagent concatenation, the vector is of length 12.
[0070] is the vector of agent i at time t, is the vector of agent i at time t+1.
[0071]
[0072] Among them, Flane is the processing of the lane line vector in the sequence, which represents the difference between the vector at the k sampling point, the k+1 sampling point, and the k+1 sampling point and the k sampling point. is the vector of lane line i at k sampling point, is the vector of lane line i at the k+1 sampling point.
[0073] After obtaining the input information required by the graph encoder, the embodiment of the present application can use the graph encoder to encode the feature matrix based on the obtained input information to obtain the adjacency matrix features, specifically:
[0074]
[0075] in, is the feature vector of feature j in layer l, including (Fagent, Flane), g enc is a multi-layer perceptron, It is the maximum pooling layer, which obtains the maximum value of the input feature vector in the time series direction (sampling point sequence direction) after passing through the multi-layer perceptron. It is the concatenation layer, which performs concatenation in the feature dimension to obtain the processed graph encoding vector is the l-th layer input vector of feature j. When l is 0, Vj is the historical trajectory information or lane line information; at other times, V j is the V of the l-1th layer i , which is the output of the previous layer.
[0076]
[0077] Among them, p is a maximum pooling layer, which performs maximum pooling in the temporal dimension to obtain the processed graph encoding feature vector. The result calculated by formula (5) when l = 3 is the output result of the last layer of graph encoder. Since the number of graph encoder layers used in our model is 3, it is written here as
[0078] The embodiment of the present application can use a graph encoder to convert the input traffic scene into a reasonable, differentiable, and interpretable graph structure, which can convert complex traffic scenes into a structured representation that can be understood by machines, effectively improving the computational efficiency and interpretability of the model.
[0079] In step S103, based on the adjacency matrix features, an attention mechanism is used for encoding to obtain an attention mechanism encoding result.
[0080] It is understandable that the attention mechanism is a technology in deep learning that simulates human cognitive attention. It focuses on key information by dynamically allocating weights and can be applied to natural language processing, computer vision and other fields.
[0081] In some embodiments, encoding is performed using a self-attention mechanism based on the adjacency matrix encoding result, which can be achieved as follows:
[0082] Q=W Q X,K=W Q Y,V=W Q Y(7)
[0083] Where Q is the query vector in the attention mechanism, X and Y are the vectors input to the attention mechanism, including the intelligent body map encoding vector and lane line map encoding vector output by formula (6). When it is a self-attention mechanism, Y = X; when it is a cross-attention mechanism, Y is the value vector; W Q It is a linear layer, K and V are the key vector and value vector respectively, and the processing process and corresponding input are the same as Q.
[0084]
[0085] Among them, formula (8) is the specific calculation process of the attention mechanism, softmax is a nonlinear layer, d k is a constant.
[0086] Among them, the agent historical trajectory encoding result and lane centerline encoding result matrix in step S102 can be encoded using the self-attention mechanism respectively to obtain the encoding result.
[0087] The embodiment of the present application can first use a graph encoder to encode the historical trajectory information of the intelligent agent and the lane line information of the map, converting the complex traffic scene into a structured representation that can be understood by the machine, and then continue encoding using the self-attention mechanism, thereby capturing long-distance dependencies and dynamically adjusting the weights of the adjacency matrix features, significantly improving the performance of the model in complex tasks, and further enhancing the depth of traffic risk analysis.
[0088] In step S104, a multimodal query password that obeys a normal distribution is used, and the encoding result based on the attention mechanism is decoded using the cross-attention mechanism to obtain a cross-attention mechanism decoding result.
[0089] As you can understand, the cross-attention mechanism is an important variant of the attention mechanism, primarily used to handle interactions between two different sequences or modalities, dynamically calculating the dependency of one sequence (the target sequence) on another (the source sequence). A multimodal query is a query generated by sampling feature vectors extracted from different modalities (text, images, audio, etc.) using a normal distribution.
[0090] In the actual implementation process, the embodiment of the present application can be based on a multimodal query password that obeys a normal distribution, use the above password as a priori information for decoding to guide the generation process, and input the attention mechanism encoding result into the decoder, and use the cross-attention mechanism in the decoder to decode the encoding result. For example, by introducing a multimodal decoder query password m∈B×M×D, where the feature dimension D satisfies the normal distribution, B represents the batch size of the training process, and M represents the number of modalities of the predicted trajectory, the password m is used as the Q value of the attention mechanism, and the two matrices obtained in step S103 are both used as K and V. The cross-attention mechanism is used to extract the correlation between the query password and the two matrices to obtain a query password containing prediction information.
[0091] Through the above technical solution, the embodiment of the present application can decode the attention mechanism encoding results by combining the cross-attention mechanism of the normally distributed multimodal query, thereby increasing the diversity of the generated results. When the decoder generates each output, it can dynamically focus on the most relevant part of the encoder output, realize dynamic context-aware decoding, and seamlessly integrate the encoded information from different modalities.
[0092] In step S105, based on the decoding result of the cross attention mechanism, a multi-layer perceptron is used to decode the predicted trajectory, and the predicted trajectory loss is calculated using the cross loss and regression loss to obtain the decoding result.
[0093] Among them, the multilayer perceptron can be understood as a feedforward artificial neural network model, which consists of multiple neuron layers (such as input layer, hidden layer, output layer) and can learn complex nonlinear patterns.
[0094] Specifically, the embodiment of the present application can use a multi-layer perceptron for trajectory extraction, take the query password obtained in step S104 as input, use two multi-layer perceptrons to extract the predicted trajectory and the predicted trajectory probability respectively, and use cross entropy loss and regression loss for training.
[0095]
[0096] Where, L cls is the cross entropy loss function, N is the number of samples, that is, the number of predicted trajectories, which is 6 here; L is the number of categories, which is 2 here; k * is the true category of sample i; is the predicted score of sample i for category K; ∈ is a constant, usually set to 1.
[0097] L reg =αL ADE +(1-α)L FDE (10)
[0098] Among them, L reg is the regression loss, L FDE is the distance deviation between the predicted trajectory and the last predicted point of the true trajectory, L ADE is the average distance deviation between the predicted trajectory and the true trajectory, and α is a proportional coefficient.
[0099] The multilayer perceptron in the embodiments of the present application can learn complex nonlinear mappings between input and trajectory through hidden layers and activation functions (such as ReLU and Tanh), which is superior to linear models (such as linear regression). The multilayer perceptron can also approximate arbitrary continuous functions based on universal approximation theorems, making it suitable for continuous output tasks such as trajectory, and can support highly parallel operations to improve computational efficiency.
[0100] In step S106, based on the decoding result, a deconvolution network is used for decoding, and a probability loss function is used to calculate the risk matrix loss, and model training and verification are performed to obtain a risk analysis model based on a graph neural network to predict traffic risks.
[0101] It's understandable that deconvolutional networks are a special type of neural network architecture in deep learning. For example, GAN generators, U-Net convolutional neural networks, FCN neural networks, and super-resolution networks can all be considered deconvolutional neural networks. Risk matrix loss is a loss function based on cost-sensitive learning, primarily used to handle scenarios in classification or segmentation tasks where different error types carry different risks (costs). Its core idea is to define a risk matrix that clearly assigns penalty weights to different misclassifications, thereby guiding the model to prioritize high-risk errors during training and optimizing overall decision risk.
[0102] In the actual implementation process, the embodiment of the present application can use a deconvolutional neural network to obtain a two-dimensional risk value matrix, and use the predicted probability loss to calculate the risk matrix loss. During the calculation, multiple points of the risk matrix are randomly selected, and the true value of the risk probability of these points is calculated. The true value of the risk probability (risk probability value) is a probability indicator used to quantify the risk of an event. It is usually comprehensively evaluated by combining the possibility (probability) of the risk occurrence and the degree of impact (consequences) of the risk. The specific calculation formula is as follows:
[0103]
[0104] Among them, d is the distance between the selected point and the predicted point, σ is an empirical value, which is related to the heading angle and speed. In this patent, it can be set as a constant and set before calculation. θ is the angle difference between the angle between the selected point and the risk source vehicle and the heading angle of the vehicle, and v is the speed of the risk source vehicle.
[0105] After calculating the true value, the L2 loss is used to represent the difference between the risk matrix value and the predicted true value, which is used as the risk matrix loss. Based on the above model, PyTorch is used for training to obtain a risk analysis model, where PyTorch is an open source deep learning framework based on Python.
[0106] Optionally, in one embodiment of the present application, the adjacency matrix feature is represented as:
[0107]
[0108] in, is the feature vector of feature j in layer l, g enc is a multi-layer perceptron, It is the maximum pooling layer, which obtains the maximum value of the input feature vector in the time series direction after passing through the multi-layer perceptron. For the splicing layer, is the l-th layer input vector for feature j.
[0109] The relevant explanations of the adjacency matrix characteristics have been mentioned above and will not be repeated here.
[0110] In the actual implementation process, the embodiment of the present application can first use the sensing equipment to collect the historical trajectory information and lane centerline information of the intelligent body, and process the above information, and input the processed data into formula (5) for calculation to obtain the adjacency matrix characteristics.
[0111] The embodiment of the present application can construct a solution expression for the adjacency matrix features by using the historical trajectory information of the intelligent body and the information of the lane centerline as parameters, providing reliable data guidance and basis for subsequent encoding using the attention mechanism, and effectively ensuring the smooth implementation of subsequent encoding.
[0112] Optionally, in one embodiment of the present application, a probability loss function is used to calculate the risk matrix loss, including: randomly selecting multiple loss points of the risk matrix; and calculating the risk probability value of each loss point to determine the risk matrix loss.
[0113] The relevant explanations of the adjacency matrix characteristics have been mentioned above and will not be repeated here.
[0114] As a feasible method, the embodiment of the present application can first define the coordinate range of the risk matrix, and secondly, can generate random points based on the coordinate range using uniform random sampling or weighted random sampling, and use the generated random points as loss points, and then use formula (11) to calculate the risk probability value of each loss point to determine the risk matrix loss.
[0115] The embodiment of the present application can iteratively train the model by determining the risk matrix loss, calculate the difference between the predicted value and the true value based on the loss function, generate gradients through back propagation, guide the parameters to be updated in the direction of reducing the error, and improve the model prediction accuracy.
[0116] Optionally, in one embodiment of the present application, the calculation formula of the risk probability value is:
[0117]
[0118] Among them, d is the distance between the selected point and the predicted point, σ is an empirical value related to the heading angle and speed, θ is the angle difference between the angle between the selected point and the risk source vehicle and the heading angle of the vehicle, and v is the speed of the risk source vehicle.
[0119] The relevant explanation of the risk probability value has been mentioned above and will not be elaborated here.
[0120] During actual implementation, the embodiment of the present application may input the above-mentioned parameter values into the risk probability calculation model to obtain the risk probability value of each loss point, and then determine the risk matrix loss based on the difference between the obtained risk probability value and the risk matrix value.
[0121] The embodiments of the present application can convert abstract risks into specific probability values by calculating risk probability values, and can dynamically adjust the weight of the loss function according to the risk probability, associate the risk probability with the loss, and provide a transparent decision-making basis.
[0122] Optionally, in one embodiment of the present application, the calculation formulas for the cross loss and the regression loss are respectively:
[0123]
[0124] L reg =αL ADE +(1-α)L FDE (10)
[0125] Among them, L cls is the cross entropy loss function, N is the number of samples, K is the number of categories, is the prediction score of sample i for category K, k * is the true category of sample i, ∈ is a constant, L reg is the regression loss, L FDE is the distance deviation between the predicted trajectory and the last predicted point of the true trajectory, L ADE is the average distance deviation between the predicted trajectory and the true trajectory, and α is a proportional coefficient.
[0126] The embodiment of the present application can use cross loss to measure the difference between the probability distribution predicted by the model and the true distribution, and use regression loss to measure the numerical difference between the predicted value and the true value.
[0127] Specifically, the embodiment of the present application can input the above parameters into the cross loss and regression loss function to determine the cross loss and regression loss, use the above two losses to determine the predicted trajectory loss, and combine the determined predicted trajectory loss with the predicted trajectory decoded using a multi-layer perceptron to obtain the final decoding result.
[0128] The embodiment of the present application can obtain a more accurate predicted trajectory decoding result by determining the cross loss and the regression loss and using the cross loss and the regression loss to coordinately train the trajectory prediction.
[0129] like Figure 2 To facilitate those skilled in the art to more clearly understand the present application, the present application is described below using a specific embodiment:
[0130] Step S201: Acquire vehicle historical trajectory data and lane line data;
[0131] Step S202: Based on the vehicle historical trajectory data and lane line data, a graph encoder module is used to encode and obtain adjacency matrix features;
[0132] Step S203: Based on the adjacency matrix features, the attention mechanism is used for encoding to obtain an attention mechanism encoding result, and the cross-attention mechanism is used for decoding to obtain a cross-attention mechanism decoding result;
[0133] Step S204: Based on the decoding result of the cross attention mechanism, the predicted trajectory decoding and risk matrix decoding are performed using a multi-layer perceptron decoder and a deconvolution decoder respectively to obtain a decoding result;
[0134] Step S205: Obtain trajectory prediction loss and risk probability loss based on the decoding result;
[0135] Step S206: Based on the acquired trajectory prediction loss and risk probability loss, the model is trained to obtain a risk analysis model, and the traffic risk is analyzed and evaluated to obtain a risk assessment result.
[0136] To verify the effectiveness of the traffic risk analysis method of the embodiment of this application, relevant technicians conducted training and verification on the Argoverse2 dataset. After 40 rounds of training, a relatively accurate risk analysis model was obtained, and the risk analysis results on the road were plotted. The analysis results are shown in the figure below. Figure 3 shown.
[0137] Furthermore, compared to related technologies, the risk analysis model in the traffic risk analysis method of the present embodiment achieved a mean squared error of 1.18 compared to the comparison model, with the trend consistent with the comparison method, validating the feasibility of the present invention. Comparing computational time, the traffic risk analysis method of the present embodiment achieved a computational time of 90.04ms / frame, while the comparison method achieved a computational time of 105.6ms / frame, a 17.3% improvement in computational speed, enabling accurate and efficient risk assessment.
[0138] According to the traffic risk analysis method based on graph neural network proposed in the embodiment of the present application, graph encoding and attention mechanism encoding can be performed based on the acquired historical trajectory and lane line information of the intelligent agent, and cross-attention mechanism decoding and deconvolution network decoding can be performed in sequence based on the encoding results to obtain a risk analysis model based on graph neural network to predict traffic risks; it effectively integrates the complex and dynamic human-vehicle-road driving environment elements into a unified and explainable objective model for decision evaluation, and uses subjective driving data to fit the objective evaluation model to obtain a generalized autonomous driving decision performance evaluation method that integrates subjective and objective factors, thereby improving the accuracy, generalization and adaptability of decision evaluation. This solves the problems of the traffic risk analysis methods in related technologies, such as the limited depth of risk analysis of traffic participants and the difficulty in accurately describing the future intentions and potential risks of traffic participants.
[0139] Next, refer to the attached Figure 4Describe a traffic risk analysis device based on a graph neural network proposed according to an embodiment of the present application.
[0140] Figure 4 It is a block diagram of a traffic risk analysis device based on a graph neural network according to an embodiment of the present application.
[0141] like Figure 4 As shown, the traffic risk analysis device 10 based on graph neural network includes: an acquisition module 100, a first encoding module 200, a second encoding module 300, a first decoding module 400, a second decoding module 500, and an analysis module 600.
[0142] The acquisition module 100 is used to obtain historical trajectory information of at least one intelligent agent and lane line information of a map.
[0143] The first encoding module 200 is used to encode the historical trajectory information and lane line information using a graph encoder to obtain adjacency matrix features.
[0144] The second encoding module 300 is used to encode based on the adjacency matrix features using the attention mechanism to obtain an attention mechanism encoding result.
[0145] The first decoding module 400 is used to utilize a multimodal query password that obeys a normal distribution, based on the attention mechanism encoding result, and use a cross-attention mechanism for decoding to obtain a cross-attention mechanism decoding result.
[0146] The second decoding module 500 is used to decode the result based on the cross attention mechanism, use a multi-layer perceptron to decode the predicted trajectory, and use the cross loss and regression loss to calculate the predicted trajectory loss to obtain the decoding result.
[0147] The analysis module 600 is used to decode using a deconvolution network based on the decoding results, calculate the risk matrix loss using a probability loss function, and perform model training and verification to obtain a risk analysis model based on a graph neural network to predict traffic risks.
[0148] Optionally, in one embodiment of the present application, the adjacency matrix feature is represented as:
[0149]
[0150] in, is the feature vector of feature j in layer l, g enc is a multi-layer perceptron, It is the maximum pooling layer, which obtains the maximum value of the input feature vector in the time series direction after passing through the multi-layer perceptron. For the splicing layer, is the l-th layer input vector for feature j.
[0151] Optionally, in one embodiment of the present application, the analysis module 600 includes: a selection unit and a calculation unit; the selection unit is used to randomly select multiple loss points of the risk matrix; the calculation unit is used to calculate the risk probability value of each loss point to determine the risk matrix loss.
[0152] Optionally, in one embodiment of the present application, the calculation formula of the risk probability value is:
[0153]
[0154] Among them, d is the distance between the selected point and the predicted point, σ is an empirical value related to the heading angle and speed, θ is the angle difference between the angle between the selected point and the risk source vehicle and the heading angle of the vehicle, and v is the speed of the risk source vehicle.
[0155] Optionally, in one embodiment of the present application, the calculation formulas for the cross loss and the regression loss are respectively:
[0156]
[0157] L reg =αL ADE +(1-α)L FDE (10)
[0158] Among them, L cls is the cross entropy loss function, N is the number of samples, L is the number of categories, is the prediction score of sample i for category L, k * is the true category of sample i, ∈ is a constant, L reg is the regression loss, L FDE is the distance deviation between the predicted trajectory and the last predicted point of the true trajectory, L ADE is the average distance deviation between the predicted trajectory and the true trajectory, and α is a proportional coefficient.
[0159] It should be noted that the aforementioned explanation of the embodiment of the traffic risk analysis method based on graph neural network is also applicable to the traffic risk analysis device based on graph neural network in this embodiment, and will not be repeated here.
[0160] According to the traffic risk analysis device based on a graph neural network proposed in the embodiment of the present application, graph encoding and attention mechanism encoding can be performed based on the acquired historical trajectory and lane line information of the intelligent agent, and cross-attention mechanism decoding and deconvolution network decoding can be performed in sequence based on the encoding results to obtain a risk analysis model based on a graph neural network to predict traffic risks; it effectively integrates the complex and dynamic human-vehicle-road driving environment elements into a unified and interpretable objective model for decision evaluation, and uses subjective driving data to fit the objective evaluation model to obtain a generalized autonomous driving decision performance evaluation method that integrates subjective and objective factors, thereby improving the accuracy, generalization, and adaptability of decision evaluation. As a result, the problems of the traffic risk analysis methods in related technologies, such as the limited depth of risk analysis of traffic participants and the difficulty in accurately describing the future intentions and potential risks of traffic participants, are solved.
[0161] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device may include:
[0162] Memory 501 , processor 502 , and computer programs stored in the memory 501 and executable on the processor 502 .
[0163] When the processor 502 executes the program, the traffic risk analysis method based on the graph neural network provided in the above embodiment is implemented.
[0164] Furthermore, the electronic device further includes:
[0165] The communication interface 503 is used for communication between the memory 501 and the processor 502 .
[0166] The memory 501 is used to store computer programs that can be run on the processor 502 .
[0167] The memory 501 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0168] If the memory 501, processor 502, and communication interface 503 are implemented independently, the communication interface 503, memory 501, and processor 502 can be connected to each other via a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one thick line is used in the diagram, but this does not mean that there is only one bus or one type of bus.
[0169] Optionally, in a specific implementation, if the memory 501, the processor 502 and the communication interface 503 are integrated on a chip, the memory 501, the processor 502 and the communication interface 503 can communicate with each other through an internal interface.
[0170] The processor 502 may be a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application.
[0171] An embodiment of the present application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-mentioned graph neural network-based traffic risk analysis method.
[0172] An embodiment of the present application also provides a computer program product, which stores a computer program, and when the program is executed by a processor, implements the above-mentioned traffic risk analysis method based on graph neural network.
[0173] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or N embodiments or examples in a suitable manner. In addition, those skilled in the art can combine and combine different embodiments or examples described in this specification and features of different embodiments or examples without contradiction.
[0174] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be understood to indicate or imply relative importance or implicitly specify the number of technical features indicated. Thus, a feature specified as "first" or "second" may explicitly or implicitly include at least one such feature. In the description of this application, "N" means at least two, for example, two, three, etc., unless otherwise specifically defined.
[0175] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or N executable instructions for implementing a custom logical function or process step, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may be performed in a different order than shown or discussed, including performing functions in a substantially simultaneous manner or in a reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present application pertain.
[0176] The logic and / or steps represented in the flowcharts or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing the logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (e.g., a computer-based system, a system including a processor, or other system that can fetch and execute instructions from an instruction execution system, apparatus, or device). For purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport a program for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include the following: an electrical connection with one or N wires (electronic devices), a portable computer disk cartridge (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and programmable read-only memory (EPROM or flash memory), fiber optic devices, and a portable compact disc read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program can be obtained electronically by optically scanning the paper or other medium and then editing, interpreting or processing it in other suitable ways as necessary, and then storing it in a computer memory.
[0177] It should be understood that various parts of the present application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiment, the N steps or methods can be implemented using software or firmware stored in a memory and executed by a suitable instruction execution system. If implemented using hardware, as in another embodiment, any one of the following technologies known in the art or a combination thereof can be used: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application-specific integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0178] Those skilled in the art will understand that all or part of the steps in the method of the above embodiment can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium. When the program is executed, it includes one or a combination of the steps of the method embodiment.
[0179] In addition, the functional units in the various embodiments of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into a module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0180] The storage medium mentioned above may be a read-only memory, a magnetic disk, or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present application. Persons skilled in the art may make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present application.
Claims
1. A traffic risk analysis method based on graph neural network, characterized in that: The following steps are involved: Obtain historical trajectory information of at least one agent and lane line information of the map; Based on the historical trajectory information and the lane line information, a graph encoder is used to encode to obtain adjacency matrix features; Based on the adjacency matrix features, encoding is performed using an attention mechanism to obtain an attention mechanism encoding result; Using a multimodal query password that obeys a normal distribution, based on the attention mechanism encoding result, using a cross attention mechanism to decode, so as to obtain a cross attention mechanism decoding result; Based on the decoding result of the cross attention mechanism, a multi-layer perceptron is used to decode the predicted trajectory, and the predicted trajectory loss is calculated using the cross loss and regression loss to obtain the decoding result; Based on the decoding results, a deconvolutional network is used for decoding, and a probability loss function is used to calculate the risk matrix loss. Model training and verification are then performed to obtain a risk analysis model based on a graph neural network to predict traffic risks.
2. The method according to claim 1, characterized in that The adjacency matrix feature is expressed as: in, is the feature vector of feature j in layer l, g enc is a multi-layer perceptron, It is the maximum pooling layer, which obtains the maximum value of the input feature vector in the time series direction after passing through the multi-layer perceptron. For the splicing layer, is the l-th layer input vector for feature j.
3. The method according to claim 1, characterized in that The method of calculating the risk matrix loss using the probability loss function includes: Randomly select multiple loss points in the risk matrix; Calculate the risk probability value of each loss point to determine the risk matrix loss.
4. The method according to claim 3, characterized in that The calculation formula of the risk probability value is: Among them, d is the distance between the selected point and the predicted point, σ is an empirical value related to the heading angle and speed, θ is the angle difference between the angle between the selected point and the risk source vehicle and the heading angle of the vehicle, and v is the speed of the risk source vehicle.
5. The method according to claim 1, wherein The calculation formulas for the cross loss and regression loss are: L reg =αL ADE +(1-α)L FDE (10) Among them, L cls is the cross entropy loss function, N is the number of samples, K is the number of categories, is the prediction score of sample i for category K, k * is the true category of sample i, ∈ is a constant, L reg is the regression loss, L FDE is the distance deviation between the predicted trajectory and the last predicted point of the true trajectory, L ADE is the average distance deviation between the predicted trajectory and the true trajectory, and α is a proportional coefficient.
6. A traffic risk analysis device based on graph neural network, characterized in that: include: An acquisition module, configured to acquire historical trajectory information of at least one intelligent agent and lane line information of a map; A first encoding module is configured to encode the historical trajectory information and the lane line information using a graph encoder to obtain an adjacency matrix feature; A second encoding module is used to encode based on the adjacency matrix features using an attention mechanism to obtain an attention mechanism encoding result; A first decoding module is configured to use a multimodal query password that obeys a normal distribution and decode the result encoded by the attention mechanism using a cross-attention mechanism to obtain a decoding result of the cross-attention mechanism; A second decoding module is used to decode the predicted trajectory using a multi-layer perceptron based on the decoding result of the cross attention mechanism, and calculate the predicted trajectory loss using the cross loss and regression loss to obtain a decoding result; The analysis module is used to decode the decoding results using a deconvolution network, calculate the risk matrix loss using a probability loss function, and perform model training and verification to obtain a risk analysis model based on a graph neural network to predict traffic risks.
7. The device according to claim 6, characterized in that The adjacency matrix feature is expressed as: in, is the feature vector of feature j in layer l, g enc is a multi-layer perceptron, It is the maximum pooling layer, which obtains the maximum value of the input feature vector in the time series direction after passing through the multi-layer perceptron. For the splicing layer, is the l-th layer input vector for feature j.
8. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the traffic risk analysis method based on graph neural network as described in any one of claims 1 to 5.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: The program is executed by a processor to implement the traffic risk analysis method based on graph neural network as described in any one of claims 1 to 5.
10. A computer program product, characterized in that The computer program is executed to implement the traffic risk analysis method based on graph neural network as described in any one of claims 1 to 5.
Citation Information
Cited By
Automatic driving risk deduction method based on anomaly detection and graph neural network
CN121743709A
An automatic driving trajectory planning method based on dynamic risk prediction
CN122544819B