Traffic accident rate prediction method, device, equipment and medium

By converting the spatiotemporal data of traffic accidents into graph structure data, using the Gumbel-Softmax sparse attention mechanism, extracting the characteristics of key road sections and time periods, the problems of sparse and imbalance of traffic accident data are solved, and the prediction accuracy and interpretability are improved.

CN120260280APending Publication Date: 2025-07-04TSINGHUA UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510432160.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-08
Publication Date
2025-07-04

AI Technical Summary

Technical Problem

Due to data sparsity and category imbalance, the existing traffic accident prediction model is difficult to accurately detect accidents in areas with few accidents and effectively identify major accidents, resulting in a low prediction accuracy.

Method used

The space-time data of traffic accidents under the grid space are converted into data under the graph structure, and the road network topology is used to extract the characteristic representation of key road sections and time periods through the traffic accident incidence prediction model. The Gumbel-Softmax sparse attention mechanism is used to focus on areas with high accident risk and generate future accident risk prediction.

Benefits of technology

It improves the accuracy and interpretability of traffic accident prediction, can predict major accidents more accurately, reduces interference from invalid information, and improves the performance and interpretability of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120260280A_ABST
    Figure CN120260280A_ABST
Patent Text Reader

Abstract

The invention provides a traffic accident rate prediction method and device, equipment and a medium, and relates to the technical field of computers. Comprising the following steps: acquiring traffic accident spatio-temporal data in a grid space; converting the traffic accident spatio-temporal data in the grid space into data in a graph structure; processing the data under the graph structure through a traffic accident rate prediction model to obtain feature representations of a plurality of key road sections in a plurality of road sections corresponding to a plurality of intersections and feature representations of a plurality of key road sections in a key historical time period of historical time periods; predicting the feature representation of each intersection in the future time period according to the feature representations of the plurality of key road sections in the key historical time period of the historical time periods; and mapping the feature representation of each intersection in the future time period back to the grid space to obtain the traffic flow and the traffic accident rate of the plurality of intersections at each future moment in the future time period, thereby improving the prediction accuracy of traffic accident prediction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular, to a method, device, equipment and medium for predicting the incidence of traffic accidents. Background Art

[0002] Traffic risk prediction is crucial for urban traffic management. Related technologies usually use historical traffic data collected from road sensors to predict future traffic risks. However, different from other traffic prediction tasks, traffic accident data has significant sparsity and imbalance: in a vast traffic network, the accident frequency in some areas is extremely low, and no accidents are recorded for a long time; this sparsity may be due to factors such as low traffic flow, well-designed infrastructure, or effective traffic management systems. In contrast, accident-prone areas, such as busy intersections, often show the characteristics of concentrated accidents. This spatial imbalance poses a major challenge to related traffic accident prediction models, making it difficult for them to accurately capture and reflect the diverse characteristics of accidents in different regions.

[0003] In addition, there is also an imbalance in the severity of traffic accidents: Minor accidents (such as scratches and small collisions) usually account for the majority of the total number of accidents because they are more common and usually cause less harm or loss; in contrast, major accidents (such as serious injuries or deaths) occur less frequently, but the consequences are extremely serious. This class imbalance may cause related traffic accident prediction models to be biased towards predicting minor accidents and ignore the key task of predicting major accidents. However, accurately predicting and preventing major accidents is crucial because of their great impact on society and individuals.

[0004] Therefore, the sparsity and imbalance of traffic accident data pose a huge challenge to the current construction of traffic accident prediction models. The performance of current traffic accident prediction models often deteriorates in accurately detecting accidents in areas with few accidents and effectively identifying major accidents, resulting in a low prediction accuracy for traffic accident prediction in related technologies. Summary of the Invention

[0005] Based on the above technical problems, the present invention provides a method, device, equipment and medium for predicting the incidence of traffic accidents, aiming to overcome or at least partially solve the above problems.

[0006] In the first aspect of the present invention, a method for predicting the incidence of traffic accidents is provided. The method includes: Obtain traffic accident spatio-temporal data in a grid space, where the traffic accident spatio-temporal data characterizes the traffic flow and the incidence of traffic accidents at multiple intersections during a historical time period; Convert the traffic accident spatio-temporal data in the grid space into data in the graph structure. The data in the graph structure includes a node matrix and an adjacency matrix. The feature representation of a node in the node matrix is used to characterize the traffic flow and the traffic accident incidence rate at an intersection during a historical time period. The adjacency matrix characterizes whether there is a road section between the intersections corresponding to every two nodes; Process the data in the graph structure through a traffic accident incidence rate prediction model to obtain the feature representations of multiple critical road sections among the multiple road sections corresponding to the multiple intersections and the feature representations of the multiple critical road sections during a critical historical time period within the historical time period; Predict the feature representations of each intersection within a future time period according to the feature representations of the multiple critical road sections during the critical historical time period within the historical time period. The traffic accident incidence rate prediction model is trained with the traffic flow and the traffic accident incidence rate of multiple sample intersections during a sample historical time period; Map the feature representations of each intersection within the future time period back to the grid space to obtain the traffic flow and the traffic accident incidence rate of each intersection at each future moment within the future time period.

[0007] A second aspect of the present invention provides a traffic accident incidence rate prediction device. The device includes: A data acquisition module, configured to acquire traffic accident spatio-temporal data in the grid space, where the traffic accident spatio-temporal data characterizes the traffic flow and the traffic accident incidence rate of multiple intersections during a historical time period; A data conversion module, configured to convert the traffic accident spatio-temporal data in the grid space into data in the graph structure. The data in the graph structure includes a node matrix and an adjacency matrix. The feature representation of a node in the node matrix is used to characterize the traffic flow and the traffic accident incidence rate at an intersection during a historical time period. The adjacency matrix characterizes whether there is a road section between the intersections corresponding to every two nodes; A data processing module, configured to process the data in the graph structure through a traffic accident incidence rate prediction model to obtain the feature representations of multiple critical road sections among the multiple road sections corresponding to the multiple intersections and the feature representations of the multiple critical road sections during a critical historical time period within the historical time period; A data prediction module, configured to predict the feature representations of each intersection within a future time period according to the feature representations of the multiple critical road sections during the critical historical time period within the historical time period. The traffic accident incidence rate prediction model is trained with the traffic flow and the traffic accident incidence rate of multiple sample intersections during a sample historical time period; A data mapping module, configured to map the feature representations of the respective intersections in a future time period back to the grid space, so as to obtain the traffic flow and the accident incidence rate at each future moment of the multiple intersections in the future time period.

[0008] A third aspect of the present invention provides an electronic device, which includes: a memory, a processor, and a computer program stored on the memory and executable on the processor. When the computer program is executed by the processor, it implements the accident incidence rate prediction method according to the first aspect of the embodiments of the present invention.

