Ship trajectory prediction method based on multi-head key-value pair dynamic memory network
By using an end-to-end framework of multi-head key-value pair dynamic memory network and long short-term memory network, the problems of shallow feature fusion dimension and single pattern matching mechanism in existing models are solved, and high-precision ship trajectory prediction in complex marine environments is achieved, improving the model's generalization ability and prediction accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANDONG UNIV OF SCI & TECH
- Filing Date
- 2026-04-28
- Publication Date
- 2026-07-03
Smart Images

Figure CN122113682B_ABST
Abstract
Description
Technical Field
[0001] This invention discloses a ship trajectory prediction method based on a multi-head key-value pair dynamic memory network, belonging to the field of ship trajectory prediction technology. Background Technology
[0002] In recent years, deep learning-based time series prediction models combined with trajectory clustering algorithms have attracted widespread attention in the field of ship trajectory prediction. The basic principle is as follows: First, density-based spatial clustering algorithms (DBSCAN), K-means, and other algorithms are used to cluster massive amounts of historical AIS data to extract typical navigation patterns. Then, multi-dimensional features of the current ship (latitude, longitude, speed, heading, time, etc.) are extracted, concatenated into vectors, and input into a time series model (such as Long Short-Term Memory (LSTM) or Gated Recurrent Unit (GRU)). During the prediction phase, similarity matching is performed with the extracted navigation patterns, ultimately outputting the predicted position for the next moment. However, facing the complex and ever-changing real-world marine navigation environment, this type of model still faces the following problems when predicting ship trajectories.
[0003] The shallow feature fusion dimension makes it difficult to capture high-order nonlinear spatiotemporal coupling relationships. Existing sequence models, when processing multidimensional AIS data, typically only perform shallow linear concatenation of spatial coordinates, dynamic features, and timestamps. This concatenation method cannot effectively represent the complex nonlinear coupling relationship between "specific temporal context" (such as different times of day, differences in air traffic density between weekdays and non-weekdays) and "spatial dynamic features." This results in limited model generalization ability and difficulty in improving prediction accuracy.
[0004] Pattern matching mechanisms suffer from global rigidity and a single addressing dimension, making them ill-suited for handling complex, multi-dimensional, heterogeneous navigation conditions. On one hand, most existing trajectory matching technologies use the entire global trajectory as a benchmark for similarity calculation. In reality, a ship's complete navigation is composed of multiple fine-grained local typical navigation patterns (such as constant speed straight navigation, large-angle turns for obstacle avoidance, and deceleration upon entering port). Global matching is highly susceptible to failure when the ship undergoes complex local maneuvers, leading to the loss of key kinematic features. On the other hand, existing local feature matching mechanisms (such as single attention mechanisms or Euclidean distance metrics) are mostly limited to single-dimensional addressing. Traffic trajectory data contains multiple heterogeneous dimensions, including spatial, temporal, and kinematic (speed, heading) dimensions. Single matching mechanisms are easily dominated by the strong feature of "geographical coordinates" during feature retrieval, thus obscuring the implicit correlations between dimensions such as speed, heading, and time. Summary of the Invention
[0005] The purpose of this invention is to provide a ship trajectory prediction method based on a multi-head key-value pair dynamic memory network, in order to solve the problems in the prior art, such as shallow linear splicing of multi-dimensional features, extraction of complete historical global trajectories as matching templates for multiple dependencies, single-dimensional pattern matching mechanism, and accumulation of long sequence errors.
[0006] Ship trajectory prediction methods based on multi-head key-value pair dynamic memory networks include:
[0007] S1. Obtain ship trajectory data from the Automatic Identification System (AIS), preprocess the trajectory data, and obtain a valid motion trajectory sequence;
[0008] S2. Perform spatiotemporal feature engineering transformation and sample construction on the effective motion trajectory to generate input feature sequence and prediction target sample;
[0009] S3. Construct an end-to-end ship trajectory prediction framework that combines a multi-head key-value pair dynamic memory network and a long short-term memory network. Based on the input feature sequence, train the neural network. After training, output the predicted latitude and longitude relative offset of the ship in the next time step, and calculate the predicted absolute coordinates by combining the current real coordinates.
[0010] S1 includes the following preprocessing steps: setting the latitude and longitude boundaries of the target sea area, deleting outbound data, and grouping data according to the ship's maritime mobile communication service identification code.
[0011] Set a trajectory threshold to delete ship trajectories with fewer than the trajectory threshold. Set a breakage threshold to sort the same ship trajectory points by timestamp. If the time interval between adjacent points is greater than the breakage threshold, the trajectories are divided into independent voyages.
[0012] For independent voyages, equal-interval resampling is performed using a fixed time window, including smoothing the latitude, longitude, and ground speed using cubic spline interpolation.
[0013] Convert the heading to radians, calculate the sine and cosine components, perform linear interpolation, and then back-calculate the angle to complete the circular interpolation.
[0014] If the average ground speed of an independent voyage is less than the static speed threshold, the voyage is determined to be a stationary or berthing trajectory and is removed, thus obtaining the effective motion trajectory sequence.
[0015] S2 includes S2.1, spatiotemporal feature engineering transformation including spatial gridding mapping, temporal context feature extraction, and dynamic kinematic feature processing;
[0016] Spatial gridding mapping involves discretizing continuous latitude and longitude coordinates into spatial grid IDs according to a set grid granularity, denoted as... ;
[0017] Temporal context feature extraction involves decomposing timestamps into time slots. Characteristics of the week ;
[0018] Dynamic kinematics feature processing involves normalizing the ground speed by dividing it by a reference value to obtain the normalized speed. The heading relative to the ground is converted into a sinusoidal component. Sum and cosine components .
[0019] S2 includes S2.2, and sample construction includes using the sliding window method to truncate samples of length [missing information]. The effective motion trajectory sequence is used as the input feature. Includes each time step of , , , , and The target sample for prediction is set as the relative latitude and longitude offset at the next time step. , , For latitude variation, This refers to changes in longitude.
[0020] S3 includes an end-to-end ship trajectory prediction framework that combines a multi-head key-value pair dynamic memory network and a long short-term memory network, comprising a temporal feature construction module, an interaction and feature addressing layer, and a temporal modeling and output layer.
[0021] The temporal feature building module includes a parallel spatial embedding layer, a linear projection layer, an embedding layer, and a ReLU function layer;
[0022] The interaction and feature addressing layer includes a parallel splicing layer and modulation layer, a multi-head memory dynamic addressing mechanism layer, and a difference fusion layer;
[0023] The temporal modeling and output layers consist of a long short-term memory network, a temporal attention mechanism layer, and a fully connected regression layer.
[0024] Will Input spatial embedding layer to obtain spatial features :
[0025] ;
[0026] In the formula, For spatial embedding layer, for Moment ;
[0027] Will , and Input a linear projection layer to obtain dynamic features :
[0028] ;
[0029] In the formula, For learnable weight matrix, for Moment , for Moment , Moment ;
[0030] Will and By concatenating the features, we obtain the joint input features of the current instantaneous state. :
[0031] ;
[0032] Will and Input the embedding layer and the ReLU function layer to obtain the temporal context. :
[0033] ;
[0034] In the formula, For learnable weight matrix, For activation function, and For embedding layer, For splicing operations, for Moment , for Moment , for Moment .
[0035] Will and By concatenating the vectors, we obtain the joint query vector. :
[0036] ;
[0037] In the formula, The weight matrix is a learnable weight matrix;
[0038] Initialize the learnable memo matrix and memory matrix , , , For the number of memory slots, As the feature dimension, and , Modulation is performed to obtain dynamic key-value pairs. , :
[0039] ;
[0040] ;
[0041] In the formula, For modulation symbols, for Moment , for Moment .
[0042] The multi-head memory dynamic addressing mechanism layer introduces a multi-head attention mechanism for weighted summation addressing. , and Cut into In each subspace, the similarity score between the query vector and the dynamic key matrix is calculated, and the dynamic value matrix is weighted and summed. The formula for calculating a single head is:
[0043] ;
[0044] In the formula, for The memory output vector obtained after addressing at each time step. for Activation function Let be the dimension of the key vector. It is the transpose symbol;
[0045] Processing results and Perform residual fusion to obtain the residual fusion result. :
[0046] ;
[0047] In the formula, and is a trainable weight matrix.
[0048] Constructing enhanced feature sequences , ,Will Input a Long Short-Term Memory (LSTM) network and output the hidden state at each time step. :
[0049] ;
[0050] In the formula, It is a long short-term memory network;
[0051] Will The input temporal attention mechanism layer introduces a temporal attention mechanism, calculating the attention weights for each time step through a two-layer fully connected network.
[0052] ;
[0053] In the formula, This represents the weight vector of the second fully connected layer. The hyperbolic tangent activation function is used. This represents the weight vector of the first fully connected layer of the network.
[0054] based on ,right Perform a weighted summation to obtain the final context representation vector. :
[0055] .
[0056] The fully connected regression layer outputs the predicted latitude and longitude offset of the ship at the next time step:
[0057] ;
[0058] In the formula, This represents the relative latitude offset predicted by the model. This represents the relative longitude offset predicted by the model. This is the weight matrix of the fully connected regression layer. This represents the bias vector of the fully connected regression layer.
[0059] Calculate the predicted absolute coordinates based on the current actual coordinates:
[0060] ;
[0061] In the formula, The absolute value of the latitude at the predicted next moment. The absolute value of the longitude at the next predicted moment. The actual latitude at the current moment. This represents the actual longitude at the current moment.
[0062] Compared with existing technologies, this invention has the following advantages: Based on a deep fusion mechanism guided by temporal context, a fine-grained dynamic addressing method for typical navigation patterns based on implicit memory matrix, and a multi-head attention parallel feature retrieval mechanism under multiple semantic subspaces, this invention, together with MHKV-DPM and LSTM, constructs an end-to-end temporal prediction architecture. This achieves deep representation and improved generalization performance of complex spatiotemporal coupling relationships, and obtains high-precision prediction capability for complex local maneuvering behavior of ships. This enables the model to overcome the limitations of single-dimensional addressing, complete unbiased and accurate retrieval of multi-dimensional heterogeneous features, and effectively reduce the error accumulation rate, thereby significantly improving the numerical stability of ship trajectory prediction. This provides high-precision and high-stability data support for downstream tasks such as intelligent ship navigation, maritime abnormal behavior monitoring, and collision warning. Attached Figure Description
[0063] Figure 1 This is an end-to-end ship trajectory prediction framework architecture diagram that combines a multi-head key-value pair dynamic memory network and a long short-term memory network.
[0064] Figure 2 This is a radar chart of the mean absolute error (MAE) and root mean square error (RMSE) of each model in the embodiments of the present invention;
[0065] Figure 3 This is a bar chart of the average distance error (ADE) of each model in the embodiments of the present invention. Detailed Implementation
[0066] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention are described clearly and completely below. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0067] Ship trajectory prediction methods based on multi-head key-value pair dynamic memory networks include:
[0068] S1. Obtain ship trajectory data from the Automatic Identification System (AIS), preprocess the trajectory data, and obtain a valid motion trajectory sequence;
[0069] S2. Perform spatiotemporal feature engineering transformation and sample construction on the effective motion trajectory to generate input feature sequence and prediction target sample;
[0070] S3. Construct an end-to-end ship trajectory prediction framework that combines a multi-head key-value pair dynamic memory network and a long short-term memory network. Based on the input feature sequence, train the neural network. After training, output the predicted latitude and longitude relative offset of the ship in the next time step, and calculate the predicted absolute coordinates by combining the current real coordinates.
[0071] S1 includes the following preprocessing steps: setting the latitude and longitude boundaries of the target sea area, deleting outbound data, and grouping data according to the ship's maritime mobile communication service identification code.
[0072] Set a trajectory threshold to delete ship trajectories with fewer than the trajectory threshold. Set a breakage threshold to sort the same ship trajectory points by timestamp. If the time interval between adjacent points is greater than the breakage threshold, the trajectories are divided into independent voyages.
[0073] For independent voyages, equal-interval resampling is performed using a fixed time window, including smoothing the latitude, longitude, and ground speed using cubic spline interpolation.
[0074] Convert the heading to radians, calculate the sine and cosine components, perform linear interpolation, and then back-calculate the angle to complete the circular interpolation.
[0075] If the average ground speed of an independent voyage is less than the static speed threshold, the voyage is determined to be a stationary or berthing trajectory and is removed, thus obtaining the effective motion trajectory sequence.
[0076] S2 includes S2.1, spatiotemporal feature engineering transformation including spatial gridding mapping, temporal context feature extraction, and dynamic kinematic feature processing;
[0077] Spatial gridding mapping involves discretizing continuous latitude and longitude coordinates into spatial grid IDs according to a set grid granularity, denoted as... ;
[0078] Temporal context feature extraction involves decomposing timestamps into time slots. Characteristics of the week ;
[0079] Dynamic kinematics feature processing involves normalizing the ground speed by dividing it by a reference value to obtain the normalized speed. The heading relative to the ground is converted into a sinusoidal component. Sum and cosine components .
[0080] S2 includes S2.2, and sample construction includes using the sliding window method to truncate samples of length [missing information]. The effective motion trajectory sequence is used as the input feature. Includes each time step of , , , , and The target sample for prediction is set as the relative latitude and longitude offset at the next time step. , , For latitude variation, This refers to changes in longitude.
[0081] S3 includes an end-to-end ship trajectory prediction framework that combines a multi-head key-value pair dynamic memory network and a long short-term memory network, comprising a temporal feature construction module, an interaction and feature addressing layer, and a temporal modeling and output layer.
[0082] The temporal feature building module includes a parallel spatial embedding layer, a linear projection layer, an embedding layer, and a ReLU function layer;
[0083] The interaction and feature addressing layer includes a parallel splicing layer and modulation layer, a multi-head memory dynamic addressing mechanism layer, and a difference fusion layer;
[0084] The temporal modeling and output layers consist of a long short-term memory network, a temporal attention mechanism layer, and a fully connected regression layer.
[0085] Will Input spatial embedding layer to obtain spatial features :
[0086] ;
[0087] In the formula, For spatial embedding layer, for Moment ;
[0088] Will , and Input a linear projection layer to obtain dynamic features :
[0089] ;
[0090] In the formula, For learnable weight matrix, for Moment , for Moment , Moment ;
[0091] Will and By concatenating the features, we obtain the joint input features of the current instantaneous state. :
[0092] ;
[0093] Will and Input the embedding layer and the ReLU function layer to obtain the temporal context. :
[0094] ;
[0095] In the formula, For learnable weight matrix, For activation function, and For embedding layer, For splicing operations, for Moment , for Moment , for Moment .
[0096] Will and By concatenating the vectors, we obtain the joint query vector. :
[0097] ;
[0098] In the formula, The weight matrix is a learnable weight matrix;
[0099] Initialize the learnable memo matrix and memory matrix , , , For the number of memory slots, As the feature dimension, and , Modulation is performed to obtain dynamic key-value pairs. , :
[0100] ;
[0101] ;
[0102] In the formula, For modulation symbols, for Moment , for Moment .
[0103] The multi-head memory dynamic addressing mechanism layer introduces a multi-head attention mechanism for weighted summation addressing. , and Cut into In each subspace, the similarity score between the query vector and the dynamic key matrix is calculated, and the dynamic value matrix is weighted and summed. The formula for calculating a single head is:
[0104] ;
[0105] In the formula, for The memory output vector obtained after addressing at each time step. for Activation function Let be the dimension of the key vector. It is the transpose symbol;
[0106] Processing results and Perform residual fusion to obtain the residual fusion result. :
[0107] ;
[0108] In the formula, and is a trainable weight matrix.
[0109] Constructing enhanced feature sequences , ,Will Input a Long Short-Term Memory (LSTM) network and output the hidden state at each time step. :
[0110] ;
[0111] In the formula, It is a long short-term memory network;
[0112] Will The input temporal attention mechanism layer introduces a temporal attention mechanism, calculating the attention weights for each time step through a two-layer fully connected network.
[0113] ;
[0114] In the formula, This represents the weight vector of the second fully connected layer. The hyperbolic tangent activation function is used. This represents the weight vector of the first fully connected layer of the network.
[0115] based on ,right Perform a weighted summation to obtain the final context representation vector. :
[0116] .
[0117] The fully connected regression layer outputs the predicted latitude and longitude offset of the ship at the next time step:
[0118] ;
[0119] In the formula, This represents the relative latitude offset predicted by the model. This represents the relative longitude offset predicted by the model. This is the weight matrix of the fully connected regression layer. This represents the bias vector of the fully connected regression layer.
[0120] Calculate the predicted absolute coordinates based on the current actual coordinates:
[0121] ;
[0122] In the formula, The absolute value of the latitude at the predicted next moment. The absolute value of the longitude at the next predicted moment. The actual latitude at the current moment. This represents the actual longitude at the current moment.
[0123] The following description, in conjunction with the accompanying drawings and embodiments, further illustrates the technical process of this invention. Figure 1 As shown, the end-to-end ship trajectory prediction framework of this invention, which combines a multi-head key-value pair dynamic memory network and a long short-term memory network, includes a temporal feature construction module, an interaction and feature addressing layer, and a temporal modeling and output layer. The temporal feature construction module includes a parallel spatial embedding layer, a linear projection layer, an embedding layer, and a ReLU function layer (Embedding+ReLU). The interaction and feature addressing layer includes a parallel splicing layer and modulation layer, a multi-head key-value pair dynamic addressing mechanism layer (MHKV-DPM), and a difference / residual fusion layer. The temporal modeling and output layer sequentially includes a long short-term memory network (LSTM), a temporal attention mechanism layer, and a fully connected regression layer. Input spatial embedding layer to obtain spatial features ,Will , and Input a linear projection layer to obtain dynamic features ,Will and Input the embedding layer and the ReLU function layer to obtain the temporal context. .Will and By concatenating the vectors, we obtain the joint query vector. Joint input features with the current instantaneous state Initialize the learnable memory key matrix and memory matrix ,Will and , Modulation is performed to obtain dynamic key-value pairs. , The multi-head memory dynamic addressing mechanism layer introduces a multi-head attention mechanism for weighted summation addressing, which will... , and Cut into In each subspace, the similarity score between the query vector and the dynamic key matrix is calculated, and the dynamic value matrix is weighted and summed. The result is compared with... Perform residual fusion to obtain the residual fusion result. .Will The inputs are sequentially processed by a Long Short-Term Memory (LSTM) network, a temporal attention mechanism layer, and a fully connected regression layer, and the output is the relative latitude and longitude offset. and .
[0124] Obtain raw trajectory data from the Automatic Identification System (AIS). First, define the latitude and longitude spatial boundaries of the target sea area, filter invalid data, and group data according to MMSI. Second, remove trajectories with fewer than 20 points (set a trajectory threshold of 20), sort by timestamp, and determine trajectories with time intervals greater than 30 minutes as broken trajectories and divide them into independent voyages. Resample valid voyages at 3-minute intervals (set a fixed time window of 3 minutes): latitude (LAT), longitude (LON), and speed on ground (SOG) are filled using cubic spline interpolation; the heading on ground (COG) is converted to sine and cosine components, linearly interpolated, and then recalculated back to the angle using a circular interpolation method. Finally, remove trajectories with an average speed less than 1.0 knots (set a stationary speed threshold of 1 knot), retaining valid motion sequences. During the feature engineering transformation process, the grid division granularity is set to 0.01 degrees, the baseline value of ground speed is 30 knots, the timestamp is decomposed into fine-grained time features, including time), the 24 hours of a day are divided into 96 slots (0-95) at fixed intervals (e.g., 15 minutes), and the week feature, representing the day of the week (0-6).
[0125] Several mainstream and advanced baseline models were selected for comparison, including traditional temporal prediction models (Long Short-Term Memory Network LSTM, Gate Recurrent Unit Network GRU, Bi-Long Short-Term Memory Network Bi-LSTM), classic ensemble networks (Convolutional Long Short-Term Memory Network CNN-LSTM), recently proposed complex trajectory prediction models (Switched Input Long Short-Term Memory Network SI-LSTM, Dual Attention Graph Neural Network DAG-Net), and the ablation model of this invention (DPM-LSTM, i.e., the base memory network without the multi-head attention addressing mechanism). The evaluation metrics selected for the experiments were Mean Absolute Error (MAE) and Root Mean Square Error (RMSE), both in degrees; and Average Distance Error (ADE), in meters.
[0126] Combination Figure 2 and Figure 3 The experimental results comparison chart shows that the method of this invention achieves the lowest error level in prediction results (MAE: 0.000362, RMSE: 0.000858). Compared with traditional basic sequence models such as LSTM (MAE: 0.00049, RMSE: 0.001037) and GRU (MAE: 0.00053, RMSE: 0.001121), the error of this invention is significantly reduced; at the same time, it is also significantly better than complex network structures such as CNN-LSTM and DAG-Net (MAE: 0.000519, RMSE: 0.001319). This proves that traditional models, due to their shallow feature fusion dimension, are unable to capture high-order nonlinear spatiotemporal coupling relationships, while the end-to-end framework constructed by this invention can more accurately analyze the complex motion laws of ships.
[0127] A comparison with the ablation model DPM-LSTM (MAE: 0.000382, RMSE: 0.000868) reveals that the complete model of this invention achieves further reductions in various error metrics. This fully demonstrates the crucial role played by the "multi-head key-value pair" mechanism introduced in the feature fusion layer of this invention: by dividing multi-dimensional heterogeneous features into multiple independent semantic subspaces for parallel computation and addressing, it effectively avoids the defect of the matching process being dominated by a single strong feature (such as position coordinates), thereby comprehensively evaluating the fit between instantaneous states and typical navigation patterns in multiple dimensions, and significantly enhancing the representation ability of complex maneuvers such as large-angle turns and speed changes.
[0128] The root mean square error (RMSE) is more sensitive to large biases or extreme errors. Experimental results show that the RMSE performance of this invention (0.000858) is significantly lower than that of comparative models such as SI-LSTM (0.001345). This indicates that the strategy of "pre-feature characterization to filter spatial noise + post-LSTM to capture temporal dependencies" adopted in this invention, combined with the output mechanism of predicting "relative offsets" rather than "absolute coordinates," greatly alleviates the problem of spatial error accumulation in long-sequence prediction, enabling the model to exhibit extremely high numerical stability and robustness when facing complex marine environments.
[0129] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A ship trajectory prediction method based on a multi-head key-value pair dynamic memory network, characterized in that, include: S1. Obtain ship trajectory data from the Automatic Identification System (AIS), preprocess the trajectory data, and obtain a valid motion trajectory sequence; S2. Perform spatiotemporal feature engineering transformation and sample construction on the effective motion trajectory to generate input feature sequence and prediction target sample; S3. Construct an end-to-end ship trajectory prediction framework that combines a multi-head key-value pair dynamic memory network and a long short-term memory network. Based on the input feature sequence, train the neural network. After training, output the predicted latitude and longitude relative offset of the ship in the next time step, and calculate the predicted absolute coordinates by combining the current real coordinates. S2 includes S2.1, spatiotemporal feature engineering transformation including spatial gridding mapping, temporal context feature extraction, and dynamic kinematic feature processing; Spatial gridding mapping involves discretizing continuous latitude and longitude coordinates into spatial grid IDs according to a set grid granularity, denoted as... ; Temporal context feature extraction involves decomposing timestamps into time slots. Characteristics of the week ; Dynamic kinematics feature processing involves normalizing the ground speed by dividing it by a reference value to obtain the normalized speed. The heading relative to the ground is converted into a sinusoidal component. Sum and cosine components ; S2 This includes S2.2, sample construction, which involves using a sliding window method to truncate samples of length [length missing]. The effective motion trajectory sequence is used as the input feature. Includes each time step of , , , , and The target sample for prediction is set as the relative latitude and longitude offset at the next time step. , , For latitude variation, For changes in longitude; S3 includes an end-to-end ship trajectory prediction framework that combines a multi-head key-value pair dynamic memory network and a long short-term memory network, comprising a temporal feature construction module, an interaction and feature addressing layer, and a temporal modeling and output layer. The temporal feature building module includes a parallel spatial embedding layer, a linear projection layer, an embedding layer, and a ReLU function layer; The interaction and feature addressing layer includes a parallel splicing layer and modulation layer, a multi-head memory dynamic addressing mechanism layer, and a difference fusion layer; The temporal modeling and output layers consist of a long short-term memory network, a temporal attention mechanism layer, and a fully connected regression layer.
2. The ship trajectory prediction method based on a multi-head key-value pair dynamic memory network according to claim 1, characterized in that, S1 includes the following preprocessing steps: setting the latitude and longitude boundaries of the target sea area, deleting outbound data, and grouping data according to the ship's maritime mobile communication service identification code. Set a trajectory threshold to delete ship trajectories with fewer than the trajectory threshold. Set a breakage threshold to sort the same ship trajectory points by timestamp. If the time interval between adjacent points is greater than the breakage threshold, the trajectories are divided into independent voyages. For independent voyages, equal-interval resampling is performed using a fixed time window, including smoothing the latitude, longitude, and ground speed using cubic spline interpolation. Convert the heading to radians, calculate the sine and cosine components, perform linear interpolation, and then back-calculate the angle to complete the circular interpolation. If the average ground speed of an independent voyage is less than the static speed threshold, the voyage is determined to be a stationary or berthing trajectory and is removed, thus obtaining the effective motion trajectory sequence.
3. The ship trajectory prediction method based on a multi-head key-value pair dynamic memory network according to claim 2, characterized in that, Will Input spatial embedding layer to obtain spatial features : ; In the formula, For spatial embedding layer, for Moment ; Will , and Input a linear projection layer to obtain dynamic features : ; In the formula, For learnable weight matrix, for Moment , for Moment , Moment ; Will and By concatenating the features, we obtain the joint input features of the current instantaneous state. : ; Will and Input the embedding layer and the ReLU function layer to obtain the temporal context. : ; In the formula, For learnable weight matrix, For activation function, and For embedding layer, For splicing operations, for Moment , for Moment , for Moment .
4. The ship trajectory prediction method based on a multi-head key-value pair dynamic memory network according to claim 3, characterized in that, Will and By concatenating the vectors, we obtain the joint query vector. : ; In the formula, The weight matrix is a learnable weight matrix; Initialize the learnable memo matrix and memory matrix , , , For the number of memory slots, As the feature dimension, and , Modulation is performed to obtain dynamic key-value pairs. , : ; ; In the formula, For modulation symbols, for Moment , for Moment .
5. The ship trajectory prediction method based on a multi-head key-value pair dynamic memory network according to claim 4, characterized in that, The multi-head memory dynamic addressing mechanism layer introduces a multi-head attention mechanism for weighted summation addressing. , and Cut into In each subspace, the similarity score between the query vector and the dynamic key matrix is calculated, and the dynamic value matrix is weighted and summed. The formula for calculating a single head is: ; In the formula, for The memory output vector obtained after addressing at each time step. for Activation function Let be the dimension of the key vector. It is the transpose symbol; Processing results and Perform residual fusion to obtain the residual fusion result. : ; In the formula, and is a trainable weight matrix.
6. The ship trajectory prediction method based on a multi-head key-value pair dynamic memory network according to claim 5, characterized in that, Constructing enhanced feature sequences , ,Will Input a Long Short-Term Memory (LSTM) network and output the hidden state at each time step. : ; In the formula, It is a long short-term memory network; Will The input temporal attention mechanism layer introduces a temporal attention mechanism, calculating the attention weights for each time step through a two-layer fully connected network. ; In the formula, This represents the weight vector of the second fully connected layer. The hyperbolic tangent activation function is used. This represents the weight vector of the first fully connected layer of the network. based on ,right Perform a weighted summation to obtain the final context representation vector. : 。 7. The ship trajectory prediction method based on a multi-head key-value pair dynamic memory network according to claim 6, characterized in that, The fully connected regression layer outputs the predicted latitude and longitude offset of the ship at the next time step: ; In the formula, This represents the relative latitude offset predicted by the model. This represents the relative longitude offset predicted by the model. This is the weight matrix of the fully connected regression layer. This represents the bias vector of the fully connected regression layer. Calculate the predicted absolute coordinates based on the current actual coordinates: ; In the formula, The absolute value of the latitude at the predicted next moment. The absolute value of the longitude at the next predicted moment. The actual latitude at the current moment. This represents the actual longitude at the current moment.