An improved generative seq2seq ship trajectory prediction method
By improving the generative seq2seq method and combining the attention mechanism and fast search clustering algorithm, the temporal and spatial features of ship trajectories are extracted, solving the long dependency and gradient problems in the existing technology and achieving higher accuracy in ship trajectory prediction.
Patent Information
- Application Number
- CN202410561066.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-08
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2044-05-08
AI Technical Summary
Existing ship trajectory prediction systems cannot effectively solve the problem of long dependencies in sequence data, suffer from gradient vanishing and gradient exploding problems, and fail to explicitly extract the temporal and spatial features in the trajectory data, resulting in insufficient prediction accuracy.
An improved generative seq2seq method is adopted, which combines attention mechanism, hierarchical temporal embedding and fast search clustering algorithm to extract the temporal and spatial features of the trajectory. Multi-head self-attention mechanism is used for parallel training to build a generative sequence-to-sequence model to capture long-term dependencies.
This improves the accuracy of ship trajectory prediction. By extracting the temporal and spatial features of the trajectory, the model can better learn the ship's maritime motion patterns, thus enhancing the accuracy of the prediction results.
Smart Images

Figure CN118504741B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of ship trajectory prediction technology, specifically to an improved generative seq2seq ship trajectory prediction method. Background Technology
[0002] With economic globalization, the safety of ship navigation has received increasing attention, especially in the field of ship collision avoidance. Ship collisions can lead to numerous casualties and huge property losses. In addition, if the cargo carried by the colliding ships is petroleum or other chemicals, it may also pollute the marine environment and damage the marine ecosystem.
[0003] Against this backdrop, maritime surveillance and maritime situational awareness have become popular research areas, and one of the key challenges in this field is ship trajectory prediction. How to use a ship's known trajectory to predict its trajectory over the next few hours, thereby providing technical support for applications such as maritime search and rescue, traffic control, route planning, and pollution monitoring, is a crucial issue in ship trajectory prediction.
[0004] Therefore, this method aims to predict ship trajectories using deep learning models, planning a safe, economical, and collision-free route for ships, enabling them to navigate safely in increasingly congested seas.
[0005] Current ship trajectory prediction systems often employ recurrent neural networks (RNNs) or long short-term memory networks (LSTMs) for prediction, but these systems suffer from several limitations, such as the inability to handle long dependencies in sequential data, the inability to train in parallel, and the problems of vanishing and exploding gradients. While LSTMs can address the vanishing gradient problem, and gradient truncation can mitigate the exploding gradient problem, long dependencies and parallel training remain unresolved. Furthermore, ship trajectory data is spatiotemporal sequential data, possessing not only time-series characteristics but also spatial features. Currently, few methods explicitly extract the temporal and spatial features from trajectory data to aid model training. Summary of the Invention
[0006] This invention addresses the shortcomings of existing technologies by proposing an improved generative seq2seq ship trajectory prediction method. This method leverages attention mechanisms for parallel training and better captures the long-term dependencies in trajectory data. By extracting the temporal and spatial features of the trajectory, the model can better learn the ship's maritime motion patterns.
[0007] To solve the above-mentioned technical problems, the technical solution of the present invention is as follows:
[0008] An improved generative seq2seq ship trajectory prediction method includes the following steps:
[0009] Step 1: Collect historical ship positioning data, process the scattered ship positioning information into trajectory data with fixed length and consistent time intervals, and then divide the dataset into training set and test set;
[0010] Step 2: Divide the trajectory data in the training set into fixed-size batches and initialize the model parameters with a normal distribution.
[0011] Step 3: Read a batch of data and discretize it, transforming the regression problem into a classification problem. Feed the data into the model's embedding layer, where the neural network learns the motion features of the trajectory. This facilitates model training.
[0012] Step 4: Use a hierarchical temporal embedding method to extract the timestamps of the trajectory as temporal features, and add and fuse the temporal feature matrix and the motion feature matrix of the trajectory, which is beneficial for model training;
[0013] Step 5: Use a clustering algorithm that quickly searches for and finds density peaks to cluster the latitude and longitude vectors of the trajectory, extract the spatial features of the trajectory, and add and fuse the spatial features of the trajectory with the results of Step 4, which is beneficial for model training.
[0014] Step 6: Construct a generative sequence-to-sequence model. Input the fusion result obtained in Step 5 into the generative sequence-to-sequence model for model training. The generative sequence-to-sequence model includes a multi-head self-attention mechanism multilayer perceptron. The multi-head self-attention mechanism multilayer perceptrons are connected through residual connections and normalization connections. The output of the multilayer perceptron is output as a prediction result through residual connections and normalization. It can capture the long-term dependence of the trajectory. Moreover, the multi-head self-attention mechanism supports parallel computing, which can speed up the training process.
[0015] Step 7: Replace the training set data in Step 2 with the test set data, repeat Steps 2 to 5, and input the result obtained in Step 5 into the generative sequence trained in Step 6 into the sequence model to obtain the final trajectory prediction result.
[0016] Preferably, in step 1, a trispline interpolation algorithm is used to reconstruct trajectory sequences with inconsistent time intervals, and a sliding window is used to process trajectories of different lengths into trajectories of uniform length.
[0017] Preferably, in step 6, the training method for the generative sequence to sequence model is as follows: taking steps 3 to 6 as one cycle, the iteration cycle from step 3 to step 6 is repeated periodically until the number of iteration cycles is initialized.
[0018] Preferably, in step 6, when training the generative sequence to the sequence model, the loss function used is the cross-entropy loss function, the expression of which is as follows:
[0019]
[0020] Where n represents the number of samples, and in this paper, it represents the number of trajectories in a batch. m represents the number of categories, y ij Let a represent the true probability. ij This indicates the probability of the prediction.
[0021] In the above technical solution, based on the attention mechanism, a hierarchical temporal embedding method is proposed to capture the long-term dependencies and temporal patterns in ship trajectory data. This invention uses four layers of timestamps: Minute of hour, hour of day, day of week, and day of month. To capture the spatial features in ship trajectory data, a clustering algorithm based on fast search and finding density peaks (DPC) is proposed. This unsupervised spatial clustering algorithm is used to extract the spatial features of the trajectory, aiding in model training.
[0022] Compared to traditional ship trajectory prediction methods, this approach leverages attention mechanisms for parallel training and better captures the long-term dependencies in trajectory data. By extracting the temporal and spatial features of the trajectory, the model can better learn the ship's maritime motion patterns.
[0023] This invention has the following characteristics and beneficial effects:
[0024] Effect 1: An improved generative seq2seq ship trajectory prediction method is proposed;
[0025] Effect 2: Using the sliding window method and interpolation algorithm, scattered ship positioning information with inconsistent time intervals is processed into trajectory data with consistent length and the same time interval;
[0026] Effect 3: A sequence-to-sequence model based on a multi-head self-attention mechanism was used to predict the trajectory, and the trajectory data was discretized to enable the model to better learn the motion features of the trajectory.
[0027] Effect 4: Integrating the temporal and spatial features of the trajectory into the model enables the model to better learn the motion characteristics of the trajectory;
[0028] Effect 5: Judging from the average prediction error and final prediction error in the trajectory prediction results, the accuracy of trajectory prediction has been improved. Attached Figure Description
[0029] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0030] Figure 1 This is a system architecture diagram based on an improved generative seq2seq ship trajectory prediction method.
[0031] Figure 2 This is the overall flowchart for trajectory data preprocessing.
[0032] Figure 3 This is a flowchart of the trajectory reconstruction method with equal time intervals.
[0033] Figure 4 This is a structural diagram of the time feature extraction method.
[0034] Figure 5 This is a structural diagram of spatial feature extraction methods. Detailed Implementation
[0035] It should be noted that, unless otherwise specified, the embodiments and features described in the present invention can be combined with each other.
[0036] In the description of this invention, it should be understood that the terms "center," "longitudinal," "lateral," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," and "outer," etc., indicating orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the invention. Furthermore, the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined with "first," "second," etc., may explicitly or implicitly include one or more of that feature. In the description of this invention, unless otherwise stated, "a plurality of" means two or more.
[0037] In the description of this invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art will understand the specific meaning of the above terms in this invention based on the specific circumstances.
[0038] Please refer to the following case study. Figure 1 , Figure 1 The architecture of the proposed improved generative seq2seq ship trajectory prediction method is presented. The following examples further illustrate the invention in detail, with specific implementation steps outlined below.
[0039] Step 1. Collect ship location reports from various devices (Automatic Identification System (AIS), satellites, etc.), select the fields used for model training from the location reports, and organize this information into trajectory data according to ship and time sequence. The overall flowchart for trajectory data preprocessing is as follows: Figure 2 As shown in Table 1, which is a diagram illustrating the fields required for model training.
[0040] Table 1
[0041] name type scope unit Remark LAT floating-point numbers 55.5~58.0 Spend Longitude of the ship LON floating-point numbers 10.3~13 Spend Latitude of the ship SOG floating-point numbers 0~30 Festival Ship's speed above ground COG floating-point numbers 0~360 Spend ship's heading to ground TIME date none none AIS observation reporting time
[0042] Step 2. Due to AIS equipment malfunction or interference from environmental factors affecting the AIS data transmission medium, the frequency at which AIS equipment sends AIS data is inconsistent. Sometimes it sends data every few minutes, and sometimes it sends data every few hours. This situation will cause the time interval between different AIS observations in the AIS trajectory to be different. This inconsistency prevents the model from accurately predicting future trajectories, because it cannot determine the time of the predicted AIS observation, which is equivalent to being unable to accurately predict future trajectories.
[0043] To address this problem, an intuitive approach is to convert trajectories with inconsistent time intervals into trajectories with equal time intervals. This invention employs a trispline interpolation algorithm to solve this problem. The flowchart of the equal time interval trajectory reconstruction method is shown below. Figure 3 As shown. The definition of the trispline interpolation algorithm is as follows: Let y = f(x) be at points x0, x1, x2, ..., xn. n The values are y0, y1, y2, ..., y n If the function S(x) satisfies the following conditions:
[0044] 1)S(x i )=f(x i )=y ii = 0, 1, 2, ..., n
[0045] 2) In each subinterval [x i x i+1 S(x) is a cubic polynomial over the interval (i = 0, 1, 2, ..., n-1).
[0046] 3) S(x) is twice continuously differentiable on [a, b].
[0047] The s(x) function that meets the above three conditions is a cubic spline interpolation function of the function f(x).
[0048] In this invention, the longitude of the trajectory point is x, and the latitude of the trajectory point is y. The trajectory is reconstructed using this algorithm, and finally the reconstructed trajectory is sampled at equal time intervals.
[0049] Step 3. To facilitate model training and augmentation of trajectory data, a sliding window method will be used to divide the trajectory data of varying lengths. The divided data will have the same trajectory length and a greater number of trajectories, which is beneficial for model training.
[0050] Step 4. Divide the preprocessed trajectory data into training and test sets. Read the trajectory data from the training set and divide it into fixed-size batches. Initialize the model parameters using a normal distribution.
[0051] Step 5. The model reads a batch of data and discretizes it, transforming the regression problem into a classification problem. The data is then fed into the model's embedding layer, where the neural network learns the motion features of the trajectory.
[0052] Step 6. Use a hierarchical temporal embedding method to extract the timestamps of the trajectory as temporal features. Add and fuse the temporal feature matrix with the result of Step 5. The structure diagram of the temporal feature extraction method is shown below. Figure 4 As shown.
[0053] In this embodiment, the timestamp of the trajectory uses a four-layer timestamp, namely Minute of hour, Hour of day, Day of week, and Day of month.
[0054] Step 7. Use a clustering algorithm that quickly searches for and finds density peaks to cluster the latitude and longitude vectors of the trajectory, extract the spatial features of the trajectory, and add and fuse the spatial features with the results of Step 6. The structure diagram of the spatial feature extraction method is shown below. Figure 5 As shown.
[0055] Step 8. Input the result of step 7 into the generative sequence to sequence model composed of multi-head self-attention mechanism and multilayer perceptron for model training. The self-attention function is shown in equation (1).
[0056]
[0057] Here, Q, K, and V are three input matrices. The essence of this formula is to use the dot product to calculate the similarity between points in the sequence; a higher similarity indicates a greater dependency. By using the dot product, the problem of RNNs failing to capture long-term dependencies in sequences is solved.
[0058] To improve the effectiveness of the attention mechanism, a multi-head attention mechanism was used. Multi-head attention allows the model to jointly pay attention to local information from different locations. Multi-head attention essentially involves dividing the matrix into n equal parts by columns. Then, each head calculates separately according to formula (1), and finally, all heads are merged back into a single matrix. The formula is shown in formula (2):
[0059] MultiHead(Q,K,V)=Concat(head1,...,head h W o (2)
[0060] in, W is a parameter matrix.
[0061] The multilayer perceptron function MLP is shown in equation (3).
[0062] MLP(x)=Dropout(GELU(Linear(x, W1, b1)·W2+b2)) (3)
[0063] Where x is the input vector, W is the weight matrix, b is the bias, Linear is the linear layer, GELU is the activation function, and Dropout is the random deactivation function.
[0064] Step 9. Repeat steps 5 to 8 periodically until the initial set number of iterations is reached. The training of this method ends. After each epoch, the loss function is used to calculate the loss between the predicted and actual results. The loss function used in this invention is the cross-entropy loss function, as shown in equation (4):
[0065]
[0066] Where n represents the number of samples, and in this paper, it represents the number of trajectories in a batch. m represents the number of categories, y ij Let a represent the true probability. ij This indicates the probability of the prediction.
[0067] Step 10. Replace the training set data from Step 4 with the test set data, and repeat Steps 4 through 9 to obtain the final trajectory prediction result. In real-world scenarios, ships continuously generate location information. The location information from the same ship is preprocessed to generate trajectory data with equal time intervals. Inputting this trajectory data into the trained model will generate the ship's predicted trajectory.
[0068] To compare the prediction accuracy of different models, this paper uses mean square error (MSE), mean absolute error (MAE), root mean square error (RMSE), average displacement error (ADE), and final displacement error (FDE) to objectively measure the difference between the model prediction results and the true values. The formula for calculating MSE is shown in equation (5), which is an indicator that measures the deviation between the model prediction value and the true value. The formula for calculating RMSE is shown in equation (6), and its function is roughly the same as MSE, calculated by taking the square root of MSE. The formula for calculating MAE is shown in equation (7), and its function is similar to MSE and RMSE, calculated using absolute values. ADE and FDE describe the distance error between the true trajectory and the predicted trajectory, in kilometers. ADE represents the average distance between all points of the predicted trajectory and the true trajectory, and FDE represents the distance between the predicted trajectory and the last point of the true trajectory. The formulas for calculating ADE and FDE are shown in equations (8) and (9), respectively. The above five indicators are essentially used to calculate the magnitude of the error between the predicted value and the true value from different perspectives, and can objectively measure the performance of the model. For all five metrics, lower values indicate higher model performance.
[0069]
[0070]
[0071]
[0072] Where y i Represents the actual value. This represents the predicted value, and N represents the number of samples.
[0073]
[0074]
[0075] In equation (8), N represents the number of samples, L represents the length of the predicted trajectory, and loc ij The coordinates (composed of latitude and longitude) of the j-th AIS observation representing the true trajectory of the i-th sample. The coordinates (composed of latitude and longitude) of the j-th AIS observation representing the predicted trajectory of the i-th sample. In equation (9), N represents the number of samples, loci The coordinates (composed of latitude and longitude) of the last AIS observation representing the true trajectory of the i-th sample. The coordinates (composed of latitude and longitude) of the last AIS observation representing the predicted trajectory of the i-th sample.
[0076] Since this article calculates the distance between two latitude and longitude coordinates, the function D(loc) i loc j ) represents the semi-sine distance between two coordinates, and its calculation formula is shown in equation (10).
[0077]
[0078] Where R is the Earth's radius. Where α1 and α2 represent loc i and loc j In the equation, latitude, β1, and β2 represent loc. i and loc j Longitude in the middle.
[0079] The embodiments of the present invention have been described in detail above with reference to the accompanying drawings, but the present invention is not limited to the described embodiments. For those skilled in the art, various changes, modifications, substitutions, and variations can be made to these embodiments, including components, without departing from the principles and spirit of the present invention, and these variations still fall within the protection scope of the present invention.
Claims
1. A ship trajectory prediction method based on an improved generative seq2seq algorithm, characterized in that, Includes the following steps: Step 1: Collect historical ship positioning data, process the scattered ship positioning data into trajectory data with fixed length and consistent time intervals, and then divide the dataset into training set and test set; Step 2: Divide the trajectory data in the training set into fixed-size batches and initialize the model parameters with a normal distribution. Step 3: Read a batch of data and discretize the data, turning the regression problem into a classification problem. Put the data into an embedding layer and learn the motion features of the trajectory through a neural network. Step 4: Use a hierarchical temporal embedding method to extract the timestamps of the trajectory as temporal features, and then add and fuse the temporal feature matrix and the motion feature matrix of the trajectory. Step 5: Use a clustering algorithm that quickly searches for and finds density peaks to cluster the latitude and longitude vectors of the trajectory, extract the spatial features of the trajectory, and add and fuse the spatial features of the trajectory with the results of Step 4. Step 6: Construct a generative sequence-to-sequence model. Input the fusion result obtained in Step 5 into the generative sequence-to-sequence model for model training. The generative sequence-to-sequence model includes a multi-head self-attention mechanism and a multilayer perceptron. The output of the multi-head self-attention mechanism is processed by residual connection and normalization and then used as the input of the multilayer perceptron. The output of the multilayer perceptron is processed by residual connection and normalization and then outputs the prediction result. The training method for the generative sequence-to-sequence model is as follows: taking steps 3 to 6 as one cycle, the steps 3 to 6 are cycled periodically until the number of iteration cycles is initialized. When training a generative sequence to a sequence model, the loss function used is the cross-entropy loss function, expressed as follows: Where n represents the number of trajectories in a batch, m represents the number of categories, and y ij Let a represent the true probability. ij Indicates the probability of a prediction; Step 7: Replace the training set data in Step 2 with the test set data, repeat Steps 2 to 5, and input the result obtained in Step 5 into the generative sequence trained in Step 6 into the sequence model to obtain the final trajectory prediction result.
2. The improved generative seq2seq ship trajectory prediction method according to claim 1, characterized in that, In step 1, the trispline interpolation algorithm is used to reconstruct the trajectory sequence with inconsistent time intervals, and the sliding window is used to process the trajectories of different lengths into trajectories of consistent length.
Citation Information
Patent Citations
Ship track prediction method and system fusing data quality control and Transform network
CN116541708A