[0009] A fourth aspect of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements the accident incidence rate prediction method according to the first aspect of the embodiments of the present invention.

[0010] In the accident incidence rate prediction method provided by the present invention, the accident spatio-temporal data based on the grid space is converted into data in a graph structure, so that the trained accident incidence rate prediction model can more effectively capture key spatial relationships by using the road network topology structure, so as to automatically highlight key sections and key time periods for the data in the graph structure through the accident incidence rate prediction model, obtain the feature representations of multiple key sections and the feature representations of multiple key sections in key historical time periods, so as to predict future accident risks. Thus, by selectively ignoring invalid node information and adaptively focusing on key sections and key historical time periods with higher accident risks, the problem of sparse accident data is solved, the class imbalance is alleviated, and thus the prediction accuracy and interpretability of accident prediction are improved. Description of the Drawings

[0011] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the drawings required to be used in the description of the embodiments of the present invention. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0012] Figure 1 It is a flowchart of the steps of an accident incidence rate prediction method shown in an embodiment of the present invention; Figure 2 It is a schematic flowchart of an accident incidence rate prediction method based on Gumbel sparse attention shown in an embodiment of the present invention; Figure 3 It is a structural block diagram of an accident incidence rate prediction device provided by an embodiment of the present invention; Figure 4It is a schematic diagram of an electronic device shown in an embodiment of the present invention. Detailed implementation manners

[0013] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0014] Please refer to Figure 1 , Figure 1 It is a step flowchart of a traffic accident incidence prediction method shown in an embodiment of the present invention. As Figure 1 shown, the traffic accident incidence prediction method provided in this embodiment at least includes the following steps: Step S11: Obtain traffic accident spatio-temporal data in a grid space, where the traffic accident spatio-temporal data characterizes the traffic flow and traffic accident incidence at multiple intersections during a historical time period.

[0015] This embodiment can obtain traffic accident spatio-temporal data in a grid space, and the traffic accident spatio-temporal data characterizes the traffic flow and traffic accident incidence at multiple intersections during a historical time period. Among them, the grid space in this embodiment is a road grid determined based on geographical location information, and the grid space includes multiple intersections.

[0016] Step S12: Convert the traffic accident spatio-temporal data in the grid space into data in a graph structure. The data in the graph structure includes a node matrix and an adjacency matrix. The feature representation of a node in the node matrix is used to characterize the traffic flow and traffic accident incidence at an intersection during a historical time period, and the adjacency matrix characterizes whether there is a road section between the intersections corresponding to every two nodes.

[0017] In this embodiment, it is necessary to convert the obtained traffic accident spatio-temporal data in the grid space into data in a graph (Graph) structure. In an optional example, the traffic accident spatio-temporal data in the grid space can be projected onto graph (Graph) nodes through a mapping function, so that the subsequent model can utilize the road network topology structure and more clearly distinguish spatial relationships. The data in the graph structure in this embodiment includes: a node matrix and an adjacency matrix; among them, a node in the node matrix corresponds to an intersection, and the feature representation of a node is used to characterize the traffic flow and traffic accident incidence at an intersection during a historical time period, and the adjacency matrix characterizes whether there is a road section between the intersections corresponding to every two nodes.

[0018] Step S13: Process the data under the graph structure through the traffic accident incidence prediction model to obtain the feature representations of multiple critical road segments among the multiple road segments corresponding to the multiple intersections, and the feature representations of the multiple critical road segments during the critical historical time period within the historical time period.

[0019] In this embodiment, after obtaining the data under the graph structure, the trained traffic accident incidence prediction model can be used to process the data under the graph structure to sequentially obtain the feature representations of multiple critical road segments among the multiple road segments corresponding to the multiple intersections, and the feature representations of the multiple critical road segments during the critical historical time period within the historical time period. This embodiment can use the trained traffic accident incidence prediction model to process the data under the graph structure to extract the key spatial features in the data under the graph structure, obtain the feature representations of multiple critical road segments among the multiple road segments corresponding to the multiple intersections, so as to highlight the critical road segments (the road segments crucial for predicting traffic accidents).

[0020] In an alternative embodiment, after obtaining the feature representations of multiple critical road segments among the multiple road segments corresponding to the multiple intersections, the trained traffic accident incidence prediction model can be used to process the feature representations of the multiple critical road segments among the multiple road segments corresponding to the multiple intersections, so as to selectively focus on the critical historical time period (such as the high-risk time period for traffic accidents), filter out irrelevant time periods, and reveal deeper time dynamics, to obtain the feature representations of the multiple critical road segments during the critical historical time period within the historical time period.

[0021] Step S14: Predict the feature representations of each intersection within the future time period according to the feature representations of the multiple critical road segments during the critical historical time period within the historical time period. The traffic accident incidence prediction model is trained with the traffic flow and traffic accident incidence of multiple sample intersections within the sample historical time period as training samples.

[0022] This embodiment can predict the feature representations of each intersection within the future time period according to the obtained feature representations of the multiple critical road segments during the critical historical time period within the historical time period. Among them, the traffic accident incidence prediction model of this embodiment is trained in advance with the traffic flow and traffic accident incidence of multiple sample intersections within the sample historical time period as training samples.

[0023] Step S15: Map the feature representations of each intersection within the future time period back to the grid space to obtain the traffic flow and traffic accident incidence of each future moment of the multiple intersections within the future time period.

[0024] In this embodiment, after obtaining the feature representations of each intersection in the future time period, the feature representations of each intersection in the future time period can be re-projected and mapped back to the grid space (for example, projecting the processed features back to the grid space through a fully connected layer), generating a future accident risk prediction on a finer-grained spatial scale, and obtaining the traffic flow and accident incidence rate at each future moment of multiple intersections in the grid space in the future time period. In this way, this embodiment not only covers potential spatio-temporal dependencies but also provides predictions at specific locations.

[0025] In this embodiment, the spatio-temporal accident data based on the grid space is converted into data in the graph structure, so that the trained accident incidence rate prediction model can more effectively capture key spatial relationships by using the road network topology structure, and automatically highlight key road segments and key time periods for the data in the graph structure through the accident incidence rate prediction model, obtaining the feature representations of multiple key road segments and the feature representations of multiple key road segments in key historical time periods, so as to predict future accident risks. Thus, by selectively ignoring invalid node information and adaptively focusing on key road segments and key historical time periods with higher accident risks, the problem of sparse accident data is solved, the class imbalance is alleviated, and the prediction accuracy and interpretability of accident prediction are improved.

