Ship trajectory prediction method based on TP2LSTM
By introducing the TP2LSTM network in ship trajectory prediction, using multi-head trajectory point association and time-mode attention mechanism, the complex features in ship trajectory data are extracted, and the problem of insufficient feature extraction in the prior art is solved, and the accuracy of prediction is improved. reliability.
Patent Information
- Application Number
- CN202411302178.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-18
- Publication Date
- 2025-01-10
AI Technical Summary
Existing ship trajectory prediction methods are difficult to effectively extract long-term and complex features hidden in the data, and the multivariate dynamic feature correlation is insufficient, resulting in low prediction accuracy and efficiency.
Using the TP2LSTM-based method, a multi-headed trajectory point-associated attention mechanism and a time-mode attention mechanism are introduced to build a TP2LSTM network, and the trajectory is extracted through trajectory point-associated attention module, long-term memory network, time-mode attention module and full-connection layer. The spatial and temporal correlation characteristics in the data improve prediction accuracy.
It improves the accuracy and reliability of ship trajectory prediction, especially in complex scenarios, which can better capture the dynamic feature correlation between trajectory attributes, and enhances the model's understanding of spatial relationships and geographical information.
Smart Images

Figure CN119293632A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of trajectory prediction, and in particular to a ship trajectory prediction method based on TP2LSTM. Background Art
[0002] With the continuous increase in water transport cargo volume and the number of ships at sea, shipping is becoming increasingly important in global trade, accounting for 90% of the total global trade. However, shipping also faces risks such as ship collisions, piracy, illegal fishing and oil spills. In order to ensure the safety of ship navigation and the efficiency of waterway passage, it is crucial to accurately obtain the location information and movements of ships and realize marine ship detection. By building a suitable prediction model to learn the historical trajectory data of the Automatic Identification System (AIS), the accurate prediction of the target trajectory can be achieved, especially the trajectory prediction in complex scenarios, which is of great significance to ensuring the safety of maritime transportation and promoting the development of intelligent shipping.
[0003] At present, there are many research methods for ship trajectory prediction, mainly including traditional machine learning models, deep learning models and hybrid methods combining deep learning with other methods. Traditional machine learning prediction models are suitable for trajectory prediction of small data sets, and the training speed on large-scale samples is very slow. Deep learning models mainly use neural networks to mine the contextual information of track data, analyze the associated features of the track, and predict the track of the ship at the next moment. These methods often ignore the complex correlation between trajectory points and the modeling of deep dependencies between specific attributes, and face the challenges of high computational complexity, limited generalization ability and insufficient interpretability. These problems limit the performance and effect when processing complex trajectory data. Summary of the invention
[0004] In order to solve the problems that the ship trajectory prediction methods in the prior art are difficult to effectively extract long-term and complex features hidden in the data in space and time, and the correlation of multivariate dynamic features is insufficiently considered, the present invention provides a ship trajectory prediction method based on TP2LSTM, which utilizes the characteristics of the multi-head trajectory point association attention mechanism and the temporal pattern attention mechanism to extract long-term and complex features hidden in the trajectory data in space and time, thereby fully considering the correlation of multivariate dynamic features and improving the accuracy of ship trajectory prediction.
[0005] In a first aspect, the present invention provides a ship trajectory prediction method based on TP2LSTM, comprising:
[0006] Step 1: Obtain historical track data of the target ship; wherein the historical track data includes information of track points of the target ship at the previous N moments, and the information of each track point includes longitude, latitude, heading over the ground and speed;
[0007] Step 2: Input the historical trajectory data into the ship trajectory prediction model to predict the trajectory data of the target ship at a future time;
[0008] The training process of the ship trajectory prediction model includes:
[0009] Construct a TP2LSTM network, including a sequentially connected trajectory point association attention TPCA module, a long short-term memory network LSTM module, a temporal pattern attention TPA module, and a fully connected layer;
[0010] A ship trajectory dataset is constructed to train the TP2LSTM network to obtain a ship trajectory prediction model; wherein the TPCA module extracts the spatial association between trajectory points from the input ship trajectory data at historical moments based on the attention mechanism; the LSTM module further extracts the temporal association between trajectory points from the input ship trajectory data at historical moments based on the output of the TPCA; the TPA module further extracts the association between multiple information in the trajectory points at multiple time steps based on the output of the LSTM module using the temporal pattern attention mechanism; the fully connected layer predicts the ship trajectory at future moments based on the output of the TPA module.
[0011] Furthermore, the TPCA module extracts the spatial association between trajectory points from the input ship trajectory data at historical moments based on the attention mechanism, specifically including:
[0012] Each trajectory point in the ship trajectory dataset is embedded into the high-dimensional space, and the calculation formula is as follows:
[0013] Q=XW Q
[0014] K=XW K
[0015] V=XW V
[0016] Among them, X represents the trajectory point, W Q , W K , W V The weights of query Q, key K, and value V are respectively represented as the linear projection parameters of the trajectory point X;
[0017] The similarity between query Q and key K is calculated and normalized to obtain the attention weights of query Q and key K. The calculation process is as follows:
[0018] S = einsum(qhd,khd->hqk,Q,K)
[0019]
[0020] Among them, S represents the similarity score, einsum represents the einsum function, qhd, khd and hqk represent formal parameters, the dimensions of Q and K are passed to the formal parameters, Attention represents the attention weight, d k represents the dimension of the embedding layer of the TPCA module, and softmax represents the softmax activation function;
[0021] Calculate the weighted representation of Attention and value V to get the intermediate output:
[0022] out=einsum(hql,lhd->qhd,Attention,V)
[0023] Among them, out represents the intermediate output, hql, lhd and qhd represent formal parameters, and the dimensions of Attention and V are passed to the formal parameters;
[0024] The intermediate output is dimensionally transformed to obtain a spatial correlation feature map.
[0025] Furthermore, the output of the LSTM module is a hidden state matrix corresponding to the input ship trajectory data at the historical moment; wherein the column vector of the hidden state matrix represents the ship trajectory point information at the same time step, and the row vector represents the state of each information of the ship trajectory point at all time steps;
[0026] Correspondingly, the TPA module further extracts the association between multiple variables in the trajectory points at multiple time steps based on the output of the LSTM module using the temporal pattern attention mechanism, specifically including:
[0027] For each row vector, a one-dimensional filter is used to convolve all elements in the row vector, and the convolution results of all row vectors constitute a time pattern matrix;
[0028] Calculate the trajectory information attention weight between the temporal pattern matrix and the output of the LSTM module at the current moment;
[0029] Obtaining an attention vector by weighted summing the attention weight of the trajectory information and the row vector of the temporal pattern matrix;
[0030] The attention vector is linearly mapped to the output of the LSTM module at the current moment and then added to obtain the intermediate variable of the final value.
[0031] Furthermore, the calculating of the attention weight between the temporal pattern matrix and the output of the LSTM module at the current moment specifically includes:
[0032] Calculate the correlation between the row vector of the temporal pattern matrix and the output of the LSTM module at the current moment:
[0033]
[0034] in, Denotes the temporal pattern matrix H C The vector of the i-th row, W a represents the weight matrix, h t Represents the output of the LSTM module at the current moment;
[0035] The trajectory information attention weight α is obtained through the correlation i :
[0036]
[0037] Among them, sigmoid represents the sigmoid activation function.
[0038] Furthermore, the fully connected layer predicts the ship trajectory at a future time based on the output of the TPA module, and the ship trajectory at a future time is as follows:
[0039] y t-1+Δ =W h′ h t ′=W h′ (W h h t +W ν v t )
[0040] Among them, y t-1+△ represents the ship's trajectory at the future time, h t ' represents the intermediate variable that generates the final value, v t represents the attention vector, h t represents the output of the LSTM module at the current moment, △ represents the prediction time scale of different prediction trajectory tasks, and W h' , W h and W v Represents different weight matrices for corresponding variables.
[0041] Furthermore, in the training process of the ship trajectory prediction model, the loss function used is:
[0042]
[0043] in,
[0044]
[0045] Wherein, N represents the number of ships in the ship trajectory dataset, dis represents the distance difference between the predicted ship trajectory point and the actual ship trajectory point, R1 represents the ground heading of the actual ship trajectory point, R2 represents the ground heading of the predicted ship trajectory point, C represents the angle calculated using the spherical trigonometry formula, A represents the equatorial radius, B represents the polar radius of the WGS-84 ellipsoid, lat1 and lon1 represent the latitude and longitude of the actual ship trajectory point, respectively, and lat2 and lon2 represent the latitude and longitude of the predicted ship trajectory point, respectively.
[0046] Furthermore, before the historical trajectory data is input into the ship trajectory prediction model, it also includes: preprocessing the historical trajectory data, including at least one of data cleaning, trajectory segmentation and trajectory interpolation.
[0047] In a second aspect, the present invention provides a ship trajectory prediction system based on TP2LSTM, the system comprising:
[0048] A data acquisition module is used to obtain historical trajectory data of the target ship;
[0049] A model building module is used to construct a TP2LSTM network and use a ship trajectory data set to train the TP2LSTM network to obtain a ship trajectory prediction model;
[0050] The trajectory prediction module is used to input the historical trajectory data into the ship trajectory prediction model to predict the trajectory data of the target ship at a future moment.
[0051] In a third aspect, the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the ship trajectory prediction method based on TP2LSTM as described above is implemented.
[0052] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the ship trajectory prediction method based on TP2LSTM as described above is executed.
[0053] Compared with the prior art, the present invention has the following technical effects:
[0054] The present invention proposes a ship trajectory prediction method based on TP2LSTM, which constructs a new ship trajectory prediction model by introducing the trajectory point association attention (TPCA) mechanism and the temporal pattern attention (TPA) mechanism into the LSTM prediction model. The introduction of the TPCA mechanism enables the model to not only pay attention to the order of a series of ship trajectory points, but also to have a deeper understanding of the correlation between these points when processing a series of ship trajectory points; the introduction of the TPA mechanism enables the model to better capture the important patterns and features in the time series, more comprehensively consider the dynamic feature correlation between trajectory attributes, and more accurately predict the future position of the ship.
[0055] The present invention further enhances the ship trajectory prediction model's ability to understand spatial relationships and geographic information by using a curvature-aware great circle route loss function, helping the model to better handle position offsets and uncertainties, thereby improving the accuracy and reliability of predictions. The method of the present invention is superior to other methods in both turning and straight-line navigation, and also demonstrates its higher reliability in multi-step predictions. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] Figure 1 A schematic diagram of a process flow of a ship trajectory prediction method based on TP2LSTM provided in an embodiment of the present invention;
[0057] Figure 2 TP2LSTM network framework diagram provided for an embodiment of the present invention;
[0058] Figure 3 The historical trajectory of the ship to be tested and the predicted trajectory result diagram provided by the embodiment of the present invention;
[0059] Figure 4 A diagram showing the prediction result of a ship's straight trajectory provided by an embodiment of the present invention;
[0060] Figure 5 One of the ship curve trajectory prediction result diagrams provided by an embodiment of the present invention;
[0061] Figure 6 This is a second diagram of the ship curve trajectory prediction result provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0062] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution in the embodiment of the present invention will be clearly described below in conjunction with the drawings in the embodiment of the present invention. Obviously, the described embodiment is a part of the embodiment of the present invention, not all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0063] like Figure 1 As shown, the embodiment of the present invention provides a ship trajectory prediction method based on TP2LSTM, comprising the following steps:
[0064] Step 1: Obtain historical trajectory data of the target ship;
[0065] Specifically, the historical track data includes the information of the track points of the target ship at the previous N moments, and the information of each track point includes longitude, latitude, heading over the ground and speed;
[0066] It can be understood that in the embodiment of the present invention, the historical track data of the ship is obtained through the AIS system. The historical track data of the ship obtained through the AIS system includes ship static data, ship dynamic data and ship voyage data. The ship static data includes ship name, call sign, MMSI number, ship length and ship width, etc. The ship dynamic data includes longitude, latitude, ship heading and ship speed, etc. The ship voyage data includes ship status, draft and ETA, etc.
[0067] Specifically, the historical trajectory data of the ship is as follows:
[0068]
[0069] in, Indicates that at timestamp t n The AIS data information at that time, lon represents longitude, lat represents latitude, cog represents the ship's course over the ground - the direction of the navigation track, and sog represents the ship's speed.
[0070]
[0071] Among them, T n Indicates that in the time period t1~t n The collection of historical track data information of ships in , where i represents the MMSI number.
[0072] Furthermore, the historical trajectory data is preprocessed, including at least one of data cleaning, trajectory segmentation and trajectory interpolation.
[0073] Specifically, data cleaning is to delete errors and noise data in historical trajectory data. There are four types of errors or noise in historical trajectory data, namely, abnormal MMSI column data, abnormal SOG column data, duplicate data, and abnormal COG column data. MMSI is the maritime mobile service identification code, with a standard length of 9 bits. Abnormal MMSI column data means that its length is not the standard length; SOG is the ship's speed to the ground. Since it is difficult for a ship to accelerate or decelerate quickly in a short period of time when sailing at sea, the values with large differences in the SOG column data are abnormal values; there are duplicate data in the historical trajectory data, which are not conducive to neural network training and are prone to overfitting, so duplicate data need to be removed; COG represents the direction of navigation to the ground, and its value range is 0≤cog<360, so COG values outside this range are abnormal values.
[0074] Specifically, the track segmentation is to divide the continuous track data of the ship into multiple sections, so as to study the movement track of the ship in more detail. According to the stop condition, observation interval and speed condition, the conditions are set to determine the segmentation point of the track; in this embodiment, the stop condition is set as the sailing time within 1000 meters exceeds 30 minutes and the travel exceeds 5000 meters, the observation interval is no data within 30 minutes, and the speed condition is the speed is less than 1.852 kilometers per hour. When the ship AIS data meets the stop condition, observation interval and speed conditions, the sub-track is divided.
[0075] It can be understood that if the ship is interfered with by the signal when sending the AIS signal, the historical trajectory data it receives will present non-uniform time intervals, so it is necessary to set conditions according to the stop conditions, observation intervals and speed conditions to determine the segmentation points of the trajectory in order to segment the trajectory.
[0076] Specifically, the trajectory interpolation is to repair the trajectory data using cubic spline interpolation.
[0077] It is understandable that when a ship is subject to obstacles and electromagnetic interference, data will be lost and erroneous. After removing the obvious abnormal data, the trajectory data will be repaired.
[0078] Step 2: Input the historical trajectory data into the ship trajectory prediction model to predict the trajectory data of the target ship at the future moment;
[0079] Specifically, the training process of the above-mentioned ship trajectory prediction model includes:
[0080] Construct a TP2LSTM network, such as Figure 2 As shown, the TP2LSTM network framework provided by the embodiment of the present invention includes a trajectory point association attention TPCA module, a long short-term memory network LSTM module, a temporal pattern attention TPA module and a fully connected layer connected in sequence;
[0081] Constructing a ship trajectory data set to train the TP2LSTM network and obtain a ship trajectory prediction model;
[0082] Among them, the TPCA module extracts the spatial correlation between trajectory points from the input ship trajectory data of historical moments based on the attention mechanism; the LSTM module further extracts the temporal correlation between trajectory points from the input ship trajectory data of historical moments based on the output of the TPCA; the TPA module further extracts the correlation between multiple information in the trajectory points at multiple time steps based on the output of the LSTM module using the temporal pattern attention mechanism; the fully connected layer predicts the ship trajectory at future moments based on the output of the TPA module.
[0083] Specifically, the TPCA module extracts the spatial associations between trajectory points from the input historical ship trajectory data based on the attention mechanism, including:
[0084] Each trajectory point in the ship trajectory dataset is embedded into the high-dimensional space. The calculation formula is as follows:
[0085] Q=XW Q
[0086] K=XW K
[0087] V=XW V
[0088] Among them, X represents the trajectory point, W Q , W K , W V They are represented as the weights of query Q, key K, and value V, respectively, as the linear projection parameters of trajectory point X;
[0089] Furthermore, Q, K, and V are rearranged so that Q, K, and V ∈ R sequence×head×head_dim .
[0090] The similarity between query Q and key K is calculated and normalized to obtain the attention weights of query Q and key K. The calculation process is as follows:
[0091] S = einsum(qhd,khd->hqk,Q,K)
[0092]
[0093] Among them, S represents the similarity score, einsum represents the einsum function, qhd, khd and hqk represent formal parameters, the dimensions of Q and K are passed to the formal parameters, Attention represents the attention weight, d krepresents the dimension of the embedding layer of the TPCA module, and softmax represents the softmax activation function;
[0094] Calculate the weighted representation of Attention and value V to get the intermediate output:
[0095] out=einsum(hql,lhd->qhd,Attention,V)
[0096] Among them, out represents the intermediate output, hql, lhd and qhd represent formal parameters, and the dimensions of Attention and V are passed to the formal parameters;
[0097] The intermediate output is transformed in dimension to obtain a spatial correlation feature map.
[0098] It can be understood that the dimensionality transformation of the intermediate output is to keep the dimensions of the input and output consistent.
[0099] Specifically, the output of the LSTM module is the hidden state matrix corresponding to the input ship trajectory data at the historical moment; the column vector of the hidden state matrix represents the ship trajectory point information at the same time step, and the row vector represents the state of each information of the ship trajectory point at all time steps;
[0100] Correspondingly, the TPA module uses the temporal pattern attention mechanism based on the output of the LSTM module to further extract the association between multiple variables in the trajectory points at multiple time steps, including:
[0101] For each row vector, a one-dimensional filter is used to convolve all elements in the row vector, and the convolution results of all row vectors constitute a time pattern matrix;
[0102] Specifically, for the i-th row of the hidden state matrix H, k one-dimensional filters are used to extract features to generate a temporal pattern matrix H with a dimension of m*k C , the elements of the temporal pattern matrix are calculated as follows:
[0103]
[0104] Among them, C j represents the jth filter of length T, T represents the maximum length to be paid attention to, usually w, and * represents the convolution operation. The one-dimensional filter has k convolution kernels, each of which is convolved along the row vector of the hidden state matrix. The temporal pattern matrix contains the complex internal connections and temporal relationships of different sequences, and is a high-dimensional embodiment of the complex nonlinear relationships between different sequences.
[0105] Calculate the attention weight of the trajectory information between the temporal pattern matrix and the output of the LSTM module at the current moment, including:
[0106] Calculate the correlation between the row vector of the temporal pattern matrix and the output of the LSTM module at the current moment:
[0107]
[0108] in, Denotes the temporal pattern matrix H C The vector of the i-th row, W a represents the weight matrix, h t Represents the output of the LSTM module at the current moment;
[0109] The trajectory information attention weight α is obtained by correlation i :
[0110]
[0111] Among them, sigmoid represents the sigmoid activation function; the sigmoid activation function is used here instead of softmax because we hope that more than one variable is useful for prediction.
[0112] Using trajectory information attention weight α i With the time pattern matrix H C The weighted sum of the row vectors of t :
[0113]
[0114] Where n represents the number of input trajectory point information, v t represents the attention vector.
[0115] The attention vector is linearly mapped to the output of the LSTM module at the current moment and then added to obtain the intermediate variable of the final value.
[0116] Specifically, the fully connected layer predicts the ship trajectory at the future time based on the output of the TPA module. The ship trajectory at the future time is as follows:
[0117] y t-1+Δ =W h′ h t ′=W h′ (W h h t +W ν v t )
[0118] Among them, y t-1+△ represents the ship's trajectory at the future time, h t ' represents the intermediate variable that generates the final value, v t represents the attention vector, h trepresents the output of the LSTM module at the current moment, △ represents the prediction time scale of different prediction trajectory tasks, and W h' , W h and W v Represents different weight matrices for corresponding variables.
[0119] Specifically, in the training process of the ship trajectory prediction model, the loss function used is:
[0120]
[0121] in,
[0122]
[0123]
[0124] Wherein, N represents the number of ships in the ship trajectory dataset, dis represents the distance difference between the predicted ship trajectory point and the actual ship trajectory point, R1 represents the ground heading of the actual ship trajectory point, R2 represents the ground heading of the predicted ship trajectory point, C represents the angle calculated using the spherical trigonometry formula, A represents the equatorial radius, B represents the polar radius of the WGS-84 ellipsoid, lat1 and lon1 represent the latitude and longitude of the actual ship trajectory point, respectively, and lat2 and lon2 represent the latitude and longitude of the predicted ship trajectory point, respectively.
[0125] like Figure 3 As shown, the embodiment of the present invention provides historical trajectory data of the target ship and predicted trajectory data at a future moment.
[0126] The embodiment of the present invention further provides a ship trajectory prediction system based on TP2LSTM, the system comprising:
[0127] A data acquisition module is used to obtain historical trajectory data of the target ship;
[0128] Model building module, used to build TP2LSTM network and use ship trajectory data set to train TP2LSTM network to obtain ship trajectory prediction model;
[0129] The trajectory prediction module is used to input historical trajectory data into the ship trajectory prediction model to predict the trajectory data of the target ship at a future moment.
[0130] An embodiment of the present invention further provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the method provided in the above embodiment is implemented, for example, including:
[0131] Step 1: Obtain historical trajectory data of the target ship;
[0132] Step 2: Input the historical trajectory data into the ship trajectory prediction model to predict the trajectory data of the target ship at the future moment.
[0133] The embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the method provided in the above embodiment is implemented, for example, including:
[0134] Step 1: Obtain historical trajectory data of the target ship;
[0135] Step 2: Input the historical trajectory data into the ship trajectory prediction model to predict the trajectory data of the target ship at the future moment.
[0136] In order to verify the generalization ability of the ship trajectory prediction model in the ship trajectory prediction method provided by the present invention, different types of trajectories are selected for prediction. Figure 4 As shown in the straight line trajectory prediction result diagram provided by the embodiment of the present invention, the real trajectory is to sail on a route close to a straight line, maintaining a relatively stable direction and speed, and the predicted value of the trajectory is also a straight line with a high similarity to the real value. Figure 5 and Figure 6 As shown in the curve trajectory prediction result diagram provided by the embodiment of the present invention, when the route is curved, Figure 5 As shown in Figure 1, the trajectory prediction results are more accurate when the speed changes slowly, and the position prediction accuracy is more consistent with the real data. Figure 6 As shown in the figure, when the speed changes sharply, although the overall error of the model prediction increases, the overall trend of the predicted route can still be basically consistent with the actual route.
[0137] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A ship trajectory prediction method based on TP2LSTM, characterized in that: include: Step 1: Obtain historical track data of the target ship; wherein the historical track data includes information of track points of the target ship at the previous N moments, and the information of each track point includes longitude, latitude, heading over the ground and speed; Step 2: Input the historical trajectory data into the ship trajectory prediction model to predict the trajectory data of the target ship at a future time; The training process of the ship trajectory prediction model includes: Construct a TP2LSTM network, including a sequentially connected track point association attention TPCA module, a long short-term memory network LSTM module, a temporal pattern attention TPA module, and a fully connected layer; A ship trajectory dataset is constructed to train the TP2LSTM network to obtain a ship trajectory prediction model; wherein the TPCA module extracts the spatial association between trajectory points from the input ship trajectory data at historical moments based on the attention mechanism; the LSTM module further extracts the temporal association between trajectory points from the input ship trajectory data at historical moments based on the output of the TPCA; the TPA module further extracts the association between multiple information in the trajectory points at multiple time steps based on the output of the LSTM module using the temporal pattern attention mechanism; the fully connected layer predicts the ship trajectory at future moments based on the output of the TPA module.
2. A ship trajectory prediction method based on TP2LSTM according to claim 1, characterized in that: The TPCA module extracts the spatial association between trajectory points from the input ship trajectory data at historical moments based on the attention mechanism, specifically including: Each trajectory point in the ship trajectory dataset is embedded into the high-dimensional space, and the calculation formula is as follows: Q=XW Q K=XW K V=XW V Among them, X represents the trajectory point, W Q , W K , W V The weights of query Q, key K, and value V are respectively represented as the linear projection parameters of the trajectory point X; The similarity between query Q and key K is calculated and normalized to obtain the attention weights of query Q and key K. The calculation process is as follows: S=einsum(qhd,khd->hqk,Q,K) Among them, S represents the similarity score, einsum represents the einsum function, qhd, khd and hqk represent formal parameters, the dimensions of Q and K are passed to the formal parameters, Attention represents the attention weight, d k represents the dimension of the embedding layer of the TPCA module, and softmax represents the softmax activation function; Calculate the weighted representation of Attention and value V to get the intermediate output: out=einsum(hql,lhd->qhd,Attention,V) Among them, out represents the intermediate output, hql, lhd and qhd represent formal parameters, and the dimensions of Attention and V are passed to the formal parameters; The intermediate output is dimensionally transformed to obtain a spatial correlation feature map.
3. A ship trajectory prediction method based on TP2LSTM according to claim 1, characterized in that: The output of the LSTM module is a hidden state matrix corresponding to the input ship trajectory data at the historical moment; wherein the column vector of the hidden state matrix represents the ship trajectory point information at the same time step, and the row vector represents the state of each information of the ship trajectory point at all time steps; Correspondingly, the TPA module further extracts the association between multiple variables in the trajectory points at multiple time steps based on the output of the LSTM module using the temporal pattern attention mechanism, specifically including: For each row vector, a one-dimensional filter is used to convolve all elements in the row vector, and the convolution results of all row vectors constitute a time pattern matrix; Calculate the trajectory information attention weight between the temporal pattern matrix and the output of the LSTM module at the current moment; Obtaining an attention vector by weighted summing the attention weight of the trajectory information and the row vector of the temporal pattern matrix; The attention vector is linearly mapped to the output of the LSTM module at the current moment and then added to obtain the intermediate variable of the final value.
4. A ship trajectory prediction method based on TP2LSTM according to claim 3, characterized in that: The calculation of the attention weight between the temporal pattern matrix and the output of the LSTM module at the current moment specifically includes: Calculate the correlation between the row vector of the temporal pattern matrix and the output of the LSTM module at the current moment: in, Denotes the temporal pattern matrix H C The vector of the i-th row, W a represents the weight matrix, h t Represents the output of the LSTM module at the current moment; The trajectory information attention weight α is obtained through the correlation i : Among them, sigmoid represents the sigmoid activation function.
5. A ship trajectory prediction method based on TP2LSTM according to claim 4, characterized in that: The fully connected layer predicts the ship trajectory at the future time based on the output of the TPA module. The ship trajectory at the future time is as follows: y t-1+Δ =W h′ h t =W h′ (W h h t +W v v t ) Among them, y t-1+Δ represents the ship trajectory at the future time, h′ t Represents the intermediate variable that generates the final value, v t represents the attention vector, h t represents the output of the LSTM module at the current moment, Δ represents the prediction time scale of different prediction trajectory tasks, and W h′ , W h and W v Represents different weight matrices for corresponding variables.
6. A ship trajectory prediction method based on TP2LSTM according to claim 1, characterized in that: In the training process of the ship trajectory prediction model, the loss function used is: in, Wherein, N represents the number of ships in the ship trajectory dataset, dis represents the distance difference between the predicted ship trajectory point and the actual ship trajectory point, R1 represents the ground heading of the actual ship trajectory point, R2 represents the ground heading of the predicted ship trajectory point, C represents the angle calculated using the spherical trigonometry formula, A represents the equatorial radius, B represents the polar radius of the WGS-84 ellipsoid, lat1 and lon1 represent the latitude and longitude of the actual ship trajectory point, respectively, and lat2 and lon2 represent the latitude and longitude of the predicted ship trajectory point, respectively.
7. The ship trajectory prediction method based on TP2LSTM according to claim 1, characterized in that: Before inputting the historical trajectory data into the ship trajectory prediction model, the method further includes: preprocessing the historical trajectory data, including at least one of data cleaning, trajectory segmentation and trajectory interpolation.
8. A ship trajectory prediction system based on TP2LSTM, characterized in that: The system comprises: A data acquisition module, used to obtain historical trajectory data of the target ship; A model building module is used to construct a TP2LSTM network and use a ship trajectory dataset to train the TP2LSTM network to obtain a ship trajectory prediction model; The trajectory prediction module is used to input the historical trajectory data into the ship trajectory prediction model to predict the trajectory data of the target ship at a future moment.
9. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 7 when executing the program.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by the processor, the ship trajectory prediction method based on TP2LSTM as described in any one of claims 1 to 7 is executed.