[0026] Combining the above embodiments, in one implementation manner, the present invention also provides an accident incidence rate prediction method. In this method, the "processing the data in the graph structure through the accident incidence rate prediction model to obtain the feature representations of multiple key road segments among the multiple road segments corresponding to the multiple intersections" in step S13 above may specifically include step S21 and step S22: Step S21: Processing the data in the graph structure through the first spatial correlation extraction sub-module to obtain the intermediate feature representations of the multiple intersections.

[0027] In this embodiment, the accident incidence rate prediction model at least includes a spatial correlation extraction module, and this spatial correlation extraction module includes: a first spatial correlation extraction sub-module and a second spatial correlation extraction sub-module. Among them, the spatial correlation extraction module is used to extract key spatial features in the data in the graph structure, emphasize neighboring nodes with the greatest impact on accident risks, and highlight key road segments crucial for predicting accidents.

[0028] After inputting the data in the graph structure into the accident incidence rate prediction model, the first spatial correlation extraction sub-module can process the data in the graph structure to obtain the intermediate feature representations of multiple intersections, focusing on the direct neighborhood of the nodes.

[0029] Step S22: Input the intermediate feature representations of the multiple intersections into the second spatial correlation extraction sub-module for processing, and obtain the output result of the second spatial correlation extraction sub-module, which serves as the feature representations of multiple critical road segments among the multiple road segments corresponding to the multiple intersections.

[0030] In this embodiment, after obtaining the intermediate feature representations of the multiple intersections output by the first spatial correlation extraction sub-module, the intermediate feature representations of the multiple intersections can be input into the second spatial correlation extraction sub-module for processing, so as to further integrate and optimize the intermediate feature representations of the multiple intersections extracted by the first spatial correlation extraction sub-module, propagate and aggregate higher-order structural information, and obtain the output of the second spatial correlation extraction sub-module: the feature representations of multiple critical road segments among the multiple road segments corresponding to the multiple intersections. Among them, the structure and data processing process of the second spatial correlation extraction sub-module are the same as those of the first spatial correlation extraction sub-module.

[0031] In this embodiment, the data in the graph structure is processed by two spatial correlation extraction sub-modules. This deeper integration enables the spatial correlation extraction module to better capture complex spatial relationships and finally generate more informative and discriminative feature representations (i.e., the feature representations of multiple critical road segments among the multiple road segments corresponding to the multiple intersections).

[0032] Combined with the above embodiments, in one implementation manner, the present invention further provides a traffic accident incidence prediction method. In this method, the above step S21 may specifically include step S31 and step S32: Step S31: Based on the adjacency matrix, for each intersection among the multiple intersections, determine the adjacent intersections that have road segments with this intersection from the remaining intersections, and the non-adjacent intersections that do not have road segments with this intersection.

[0033] In this embodiment, based on the adjacency matrix in the data in the graph structure, for each intersection among the multiple intersections in the grid space, determine the adjacent intersections that have road segments with this intersection from the remaining intersections, and determine the non-adjacent intersections that do not have road segments with this intersection from the remaining intersections. Among them, the remaining intersections in this embodiment are the other intersections in the grid space except the targeted intersection.

[0034] Step S32: For the i-th intersection among the multiple intersections, execute steps S321 to S324 through the first spatial correlation extraction sub-module.

[0035] In this embodiment, the spatial correlation extraction module is a Gumbel sparse graph attention network, which adopts the sparse attention mechanism of Gumbel-Softmax with a graph structure (Graphs) to dynamically assign different attention weights to each node, thereby emphasizing the neighboring nodes that have the greatest impact on traffic accident risks. In this embodiment, the sparse attention mechanism of Gumbel-Softmax is introduced to achieve a sparser attention distribution. This sparsity prompts the spatial correlation extraction module to focus on more important connections (critical edges), thereby improving interpretability and enhancing performance. The first spatial correlation extraction sub-module and the second spatial correlation extraction sub-module of this embodiment are two identical graph attention layers.

[0036] Step S321: Filter out non-adjacent intersections that do not have a road segment with the i-th intersection.

[0037] In this embodiment, for the i-th intersection among multiple intersections (i is a natural number greater than 0), non-adjacent intersections that do not have a road segment with the i-th intersection can be filtered out.

[0038] Step S322: Obtain the score of the j-th adjacent intersection of the i-th intersection according to the feature representation of the i-th intersection and the feature representation of the j-th adjacent intersection of the i-th intersection.

[0039] In this embodiment, the score of the j-th adjacent intersection of the i-th intersection can be calculated according to the feature representation of the i-th intersection and the feature representation of the j-th adjacent intersection of the i-th intersection. The score of the j-th adjacent intersection of the i-th intersection represents the attention score of the road segment between the i-th intersection and the j-th adjacent intersection, where j is a natural number greater than 0. In this embodiment, specific values of i and j are not limited. In an alternative embodiment, Gumbel noise can be introduced, and then the score of the j-th adjacent intersection of the i-th intersection can be calculated according to the feature representation of the i-th intersection and the feature representation of the j-th adjacent intersection of the i-th intersection.

[0040] Step S323: Based on the score of the j-th adjacent intersection of the i-th intersection, assign a weight to the j-th adjacent intersection of the i-th intersection according to the sparse attention mechanism of Gumbel-Softmax with a temperature coefficient of τ.

[0041] In this embodiment, after obtaining the score of the j-th adjacent intersection of the i-th intersection, normalization can be performed along the j direction according to the sparse attention mechanism of Gumbel-Softmax with a temperature coefficient of τ based on the score of the j-th adjacent intersection of the i-th intersection to obtain the weight of the j-th adjacent intersection of the i-th intersection, and assign this weight to the j-th adjacent intersection of the i-th intersection. This step will generate a sparse attention distribution to highlight critical edges (critical road segments).

[0042] Based on the above steps, in this embodiment, weights can be assigned to each adjacent intersection of the i-th intersection.

[0043] Step S324: Based on the weights assigned to each adjacent intersection of the i-th intersection and the feature representations of each adjacent intersection of the i-th intersection, obtain the intermediate feature representation of the i-th intersection.

[0044] In this embodiment, the features can be aggregated. Based on the weights assigned to each adjacent intersection of the i-th intersection and the feature representations of each adjacent intersection of the i-th intersection, obtain the intermediate feature representation of the i-th intersection, so as to obtain the intermediate feature representations of multiple intersections.

[0045] In a specific example, it can be to perform weighted summation on the weights assigned to each adjacent intersection of the i-th intersection and the corresponding feature representations of each adjacent intersection of the i-th intersection to obtain the intermediate feature representation of the i-th intersection.

[0046] It should be noted that the steps executed by the second spatial correlation extraction sub-module and the first spatial correlation extraction sub-module in this embodiment are the same. When the intermediate feature representations of multiple intersections are input into the second spatial correlation extraction sub-module for processing, the second spatial correlation extraction sub-module can repeatedly execute the above steps S321 to S324 based on the intermediate feature representations of multiple intersections to obtain the feature representations of multiple key road segments in multiple road segments corresponding to multiple intersections output by the second spatial correlation extraction sub-module.

[0047] In this embodiment, in order to capture various node relationships, the Gumbel-Softmax method is adopted to enforce sparsity, prompting the spatial correlation extraction module to only focus on the most important edges (i.e., key road segments), filtering out irrelevant connections through a two-layer sparse attention mechanism (i.e., the first spatial correlation extraction sub-module and the second spatial correlation extraction sub-module), and only highlighting the road segments crucial for predicting accidents. This not only improves interpretability but also reduces unnecessary calculations.

[0048] Combined with the above embodiments, in one implementation manner, the present invention further provides a method for predicting the traffic accident incidence rate. In this embodiment, the "processing the data in the graph structure through the traffic accident occurrence probability prediction model to obtain the feature representations of the multiple key road segments in the key historical time period within the historical time period" in the above step S13 specifically includes step S41 and step S42: Step S41: Through the Gumbel-Softmax sparse multi-head attention layer in the l-th time correlation extraction sub-module, execute steps S411 to S417.

[0049] In this embodiment, the traffic accident incidence prediction model further includes a temporal correlation extraction module connected in series after the spatial correlation extraction module, and the temporal correlation extraction module includes L serially connected temporal correlation extraction sub-modules. Each temporal correlation extraction sub-module includes at least a Gumbel-Softmax sparse multi-head attention layer. The temporal correlation extraction module of this embodiment adopts a sparse attention mechanism based on Gumbel-Softmax, aiming to process potential noise and redundant temporal information by focusing on a limited number of critical moments in the sequence, so as to apply the sparse self-attention mechanism to capture critical moments and patterns in temporal data to predict future accident risks.

[0050] In an alternative embodiment, the temporal correlation extraction module of this embodiment is a Gumbel sparse Transformer, which is a temporal encoder constructed based on the Transformer architecture and adopting a sparse attention mechanism based on Gumbel-Softmax.

[0051] In this embodiment, the following steps S411 to S417 can be executed through the Gumbel-Softmax sparse multi-head attention layer in the l-th temporal correlation extraction sub-module. Wherein, l and L are natural numbers greater than 0, and l ∈ [1, L]. It should be noted that the specific values of l and L in this embodiment are not limited.

[0052] Step S411: Perform a linear projection on the input of the Gumbel-Softmax sparse multi-head attention layer in the l-th temporal correlation extraction sub-module to obtain a Q matrix, a K matrix, and a V matrix.

[0053] In this embodiment, a linear projection can be performed on the input of the Gumbel-Softmax sparse multi-head attention layer in the l-th temporal correlation extraction sub-module to respectively obtain a Q matrix, a K matrix, and a V matrix. The Q matrix, the K matrix, and the V matrix are the results of linear projections of the input in different dimensions.

[0054] Among them, when l is 1, in the first temporal correlation extraction sub-module, the feature representations of multiple critical road segments among the multiple road segments corresponding to multiple intersections output by the spatial correlation extraction module are used as the input of the Gumbel-Softmax sparse multi-head attention layer. That is, the input of the Gumbel-Softmax sparse multi-head attention layer in the first temporal correlation extraction sub-module is: the feature representations of multiple critical road segments among the multiple road segments corresponding to multiple intersections. When l is not 1, the input of the Gumbel-Softmax sparse multi-head attention layer in the l-th temporal correlation extraction sub-module is the output of the Gumbel-Softmax sparse multi-head attention layer in the (l - 1)-th temporal correlation extraction sub-module.

[0055] Step S412: Process the Q matrix to obtain the scores of each historical time interval within the historical time period.

[0056] In this embodiment, after obtaining the Q matrix, the Q matrix can be processed to obtain the scores of each historical time interval within the historical time period. In an alternative implementation, a Predictor can be used to process the Q matrix to generate the scores of each historical time interval within the historical time period, and the scores of each historical time interval within the historical time period represent the log odds corresponding to the time positions. In an alternative implementation, the Predictor is a linear transformation operation.

[0057] Step S413: Based on the scores of each historical time interval, generate the mask result of each historical time interval according to the Gumbel-Softmax-based sparse attention mechanism with a temperature coefficient of τ.

[0058] In this embodiment, the mask result of each historical time interval within the obtained historical time period can be generated according to the Gumbel-Softmax-based sparse attention mechanism with a temperature coefficient of τ to roughly screen out the range of the critical historical time period of the critical road segments. Among them, when the mask result of a historical time interval is 1, it indicates that this historical time interval belongs to the critical historical time period.

[0059] Step S414: Perform attention calculation based on the Q matrix and the K matrix to obtain the attention calculation results of multiple critical road segments.

[0060] In this embodiment, attention calculation can be performed based on the Q matrix and the K matrix. For example, in multi-head attention, attention calculation is performed on the Q matrix and the K matrix through dot products of a standard ratio to obtain the attention calculation results of multiple key road segments. It should be noted that this embodiment does not limit the execution order of step S414, step S412, and step S413.

[0061] Step S415: Based on the attention calculation results of the multiple key road segments and the masking results of each historical time interval, obtain the scores of the multiple key road segments within the critical historical time period of the historical time period.

[0062] In this embodiment, based on the attention calculation results of multiple key road segments and the masking results of each historical time interval, the scores of multiple key road segments within the critical historical time period of the historical time period can be obtained. In this embodiment, the attention calculation results of multiple key road segments can be filtered based on the masking results of the historical time interval: when the masking result of the historical time interval is 1, the attention calculation results of the multiple key road segments corresponding to this historical time interval are determined as the scores of the multiple key road segments within the critical historical time period; when the masking result of the historical time interval is not 1, there is no score corresponding to this historical time interval.

[0063] Step S416: Perform softmax processing on the scores of the multiple key road segments within the critical historical time period of the historical time period to obtain the weights of the multiple key road segments within the critical historical time period of the historical time period.

[0064] In this embodiment, after obtaining the scores of the multiple key road segments within the critical historical time period of the historical time period, softmax processing is performed on the scores of the multiple key road segments within the critical historical time period of the historical time period to obtain the weights of the multiple key road segments within the critical historical time period of the historical time period. This embodiment introduces a sparse attention mechanism based on Gumbel-Softmax, rather than directly applying softmax processing to all time positions, and processes potential noisy and redundant time information by focusing on a limited number of critical moments in the sequence.

[0065] Step S417: Based on the weights of the multiple key road segments within the critical historical time period of the historical time period and the V matrix, obtain the output result of the Gumbel-Softmax sparse multi-head attention layer in the l-th time correlation extraction sub-module.

[0066] In this embodiment, based on the obtained weights of the multiple key road segments within the critical historical time period of the historical time period and the V matrix, the output result of the Gumbel-Softmax sparse multi-head attention layer in the l-th time correlation extraction sub-module can be obtained.

[0067] Step S42: Use the output result of the Gumbel-Softmax sparse multi-head attention layer in the L-th time correlation extraction sub-module as the feature representation of the multiple key road segments within the key historical time period of the historical time period.

[0068] In this embodiment, by sequentially performing the above-mentioned steps S411 to S417 through L cascaded time correlation extraction sub-modules, the feature representation of multiple key road segments within the key historical time period of the historical time period output by the Gumbel-Softmax sparse multi-head attention layer in the L-th time correlation extraction sub-module can be obtained. That is, use the output result of the Gumbel-Softmax sparse multi-head attention layer in the L-th time correlation extraction sub-module as the feature representation of multiple key road segments within the key historical time period of the historical time period.

[0069] In this embodiment, by introducing the Gumbel-Softmax sparse attention mechanism in both the spatial and temporal aggregation stages, it is possible to accurately locate the truly influential nodes and time steps, significantly reduce the computational overhead, while retaining the key information, to obtain a more efficient, accurate, and interpretable traffic accident incidence prediction model, which performs excellently in dealing with highly sparse and imbalanced traffic accident data, can focus the attention on the most relevant regions and time intervals, and further improve the traffic accident prediction accuracy and interpretability in complex and sparse traffic accident scenarios.

[0070] Combined with the above embodiments, in one implementation, the present invention also provides a traffic accident incidence prediction method. In this embodiment, the "predicting the feature representation of each intersection in the future time period according to the feature representation of the multiple key road segments within the key historical time period of the historical time period" in the above step S14 specifically includes steps S51 and S52: Step S51: Process the output result of the Gumbel-Softmax sparse multi-head attention layer in the l-th time correlation extraction sub-module through the FFN layer in the l-th time correlation extraction sub-module to obtain the output result of the l-th time correlation extraction sub-module.

[0071] In this embodiment, each time correlation extraction sub-module further includes an FFN (feed-forward neural network) layer. In each time correlation extraction sub-module, the input of the FFN layer is the output of the Gumbel-Softmax sparse multi-head attention layer. The FFN layer in this embodiment is used to further process the already sparsified temporal features.

[0072] In this embodiment, the output result of the Gumbel-Softmax sparse multi-head attention layer in the l-th temporal correlation extraction sub-module is processed by the FFN layer in the l-th temporal correlation extraction sub-module to obtain the output result of the l-th temporal correlation extraction sub-module. In this embodiment, the output result of the l-th temporal correlation extraction sub-module is used as the input of the (l + 1)-th temporal correlation extraction sub-module (i.e., the input of the Gumbel-Softmax sparse multi-head attention layer of the (l + 1)-th temporal correlation extraction sub-module).

[0073] Step S52: Input the output result of the l-th temporal correlation extraction sub-module into the (l + 1)-th temporal correlation extraction sub-module for processing until the output result of the L-th temporal correlation extraction sub-module is obtained, which is used as the feature representation of each intersection in the future time period.

[0074] In this embodiment, the output results of the l temporal correlation extraction sub-modules can be input into the (l + 1)-th temporal correlation extraction sub-module for processing until the feature representations of each intersection in the future time period of the output of the L-th temporal correlation extraction sub-module are obtained, that is, the output result of the L-th temporal correlation extraction sub-module is used as the feature representation of each intersection in the future time period.

[0075] In an alternative embodiment, the FFN layer consists of two fully connected layers and is equipped with a non-linear activation function (such as GELU). In another alternative embodiment, to ensure stability, in each correlation extraction sub-module, residual connections and layer normalization are added around the Gumbel-Softmax sparse multi-head attention layer and the FFN layer. Also, in another alternative embodiment, after obtaining the output result of the l-th temporal correlation extraction sub-module, the output result of the l-th temporal correlation extraction sub-module can be processed by an embedding layer and learnable positional encoding and then input into the (l + 1)-th temporal correlation extraction sub-module.

[0076] In this embodiment, Gumbel-Softmax is used to introduce sparsity into the attention mechanism, enabling the temporal correlation extraction module to focus on key time points in a noisy sequence. Through multi-head attention, feed-forward neural network layers, and residual normalization techniques, the temporal correlation extraction module can effectively extract key temporal features, thereby generating a more informative and robust time series representation than the standard Transformer.

[0077] Combining the above embodiments, in one embodiment, the present invention further provides a traffic accident incidence prediction method. In this method, the "acquiring traffic accident spatio-temporal data in the grid space" in the above step S11 specifically includes steps S61 to S63: Step S61: Obtain the original traffic spatio-temporal data in the grid space.

[0078] Step S62: Determine the spatio-temporal distribution uniformity of the traffic accident data in the original traffic spatio-temporal data.

[0079] In this embodiment, the original traffic spatio-temporal data in the grid space can be obtained, and then based on the obtained original traffic spatio-temporal data in the grid space, the spatio-temporal distribution uniformity of the traffic accident data in the original traffic spatio-temporal data is determined. This spatio-temporal distribution uniformity characterizes the sparsity and imbalance of the traffic accident data in time and space.

[0080] Step S63: When the spatio-temporal distribution uniformity of the traffic accident data is greater than the spatio-temporal distribution uniformity threshold, use the traffic accident data in the original traffic spatio-temporal data as the traffic accident spatio-temporal data in the grid space.

[0081] In this embodiment, a spatio-temporal distribution uniformity threshold is set in advance and can be freely set according to requirements or experience. In this embodiment, the relationship between the spatio-temporal distribution uniformity of the traffic accident data and the spatio-temporal distribution uniformity threshold is judged. When it is determined that the spatio-temporal distribution uniformity of the traffic accident data is greater than the spatio-temporal distribution uniformity threshold, the traffic accident data in the original traffic spatio-temporal data is used as the traffic accident spatio-temporal data in the grid space for traffic accident prediction in this grid space.

[0082] Combined with the above embodiments, in one implementation, the present invention further provides a method for predicting the traffic accident incidence rate. In this method, in addition to the above steps, it may further include Step S71: Step S71: Output prompt information for high-risk time periods and prompt information for high-risk road sections according to the traffic flow and traffic accident incidence rate at each future moment of the plurality of intersections in the future time period, and the feature representation of the plurality of key road sections in the key historical time period of the historical time period.

[0083] In this embodiment, after obtaining the traffic flow and the traffic accident incidence rate at each future moment of multiple intersections in the future time period, the high-risk time period and the high-risk road section can be determined according to the traffic flow and the traffic accident incidence rate at each future moment of multiple intersections in the future time period and the feature representation of the multiple key road sections in the key historical time period of the historical time period, and the prompt information of the high-risk time period and the prompt information of the high-risk road section are output. In an alternative embodiment, the high-risk time period and the high-risk road section, and / or the prompt information of the high-risk time period and the prompt information of the high-risk road section can be visualized so that the user can intuitively identify the high-risk area and time period, thereby more deeply understanding the spatial aggregation and temporal evolution of traffic risks.

[0084] In one embodiment, as Figure 2 shown, Figure 2 is a schematic flowchart of a traffic accident incidence rate prediction method based on Gumbel sparse attention according to an embodiment of the present invention. In Figure 2 , first starting from the spatio-temporal traffic accident data in the grid space (such as the WH grid containing historical traffic accident incidence rate and traffic flow), these features are projected onto the graph nodes through a mapping function to obtain the data in the graph structure, so as to construct an intuitive understanding of the road network spatial structure in the graph domain, enabling the traffic accident incidence rate prediction model to utilize the road network topology structure and more clearly distinguish spatial relationships.

[0085] After mapping the data to the graph representation, the traffic accident incidence rate prediction model applies the Gumbel sparse graph attention network (Gumbel-Softmax sparse attention mechanism for graphs) to extract key spatial features. The two-layer sparse attention mechanism of the Gumbel sparse graph attention network filters out irrelevant connections to extract highly distinguishable spatial features, only highlighting the road segments crucial for predicting accidents.

[0086] After that, time feature refinement is performed through the Gumbel sparse Transformer: the spatial embedding generated by the Gumbel sparse graph attention network is used as the input of the Gumbel sparse Transformer. The Gumbel sparse Transformer captures key time information, selectively focuses on key time intervals (such as high-risk periods), filters out irrelevant time periods, and reveals deeper time dynamics.

[0087] Finally, reprojection to the grid and future prediction: Finally, the traffic accident incidence prediction model reprojects the optimized features (the output results of the Gumbel sparse Transformer) back to the original grid to generate a future accident risk prediction on a finer-grained spatial scale. This step not only covers potential spatio-temporal dependencies but also provides predictions for specific locations. By adopting a sparse attention mechanism both spatially and temporally, this embodiment can accurately locate the truly influential nodes and time steps, thereby reducing noise and unnecessary computations.

[0088] It should be noted that for method embodiments, for simplicity of description, they are all expressed as a series of action combinations. However, those skilled in the art should be aware that the embodiments of the present invention are not limited by the described action sequences because, according to the embodiments of the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily essential for the embodiments of the present invention.

[0089] Based on the same inventive concept, an embodiment of the present invention provides a traffic accident incidence prediction device. Refer to Figure 3 , Figure 3 which is a structural block diagram of a traffic accident incidence prediction device provided by an embodiment of the present invention. As shown in Figure 3 , the traffic accident incidence prediction device of this embodiment may include: A data acquisition module, configured to acquire traffic accident spatio-temporal data in a grid space, where the traffic accident spatio-temporal data characterizes the traffic flow and traffic accident incidence at multiple intersections during a historical time period; A data conversion module, configured to convert the traffic accident spatio-temporal data in the grid space into data in a graph structure, where the data in the graph structure includes a node matrix and an adjacency matrix. The feature representation of a node in the node matrix is used to characterize the traffic flow and traffic accident incidence at an intersection during a historical time period, and the adjacency matrix characterizes whether there is a road section between the intersections corresponding to every two nodes; A data processing module, configured to process the data in the graph structure through a traffic accident incidence prediction model to obtain the feature representations of multiple key road sections in multiple road sections corresponding to the multiple intersections and the feature representations of the multiple key road sections during a key historical time period within the historical time period; A data prediction module, configured to predict the feature representations of each intersection within a future time period according to the feature representations of the multiple key road sections during the key historical time period within the historical time period. The traffic accident incidence prediction model is trained with the traffic flow and traffic accident incidence at multiple sample intersections during a sample historical time period as training samples. A data mapping module, configured to map the feature representations of the respective intersections in a future time period back to the grid space, so as to obtain the traffic flow and the accident incidence rate at each future moment of the multiple intersections in the future time period.

[0090] Optionally, the accident incidence rate prediction model at least includes a spatial correlation extraction module, and the spatial correlation extraction module includes a first spatial correlation extraction sub-module and a second spatial correlation extraction sub-module; the data processing module includes: A first processing module, configured to process the data in the graph structure through the first spatial correlation extraction sub-module to obtain intermediate feature representations of the multiple intersections; A second processing module, configured to input the intermediate feature representations of the multiple intersections into the second spatial correlation extraction sub-module for processing, and obtain the output result of the second spatial correlation extraction sub-module as the feature representations of multiple key road segments among the multiple road segments corresponding to the multiple intersections.

[0091] Optionally, the first processing module includes: A first determination module, configured to, based on the adjacency matrix, for each intersection among the multiple intersections, determine adjacent intersections that have road segments with this intersection from the remaining intersections, and non-adjacent intersections that do not have road segments with this intersection; A first execution module, for the i-th intersection among the multiple intersections, execute the following steps through the first spatial correlation extraction sub-module: Filter out non-adjacent intersections that do not have road segments with the i-th intersection; According to the feature representation of the i-th intersection and the feature representation of the j-th adjacent intersection of the i-th intersection, obtain the score of the j-th adjacent intersection of the i-th intersection; Based on the score of the j-th adjacent intersection of the i-th intersection, according to the Gumbel-Softmax-based sparse attention mechanism with a temperature coefficient of τ, assign weights to the j-th adjacent intersection of the i-th intersection; Based on the weights assigned to the respective adjacent intersections of the i-th intersection and the feature representations of the respective adjacent intersections of the i-th intersection, obtain the intermediate feature representation of the i-th intersection; wherein, i is a natural number greater than 0, and j is a natural number greater than 0.

[0092] Optionally, the accident incidence rate prediction model further includes a temporal correlation extraction module connected in series after the spatial correlation extraction module, and the temporal correlation extraction module includes L serially connected temporal correlation extraction sub-modules, and each temporal correlation extraction sub-module at least includes a Gumbel-Softmax sparse multi-head attention layer; the data processing module includes: The second execution module is used to execute the following steps through the Gumbel-Softmax sparse multi-head attention layer in the l-th time correlation extraction sub-module: Perform a linear projection on the input of the Gumbel-Softmax sparse multi-head attention layer in the l-th time correlation extraction sub-module to obtain a Q matrix, a K matrix, and a V matrix; wherein, the input of the Gumbel-Softmax sparse multi-head attention layer in the first time correlation extraction sub-module is: the feature representations of multiple key road segments among multiple road segments corresponding to multiple intersections; Process the Q matrix to obtain the scores of each historical time interval within the historical time period; Based on the scores of each historical time interval, according to the Gumbel-Softmax-based sparse attention mechanism with a temperature coefficient of τ, generate a mask result for each historical time interval; when the mask result of a historical time interval is 1, it indicates that this historical time interval belongs to the key historical time period; Perform attention calculation based on the Q matrix and the K matrix to obtain the attention calculation results of multiple key road segments; Based on the attention calculation results of the multiple key road segments and the mask result of each historical time interval, obtain the scores of the multiple key road segments within the key historical time period of the historical time period; Perform softmax processing on the scores of the multiple key road segments within the key historical time period of the historical time period to obtain the weights of the multiple key road segments within the key historical time period of the historical time period; Based on the weights of the multiple key road segments within the key historical time period of the historical time period and the V matrix, obtain the output result of the Gumbel-Softmax sparse multi-head attention layer in the l-th time correlation extraction sub-module; The second determination module is used to use the output result of the Gumbel-Softmax sparse multi-head attention layer in the L-th time correlation extraction sub-module as the feature representation of the multiple key road segments within the key historical time period of the historical time period; Wherein, l and L are natural numbers greater than 0, and l ∈ [1, L].

[0093] Optionally, each time correlation extraction sub-module further includes an FFN layer; the data prediction module includes: The third processing module is used to process the output result of the Gumbel-Softmax sparse multi-head attention layer in the l-th time correlation extraction sub-module through the FFN layer in the l-th time correlation extraction sub-module to obtain the output result of the l-th time correlation extraction sub-module; The fourth processing module is configured to input the output result of the l-th temporal correlation extraction sub-module into the (l + 1)-th temporal correlation extraction sub-module for processing until the output result of the L-th temporal correlation extraction sub-module is obtained, which is used as the feature representation of each intersection in the future time period.

[0094] Optionally, the data acquisition module includes: The first acquisition module is configured to acquire the original traffic spatio-temporal data in the grid space; The third determination module is configured to determine the spatio-temporal distribution uniformity of the traffic accident data in the original traffic spatio-temporal data; The fourth determination module is configured to, when the spatio-temporal distribution uniformity of the traffic accident data is greater than the spatio-temporal distribution uniformity threshold, use the traffic accident data in the original traffic spatio-temporal data as the traffic accident spatio-temporal data in the grid space.

[0095] Optionally, the device further includes: The prompt output module is configured to output prompt information of high-risk time periods and prompt information of high-risk road segments according to the traffic flow and traffic accident incidence rate at each future moment in the future time period of the multiple intersections, and the feature representation of the multiple key road segments in the key historical time period of the historical time period.

[0096] Based on the same inventive concept, another embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps in the traffic accident incidence rate prediction method as described in any one of the above embodiments of the present invention are implemented.

[0097] Based on the same inventive concept, another embodiment of the present invention provides an electronic device, as Figure 4 shown. Figure 4 is a schematic diagram of an electronic device shown in an embodiment of the present invention. The electronic device includes a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes, the steps in the traffic accident incidence rate prediction method as described in any one of the above embodiments of the present invention are implemented.

[0098] For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple. For the relevant parts, please refer to the partial description of the method embodiment.

[0099] Each embodiment in this specification is described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The same or similar parts among the embodiments can be referred to each other.

[0100] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, an apparatus, or a computer program product. Therefore, the embodiments of the present invention can take the form of an all-hardware embodiment, an all-software embodiment, or an embodiment combining software and hardware aspects. Moreover, the embodiments of the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memory, CD-ROM, optical memory, etc.) that contain computer-usable program code.

[0101] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each flow and / or block in the flowchart and / or block diagram, as well as the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing terminal devices generate a device for implementing the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.

[0102] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal devices to work in a specific manner, such that the instructions stored in the computer-readable memory generate a manufactured article including an instruction device that implements the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.

[0103] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal devices, such that a series of operation steps are executed on the computer or other programmable terminal devices to generate a computer-implemented process, so that the instructions executed on the computer or other programmable terminal devices provide steps for implementing the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.

[0104] Although the preferred embodiments of the embodiments of the present invention have been described, those skilled in the art can make additional changes and modifications once they know the basic creative concepts. Therefore, the appended claims are intended to be construed to include the preferred embodiments and all changes and modifications falling within the scope of the embodiments of the present invention.

[0105] Finally, it should also be noted that in this text, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or terminal device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or terminal device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or terminal device comprising the said element.

[0106] The above has introduced in detail a method, apparatus, device and medium for predicting the traffic accident rate provided by the present invention. Specific examples are used in this text to elaborate on the principle and implementation manner of the present invention. The description of the above embodiments is only used to help understand the method and its core idea of the present invention; at the same time, for those of ordinary skill in the art, according to the idea of the present invention, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present invention.

Claims

1. A method for predicting the incidence rate of traffic accidents, characterized in that, The method includes: Obtaining the spatio-temporal data of traffic accidents in a grid space, where the spatio-temporal data of traffic accidents characterizes the traffic flow and the traffic accident incidence rate at multiple intersections during a historical time period; Converting the spatio-temporal data of traffic accidents in the grid space into data in a graph structure, where the data in the graph structure includes a node matrix and an adjacency matrix. The feature representation of a node in the node matrix is used to characterize the traffic flow and the traffic accident incidence rate at an intersection during a historical time period, and the adjacency matrix characterizes whether there is a road section between the intersections corresponding to every two nodes; Processing the data in the graph structure through a traffic accident incidence rate prediction model to obtain the feature representations of multiple critical road sections in the multiple road sections corresponding to the multiple intersections and the feature representations of the multiple critical road sections during a critical historical time period in the historical time period; Predicting the feature representations of each intersection in a future time period according to the feature representations of the multiple critical road sections during the critical historical time period in the historical time period. The traffic accident incidence rate prediction model is trained with the traffic flow and the traffic accident incidence rate of multiple sample intersections during a sample historical time period; Mapping the feature representations of each intersection in the future time period back to the grid space to obtain the traffic flow and the traffic accident incidence rate of each future moment of the multiple intersections in the future time period.

2. The traffic accident incidence prediction method according to claim 1, wherein The traffic accident incidence rate prediction model at least includes a spatial correlation extraction module, and the spatial correlation extraction module includes a first spatial correlation extraction sub-module and a second spatial correlation extraction sub-module; Processing the data in the graph structure through a traffic accident incidence rate prediction model to obtain the feature representations of multiple critical road sections in the multiple road sections corresponding to the multiple intersections, including: Processing the data in the graph structure through the first spatial correlation extraction sub-module to obtain the intermediate feature representations of the multiple intersections; Inputting the intermediate feature representations of the multiple intersections into the second spatial correlation extraction sub-module for processing, and taking the output result of the second spatial correlation extraction sub-module as the feature representations of multiple critical road sections in the multiple road sections corresponding to the multiple intersections.

3. The traffic accident rate prediction method according to claim 2, characterized in that Processing the data in the graph structure through the first spatial correlation extraction sub-module to obtain the intermediate feature representations of the multiple intersections, including: Based on the adjacency matrix, for each intersection among the multiple intersections, determining the adjacent intersections that have a road section with this intersection and the non-adjacent intersections that do not have a road section with this intersection from the remaining intersections; For the i-th intersection among the multiple intersections, through the first spatial correlation extraction sub-module, perform the following steps: Filtering out the non-adjacent intersections that do not have a road section with the i-th intersection; Obtaining the score of the j-th adjacent intersection of the i-th intersection according to the feature representation of the i-th intersection and the feature representation of the j-th adjacent intersection of the i-th intersection; Based on the score of the j-th adjacent intersection of the i-th intersection, according to the Gumbel-Softmax-based sparse attention mechanism with a temperature coefficient of τ, assign weights to the j-th adjacent intersection of the i-th intersection; Based on the weights assigned to each adjacent intersection of the i-th intersection and the feature representations of each adjacent intersection of the i-th intersection, obtain the intermediate feature representation of the i-th intersection; Wherein, i is a natural number greater than 0, and j is a natural number greater than 0.

4. The traffic accident rate prediction method according to claim 2, characterized in that The traffic accident incidence prediction model further includes a time correlation extraction module connected in series after the spatial correlation extraction module. The time correlation extraction module includes L time correlation extraction sub-modules connected in series. Each time correlation extraction sub-module includes at least a Gumbel-Softmax sparse multi-head attention layer; by processing the data under the graph structure in the traffic accident occurrence probability prediction model, obtain the feature representations of the multiple key road segments during the key historical time period in the historical time period, including: Through the Gumbel-Softmax sparse multi-head attention layer in the l-th time correlation extraction sub-module, perform the following steps: Perform a linear projection on the input of the Gumbel-Softmax sparse multi-head attention layer in the l-th time correlation extraction sub-module to obtain a Q matrix, a K matrix, and a V matrix; wherein, the input of the Gumbel-Softmax sparse multi-head attention layer in the first time correlation extraction sub-module is: the feature representations of multiple key road segments among multiple road segments corresponding to multiple intersections; Process the Q matrix to obtain the scores of each historical time interval in the historical time period; Based on the score of each historical time interval, according to the Gumbel-Softmax-based sparse attention mechanism with a temperature coefficient of τ, generate a mask result for each historical time interval; when the mask result of a historical time interval is 1, it indicates that this historical time interval belongs to the key historical time period; Perform attention calculation based on the Q matrix and the K matrix to obtain the attention calculation results of multiple key road segments; Based on the attention calculation results of the multiple key road segments and the mask result of each historical time interval, obtain the scores of the multiple key road segments during the key historical time period in the historical time period; Perform softmax processing on the scores of the multiple key road segments during the key historical time period in the historical time period to obtain the weights of the multiple key road segments during the key historical time period in the historical time period; Based on the weights of the multiple key road segments during the key historical time period in the historical time period and the V matrix, obtain the output result of the Gumbel-Softmax sparse multi-head attention layer in the l-th time correlation extraction sub-module; Take the output result of the Gumbel-Softmax sparse multi-head attention layer in the L-th time correlation extraction sub-module as the feature representations of the multiple key road segments during the key historical time period in the historical time period; Wherein, l and L are natural numbers greater than 0, and l ∈ [1, L].

5. The traffic accident incidence prediction method according to claim 4, characterized in that Each time correlation extraction sub-module further includes an FFN layer; predicting the feature representations of each intersection in a future time period according to the feature representations of the multiple key road segments in the key historical time period of the historical time period includes: Processing the output result of the Gumbel-Softmax sparse multi-head attention layer in the l-th time correlation extraction sub-module through the FFN layer in the l-th time correlation extraction sub-module to obtain the output result of the l-th time correlation extraction sub-module; Inputting the output result of the l-th time correlation extraction sub-module into the (l + 1)-th time correlation extraction sub-module for processing until the output result of the L-th time correlation extraction sub-module is obtained as the feature representations of each intersection in the future time period.

6. The traffic accident incidence prediction method according to any one of claims 1 to 5, characterized in that Obtain the spatio-temporal data of traffic accidents in the grid space, including: Obtain the original traffic spatio-temporal data in the grid space; Determine the spatio-temporal distribution uniformity of the traffic accident data in the original traffic spatio-temporal data; When the spatio-temporal distribution uniformity of the traffic accident data is greater than the spatio-temporal distribution uniformity threshold, use the traffic accident data in the original traffic spatio-temporal data as the spatio-temporal data of traffic accidents in the grid space.

7. The traffic accident rate prediction method according to any one of claims 1 to 5, characterized in that The method further includes: Outputting prompt information for high-risk time periods and prompt information for high-risk road segments according to the traffic flow and traffic accident incidence rates of each future moment of the multiple intersections in the future time period, and the feature representations of the multiple key road segments in the key historical time period of the historical time period.

8. A traffic accident incidence prediction device, characterized in that, The device includes: A data acquisition module, configured to acquire spatio-temporal data of traffic accidents in the grid space, where the spatio-temporal data of traffic accidents characterizes the traffic flow and traffic accident incidence rates of multiple intersections in a historical time period; A data conversion module, configured to convert the spatio-temporal data of traffic accidents in the grid space into data in a graph structure, where the data in the graph structure includes a node matrix and an adjacency matrix, the feature representation of a node in the node matrix is used to characterize the traffic flow and traffic accident incidence rate of an intersection in a historical time period, and the adjacency matrix characterizes whether there is a road segment between the intersections corresponding to every two nodes; A data processing module, configured to process the data in the graph structure through a traffic accident incidence rate prediction model to obtain the feature representations of multiple key road segments among the multiple road segments corresponding to the multiple intersections and the feature representations of the multiple key road segments in the key historical time period of the historical time period; A data prediction module, configured to predict the feature representations of each intersection in a future time period according to the feature representations of the multiple key road segments in the key historical time period of the historical time period, and the traffic accident incidence rate prediction model is trained with the traffic flow and traffic accident incidence rates of multiple sample intersections in a sample historical time period as training samples. A data mapping module, configured to map the feature representations of the respective intersections in a future time period back to the grid space, so as to obtain the traffic flow and the accident incidence rate at each future moment of the multiple intersections in the future time period.

9. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the computer program is executed by the processor, it implements the accident incidence rate prediction method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the accident incidence rate prediction method according to any one of claims 1 to 7.