A trajectory prediction system and method based on dictionary
By building a dictionary module and an encoder-attention-decoder architecture through clustering, it solves the problems of high computational cost and many hyperparameters of the MANTRA architecture, achieves more efficient trajectory prediction, and is suitable for complex environments and high-density traffic scenes.
Patent Information
- Application Number
- CN202311074757.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-24
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2043-08-24
AI Technical Summary
The existing MANTRA architecture has high computational costs, many hyperparameters, and is prone to overfitting in trajectory prediction. Its large memory capacity limits its application in complex environments, especially in high-density traffic scenarios where performance declines.
Use clustering to build a dictionary module, remove the memory controller, use the clustering module to select representative trajectories in advance, build a dictionary through past encoders and future encoders, and combine the encoder-attention-decoder architecture for trajectory prediction to reduce hyperparameters and memory usage.
It reduces computational costs, reduces the complexity of hyperparameter tuning and memory requirements, improves data redundancy utilization, is applicable to a wider range of data and improves prediction efficiency.
Smart Images

Figure CN117131858B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of deep learning technology, and in particular to a dictionary-based trajectory prediction system and method. Background Art
[0002] In order to ensure the safety of driving in complex environments, it has become a challenging task to understand and accurately predict the future trajectory of moving objects such as vehicles or ships. In recent years, scholars have proposed different solutions to this task, including methods based on dynamics, probability statistics, machine learning, and deep learning. Recently, deep learning technology has successfully promoted the development of artificial intelligence and has been applied to various fields. Deep learning uses artificial neural networks to extract and characterize data features. It is an abstract algorithm with complex structures. It can be regarded as a combination of multiple network layers. Each layer converts the features extracted by the previous layer into a higher and more abstract representation. Compared with dynamics, probability statistics, machine learning and other methods, it shows stronger learning ability. Among them, Seq2Seq (Sequence to sequence) model is very popular in the field of deep learning. Seq2seq is a sequence to sequence learning architecture that can achieve variable length sequence tasks through encoder-decoder. Since LSTM (Long Short-Term Memory) can effectively memorize the dependencies of long sequence data and is very suitable for processing sequence data, LSTM is often used as the building block of encoder and decoder networks in seq2seq architecture. Scholars have noticed the effectiveness and flexibility of the LSTM-based Seq2seq architecture and applied it to the trajectory prediction problem. This paper regards the trajectory prediction task as a sequence-to-sequence problem and innovates on the basis of the existing Seq2seq architecture. Therefore, the Seq2seq architecture and related research will be introduced in detail below.
[0003] The sequence-to-sequence seq2seq architecture is a neural network designed for end-to-end learning. It can receive sequences of variable length as input and generate variable-length output sequences after a series of complex mapping transformations. The input length and output length can be different. This architecture has been proven to be successful in various machine learning tasks, such as machine translation, dialogue generation, text summarization, etc.
[0004] There are two main components in a typical seq2seq framework: encoder and decoder, so the seq2seq framework is also called encoder-decoder network. Its working mechanism is as follows:
[0005] First, the encoder generates a fixed-length vector representation based on the received input sequence, also known as a context vector, which is able to capture the characteristics of the entire sequence and semantically encode the input sequence. This context vector is designed to encapsulate all the relevant information needed to generate the corresponding output sequence learned from the input sequence. The context vector is the final state of the encoder, which is then passed to the decoder. The decoder uses the encoder's context vector and a special sequence start marker as input to generate an output sequence, such as an output sentence translated from an input sentence into another language. The decoder generates output word by word, and when the decoder generates each token of the output sequence at each prediction time step, it also considers the prediction generated at the previous time step, thereby creating a feedback loop that allows it to refine its predictions based on its own previously predicted outputs.
[0006] The encoder-decoder architecture is trained end-to-end using backpropagation to minimize the difference between the predicted output sequence and the actual output sequence. During training, the decoder is trained to generate the correct next word in the output sequence given the current hidden state and the previous word generated. This process provides the decoder with a target output sequence to guide the decoder to correct the predicted results at each time step. This training strategy is also called teacher forcing; but during inference, the decoder is not provided with a target output sequence. The decoder must generate the output sequence by itself given the context vector. The decoder infers the prediction result of the current time step through the prediction of the previous time step. In this way, the decoder continues to predict each time step until a special sequence end marker is generated or the maximum length is reached.
[0007] These features of the Seq2seq architecture are implemented by RNNs, which can pass information from one time step to the next in the sequence. Specifically, the RNNs used are usually LSTM or GRU variants because they are better able to handle long-term dependencies. Therefore, the Seq2seq model consists of two RNNs, one as an encoder and the other as a decoder.
[0008] The seq2seq architecture has the following properties:
[0009] 1) The length of input and output sequences can be variable: Seq2seq models can handle variable-length input and output sequences, making them suitable for a variety of tasks in which the input and output sequences can have different lengths. Traditional NLP models, however, usually rely on fixed-length feature representations that cannot capture the sequential nature of sequences and are therefore not suitable for handling variable-length input and output sequences.
[0010] 2) There is a strict temporal logic between the input and output sequences. RNN can read the input sequence step by step, and generate the output sequence step by step based on the previous output and the current hidden state. Therefore, the seq2seq model is very suitable for tasks where the input and output sequences have a strong temporal structure.
[0011] 3) Efficient use of memory: The encoder of the Seq2seq model ultimately compresses the input sequence into a fixed-size vector. Therefore, regardless of the length of the input sequence, the size of this context vector does not change, and longer inputs do not consume additional memory.
[0012] The existing MANTRA (Memory Augmented Neural Trajectory predictor) uses a Seq2seq (Sequence to sequence) architecture with a memory augmented network to perform multimodal prediction of the target vehicle (see Marchetti, F., Becattini, F., Seidenari, L., & Bimbo, AD. (2020). Mantra: memory augmented networks for multiple trajectory prediction. arXiv.). The use of a large amount of past experience in this scheme is one of the keys to the success of the prediction task. An incremental knowledge base (also referred to as memory in the article) is established in its model. The knowledge base is built based on historical trajectory samples and is continuously updated during the training process due to the addition of new trajectories. The knowledge base stores the encoding form of past and future trajectories. When predicting a new trajectory, multiple possible future trajectories are retrieved from the knowledge base through the past trajectory encoding of the new trajectory to achieve multimodal trajectory prediction. In addition, the authors also considered semantic scene maps as additional contextual representations and used CNN (Convolutional Neural Networks) to extract its features to fine-tune the prediction results.
[0013] Since this study is multimodal prediction, the problem is defined as: given an observation trajectory x P and context representation information c, the goal is to predict the future trajectory x F The probability of the vehicle trajectory is represented by two-dimensional coordinates.
[0014] P(x F |x P ,c)(1-1)
[0015] The author uses RNN (Recurrent Neural Network) as a component of Seq2seq, and uses two encoders to encode the history and future trajectories of the sample trajectory respectively. The two codes obtained will be used for the prediction of the decoder at the same time. The entire encoding and decoding process is as follows:
[0016]
[0017]
[0018]
[0019] Assume that the current knowledge base stores |M| key-value pairs When a new trajectory When predicting, it is first encoded:
[0020]
[0021] Encoded π k As a key, it is retrieved from the knowledge base to obtain sample trajectories that are similar to it. The retrieval process is completed using cosine similarity:
[0022]
[0023] The obtained s i Represents the similarity between the i-th sample trajectory in the dictionary and the new trajectory to be predicted. Based on the similarity, the author selects the top-k most similar trajectories and uses their future trajectory parts in the knowledge base as possible future trajectories for the current predicted trajectory. In the specific implementation, the future trajectory encoding representations of these top-k trajectories are concatenated with the historical trajectory encoding representations of the predicted trajectory and then put into the decoder for prediction, thus obtaining k possible future trajectories.
[0024]
[0025] The MANTRA architecture uses a memory controller to determine the storage content of the current knowledge base. During the training process, the knowledge base will be continuously updated through the memory controller. When a new trajectory arrives, the memory controller decides whether to write the new trajectory into the knowledge base with a probability of P(w), that is, the probability of writing is P(w), and the probability of ignoring the trajectory is 1-P(w). If the current prediction accuracy is low, it means that the knowledge base lacks relevant information similar to the current trajectory and cannot provide a possible future for the current trajectory. Then, the current trajectory needs to be written to expand the knowledge base. In order to make the write probability P(w) achieve more accurate predictions, the author introduced the reconstruction error e and defined the loss function of the memory controller as follows:
[0026] L c =e·(1-P(w))+(1-e)·P(w)(1-8)
[0027] Where e∈[0,1] is the parameter to be learned by the memory controller network. Consider the boundary case: when e=0, the loss function is P(w), and the goal of network training is to minimize P(w); when e=1, the loss function is 1-P(w), and the goal of network training is to maximize P(w). By learning a more appropriate reconstruction error e, the network can bring the predicted value closer to the true value and reduce data redundancy in the knowledge base.
[0028] In addition, the MANTRA architecture uses maps as supplementary data to enable the model to adapt to the environment. CNN is a commonly used network for graph feature extraction, which can convert map features into context vectors. The obtained context vectors can be used to fine-tune the model to improve prediction accuracy.
[0029] Although the MANTRA architecture (Memory Augmented Network for Multi-Trajectory Prediction) proposes a promising framework for multi-trajectory prediction in complex outdoor environments, it also has limitations, which are as follows:
[0030] 1. The computational cost is too high: In order to build the knowledge base, an additional network is added to the MANTRA architecture: the memory controller. During the training process, the memory controller needs to be trained to ensure the real-time update of the knowledge base, which requires a large amount of computing resources. Its computing time and hardware requirements may limit its practical application in real-time scenarios.
[0031] 2. Risk of overfitting due to too many hyperparameters: The use of memory controller introduces additional hyperparameters such as memory size, memory dimension, reconstruction threshold, etc. These hyperparameters may be difficult to tune and may require expert knowledge. If not performed correctly, it may increase the risk of overfitting.
[0032] 3. Too large memory capacity: The memory module used in the model has a fixed capacity, which may limit its ability to capture long-term interactions between many agents. If the memory controller is full, it may start to overwrite old information, resulting in data loss and performance degradation. Therefore, the MANTRA architecture may not be suitable for high-density traffic scenarios.
[0033] Therefore, there is currently no solution to the above limitations in trajectory prediction. Summary of the invention
[0034] In view of this, the present invention provides a trajectory prediction system and method based on a dictionary. The present invention uses clustering to build a knowledge base in advance, and no update operation is required during the training process. The memory controller network is removed, and the computing cost is effectively reduced. Compared with the MANTRA architecture, the present invention has fewer hyperparameters, and some of the hyperparameters can be reasonably selected through existing experience. The present invention uses less memory and reduces data redundancy.
[0035] To achieve the above-mentioned purpose, the technical solution of the present invention is: a dictionary-based trajectory prediction system, including a clustering module, a dictionary module and an encoder-attention-decoder prediction architecture.
[0036] The clustering module is used to cluster the trajectory data set to select representative trajectories; the selected representative trajectories are sent to the dictionary module.
[0037] The dictionary module uses the past encoder and the future encoder to construct the dictionary; the dictionary module uses the past encoder to encode the historical trajectory part of each representative trajectory to generate the key in the dictionary; the dictionary module uses the future encoder to encode the future trajectory part of each representative trajectory to generate the value in the dictionary; the dictionary is composed of key-value pairs.
[0038] The encoder-attention-decoder prediction architecture is a sequence-to-sequence Seq2seq architecture consisting of a past encoder, a convolutional neural network CNN, and an attention mechanism decoder; the target trajectory is input into the encoder-attention-decoder prediction architecture, and the past encoder encodes the historical trajectory part of the target trajectory to obtain the observation feature encoding, which is used to query the dictionary and construct auxiliary features; the auxiliary features are fused with the observation feature encoding through the convolutional neural network CNN, and the fused features are used as the initial hidden state of the attention mechanism decoder, and the attention mechanism decoder outputs the predicted future trajectory.
[0039] Furthermore, the clustering module is used to cluster the trajectory data set to select representative trajectories; the clustering method adopted is the K-means method.
[0040] Furthermore, the observed feature encoding is used to query the dictionary and construct auxiliary features, which specifically includes two processes: query and construction:
[0041] The query process is as follows: the observed feature code of the target trajectory is multiplied by all the keys in the dictionary, and the probability is obtained through the softmax function to obtain the similarity between the target trajectory and the center of cluster i corresponding to each representative trajectory;
[0042] The construction process is: multiply each value in the dictionary by the corresponding similarity to obtain the constructed auxiliary features.
[0043] Another embodiment of the present invention further provides a dictionary-based trajectory prediction method, comprising the following steps:
[0044] Step 1: Cluster the trajectory data set to select representative trajectories;
[0045] Step 2: Use the past encoder and the future encoder to construct a dictionary, including:
[0046] Using a past encoder to encode the historical trajectory part of each representative trajectory to generate a key in a dictionary; using a future encoder to encode the future trajectory part of each representative trajectory to generate a value in the dictionary; the dictionary is composed of key-value pairs;
[0047] Step 3: Receive the input of the target trajectory, use the past encoder to encode the historical trajectory part of the target trajectory, obtain the observation feature code, use the observation feature code, query the dictionary, and construct auxiliary features; use the convolutional neural network CNN to fuse the auxiliary features with the observation feature code, and use the fused features as the initial hidden state of the attention mechanism decoder. The attention mechanism decoder outputs the predicted future trajectory.
[0048] Furthermore, clustering is performed on the trajectory data set to select representative trajectories. The specific steps are as follows:
[0049] Step 101: Use the center trajectory table to represent each cluster, first randomly select k trajectories from the trajectory data set as the center trajectory;
[0050] Step 102: For each trajectory in the trajectory data set, calculate its distance from each center trajectory and divide it into the set to which the nearest center trajectory belongs;
[0051] Repeat step 102 until all trajectories in the trajectory data set are grouped into one set, and the central trajectory of each set is recalculated; finally, a total of N clusters are obtained;
[0052] Step 104: After clustering, select representative trajectories as follows:
[0053]
[0054] in, Represents the historical trajectory part and The future trajectory part, the two together constitute the representative trajectory corresponding to the i-th cluster center, N is the number of clusters obtained by clustering, M represents the representative trajectory set; are the time length of the historical trajectory part, t f is the time length of the portion of the future trajectory to be predicted.
[0055] Furthermore, the observation feature encoding is used to query the dictionary and construct auxiliary features. The specific process is as follows:
[0056] The observed feature encoding of the target trajectory is multiplied by all the keys in the dictionary, and the probability is obtained through the softmax function to obtain the similarity between the target trajectory and the center of cluster i corresponding to each representative trajectory;
[0057] Multiply each value in the dictionary by the corresponding similarity to obtain the constructed auxiliary features.
[0058] Beneficial effects:
[0059] 1. The present invention provides a trajectory prediction system and method based on a dictionary. The present invention uses clustering to build a knowledge base in advance, and no update operation is required during the training process. The memory controller network is removed, effectively reducing the computing cost. Compared with the MANTRA architecture, the present invention has fewer hyperparameters, and some of the hyperparameters can be reasonably selected through existing experience. The present invention uses less memory and reduces data redundancy.
[0060] 2. The use of clustering can make the data features of each distribution point of the entire data set be reflected, avoiding the data distribution problem caused by different frequencies of occurrence. Clustering can give equal importance to all data with different characteristics. At the same time, the present invention can effectively distinguish the relationship between each target key-value pair by changing the clustering method and distance formula, effectively avoiding the occurrence of redundancy. In summary, the dictionary-based trajectory prediction system and method proposed in the present invention can cover a wider range of data and use the dictionary storage space more efficiently.
[0061] 3. There are mainly two existing dictionary methods. One is the traditional dictionary construction method, in which the key-value pairs are manually selected by people; the other is to use neural networks such as memory controllers to select key-value pairs. The above two traditional dictionary construction methods cannot take into account the number of key-value pairs, representativeness and the distance relationship between each key-value pair at the same time. Compared with the traditional dictionary construction method, the method proposed in the present invention can control the number of key-value pairs desired by the present invention by changing the number of clusters. At the same time, compared with the memory controller method, the present invention can use lower computational time complexity, fewer parameters and memory to select more representative key-value pairs. Therefore, the methods proposed in the present invention are more advantageous, and the quality of the information in the dictionary and its distinct representativeness are still guaranteed when the dictionary size is controllable and time is limited. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] Figure 1 A schematic diagram of the structure of a trajectory prediction system based on a dictionary provided by the present invention;
[0063] Figure 2 Schematic diagram of the dictionary-based trajectory prediction system training strategy used in the present invention. DETAILED DESCRIPTION
[0064] The present invention is described in detail below with reference to the accompanying drawings and embodiments.
[0065] The dictionary-based trajectory prediction system provided by the present invention specifically solves the trajectory prediction problem, where the trajectory belongs to spatiotemporal data and involves various attributes, including geographic coordinates, object speed, acceleration and direction. The trajectory can be represented as a time series tuple, specifically as formula (2-1):
[0066] C={x t ,t},t∈T(2-1)
[0067] Where C is the time series tuple of the trajectory, T is the timestamp set, x t Represents geographic location data and other motion information, and t is the time. Longitude and latitude are usually used to represent the geographic location of a moving object. At the same time, ground speed and ground heading are used as supplementary features that can be used to reveal the behavior of a moving object and help discover any unexpected changes in speed or direction. The inclusion of this additional motion information is intended to construct a better representation of the data. In this way, the input trajectory data x t It contains four dimensions, as shown in formula (2-2):
[0068] x t =(lon t ,lat t ,sog t ,cog t) (2-2)
[0069] Among them, lon represents longitude, lat represents latitude, sog represents ground speed, cog represents ground heading, and the subscript t represents the information at time t, such as lon t Represents the longitude at time t.
[0070] Due to the deterministic prediction, trajectory prediction can be regarded as a regression task, given the h Historical observation trajectory data of a fixed time length from time t to time t, h is the time length of the historical trajectory sequence, and the goal is to find a regression model to predict the trajectory coordinates y within the future prediction range t =(lon t ,lat t ). t is the time length of the trajectory sequence to be predicted, so the trajectory prediction problem can be expressed as formula (2-3):
[0071]
[0072] Among them, the input trajectory data x t is a four-dimensional vector consisting of position, direction and velocity at time t, y t is the two-dimensional spatial coordinate at time t, f is the auxiliary information of the target trajectory obtained from the dictionary, M is the mapping function that the trajectory prediction model needs to learn, and M represents Figure 1 The entire model in , the model is introduced in blocks below.
[0073] In order to solve the trajectory prediction problem, the present invention proposes an LSTM_Seq2seq (Sequence to sequence) architecture based on a dictionary module. The present invention introduces a temporal attention mechanism as an intermediate layer in the Seq2seq architecture to prevent the memory forgetting of the long short-term memory network LSTM network (Long Short-Term Memory), which can greatly improve the accuracy of the encoder-decoder model. In addition, the present invention proposes a new clustering-based dictionary module, which stores the features required for prediction and can provide suggestions for predicting future trajectories for target trajectories. The keys and values in the dictionary module are constructed by clustering historical trajectories. Clustering is a machine learning method that can divide trajectories into multiple clusters, where the trajectories in each cluster are more similar than those in other groups. In this study, the K-Means clustering method based on the dynamic time warping DTW distance is used. The dictionary network established based on the clustering results stores the relationship mapping between past motion patterns and future trajectories. By comparing the historical trajectory of the target object with the key similarities found in the dictionary, the dictionary module can provide a supplementary feature for high-quality prediction of future trajectories.
[0074] Specifically, a dictionary-based trajectory prediction system, such as Figure 1 As shown, it includes a clustering module, a dictionary module, and an encoder-attention-decoder prediction architecture;
[0075] The clustering module is used to cluster the trajectory data set to select representative trajectories; the selected representative trajectories are sent to the dictionary module.
[0076] The trajectory dataset refers to the publicly available ship trajectory dataset.
[0077] The purpose of constructing a dictionary in the present invention is to store trajectories with different patterns in a dataset so that new trajectories can be compared with existing trajectories in the dictionary and similar patterns can be identified. However, due to the huge number of trajectories and the existence of similar motion patterns, storing the entire trajectory is usually impossible. To solve this problem, a clustering algorithm K-means is used to create an efficient and compressed representation of the trajectory dataset by dividing similar trajectories into clusters.
[0078] K-means first randomly initializes K cluster centers, and then clusters each trajectory with its nearest center. The algorithm continuously updates the cluster centers and eventually stabilizes to identify k trajectory clusters with similar behaviors. The present invention uses the existing DTW (Dynamic Time Warping) distance metric instead of the traditional Euclidean distance to calculate the distance between trajectories. The DTW metric can better align unequal trajectory sequences and more accurately measure the similarity between two trajectories. The dynamic programming algorithm of DTW is as shown in formula (2-4):
[0079]
[0080] where d DTW (tr 1 ,tr 2 ) are two trajectories tr 1 and tr 2 The similarity of tr 1 and tr 2 are trajectories of length m and n respectively. Assume tr 1 ={p 1 ,p 2 ,...p n}, p1~pn are the 1st to nth trajectory points, then Head(tr 1 )=p 1 ,Rest(tr 1 )={p 2 ,...p n}.
[0081] The steps of K-means algorithm are:
[0082] 1. The present invention uses a central trajectory table to represent each cluster. First, k trajectories are randomly selected from the data as central trajectories.
[0083] 2. For each track in the data set, use d DTW (tr 1 , tr 2 ) calculates its distance to each center trajectory and divides it into the set to which the nearest center belongs.
[0084] 3. After all data are grouped into a certain set, recalculate the center trajectory of each set.
[0085] 4. If the desired clustering effect is achieved, the algorithm terminates; otherwise, repeat steps 2-3.
[0086] Through the above steps, after clustering, the present invention obtains representative trajectories as shown in formula (2-5).
[0087]
[0088] in, History and The future part constitutes the i-th central trajectory, N is the number of clusters, and M represents the set of representative trajectories. h , t f t h is the time length of the historical trajectory sequence, t f is the time length of the future trajectory sequence to be predicted.
[0089] The encoder-attention-decoder prediction architecture is a sequence-to-sequence Seq2seq architecture consisting of a past encoder, a convolutional neural network CNN, and an attention mechanism decoder; the target trajectory is input into the encoder-attention-decoder prediction architecture, and the past encoder encodes the historical trajectory part of the target trajectory to obtain the observation feature encoding, which is used to query the dictionary and construct auxiliary features; the auxiliary features are fused with the observation feature encoding through the convolutional neural network CNN, and the fused features are used as the initial hidden state of the attention mechanism decoder, and the attention mechanism decoder outputs the predicted future trajectory.
[0090] The parameters of the past encoder in the dictionary are consistent with those in the encoder-attention-decoder trajectory prediction architecture; the decoder in the dictionary is consistent with the attention mechanism decoder in the encoder-attention-decoder trajectory prediction architecture without the attention mechanism.
[0091] With learnable parameters θ E The past encoder neural network will input the historical trajectory sequence (historical observation trajectory data) Represented as context vector The encoder is implemented using LSTM.
[0092]
[0093] in is the encoding network, θ E is the parameter that the encoder network needs to learn. h is the time length of the historical trajectory sequence;
[0094] LSTM receives two inputs ((x i ,h_enc i-1 )), where h_enc i-1 is the past encoder hidden state at the previous moment i-1, x i is the current trajectory information. It then uses these inputs to generate the hidden state of the current time step i. iThe encoding result of the trajectory prediction task based on the input up to time step i by the LSTM model in the past encoder can be regarded as a compressed information representation of the previous input and reflects the LSTM's memory of the previous motion. At each time step, the hidden state is updated and passed as input to the next time step. The implementation formula for each time step is shown in formula (2-7):
[0095] h_enc i =LSTM(x i ,h_enc i-1 )(2-7)
[0096] Therefore, the context vector is the sequence of all hidden states. This context vector will be used in the attention mechanism of the attention decoder:
[0097]
[0098] The attention decoder uses the final hidden state of the encoder as one of the inputs to generate the future trajectory of the object. The decoder is mainly implemented using LSTM. The prediction y of each time step is used as the input of the next time step, and the entire prediction sequence is generated in this autoregressive way. The next position at the predicted time j is h_dec j , the formula is:
[0099] h_dec j =LSTM(y j-1 ,c j ,h_dec j-1 θ D ) (2-9)
[0100] y j =W y h_dec j +b y (2-10)
[0101] where h_dec j is the hidden state of the attention decoder at time j, used to predict the position at time j. D are the decoder network parameters, with the final hidden state of the past encoder as the initial state of this decoder. j is the context representation obtained by the attention mechanism. y and b y W is a trainable network weight that converts the decoder hidden state into the predicted position y by calculating the network weight matrix. 0 b 0 The initial state is the default value.
[0102] h_dec 0=tanh(W 0 h_enc t +b 0 ) (2-11)
[0103] By recursively applying equations (2-9) and (2-10) at each time step, the attention decoder can generate the entire future trajectory. In this way, the attention decoder can exploit the serial correlation present in the input sequence to regressively generate highly accurate and meaningful predictions.
[0104] Formula (2-12) describes the context representation c generated by the attention mechanism j . It is obtained by taking the weighted sum of all hidden states of the encoder.
[0105]
[0106] Where A represents the attention mechanism, θ A is the parameter that the attention network needs to learn; this mechanism aggregates the encoder hidden state sequence and the decoder hidden state at the previous moment into a compressed context vector. In order to determine the attention mechanism A, the following common steps of the attention mechanism are used:
[0107] 1) Calculate the attention score e ij , the attention score reflects the correlation between the hidden state of each moment i in the past encoder and the hidden state of the attention decoder at moment j-1.
[0108]
[0109] in, W a b a are the linear transformation parameters that can be learned by the linear model. [,] represents the concatenation of vectors.
[0110] 2) Calculate a set of attention weights for the attention decoder at time j, expressed as α ij is the weight assigned by the attention mechanism to the hidden state of the attention decoder at time j to the hidden state of the i-th past encoder, calculated in equation (2-14).
[0111]
[0112] 3) After calculating the attention weights, a contextual representation is created by summing all encoder hidden states corresponding to their respective attention weights.
[0113]
[0114] The dictionary module uses the past encoder and the future encoder to construct the dictionary; the dictionary module uses the past encoder to encode the historical trajectory part of each representative trajectory to generate the key in the dictionary; the dictionary module uses the future encoder to encode the future trajectory part of each representative trajectory to generate the value in the dictionary; the dictionary is composed of key-value pairs;
[0115] In the latent space of deep learning, data will reveal more information. In order to enable the model to utilize the data in the latent space, the present invention uses certain transformations to process the original data and map it to the latent space. Therefore, the dictionary does not store the original data, but the transformed information. Specifically, after obtaining the representative trajectory, two encoders E history and E future The historical trajectory part and the future trajectory part are encoded separately. This method has two advantages: first, it reduces data redundancy and dimensionality, enabling the model to distinguish different trajectories and make accurate predictions; second, by encoding the information of the future part, the decoder is allowed to be forward-looking, obtain information related to the future before prediction, and make more accurate predictions. At the same time, this also helps the decoder to complete the prediction task of longer sequences, otherwise it is difficult to complete the task without knowing the future steps of the sequence. The past encoder and the encoder-attention-decoder trajectory prediction architecture in the dictionary module are the same past encoder, which is used during training and target trajectory prediction. The dictionary module in the present invention includes a past encoder (E history denoted) and a future encoder (this paper uses E future express).
[0116] First, the encoder E history The keys in the dictionary are generated by encoding the historical trajectory portion of each representative trajectory (the future portion of the historical portion of the representative trajectory is known through the clustering module).
[0117]
[0118] Where E history Represents the past encoder network, the network is the same as the Encoder in formula (2-1). i Represents the i-th key in the dictionary. represents the i-th historical trajectory sequence obtained by clustering. N is the number of trajectory sequences obtained by clustering.
[0119] Similarly, the future encoder E future The values in the dictionary are generated by encoding the future trajectory portion of each representative trajectory.
[0120]
[0121] Among them, E future Represents the future encoder network, which is the same as the Encoder in formula (2-1). i Represents the i-th value in the dictionary. represents the i-th future trajectory sequence obtained by clustering. N is the number of trajectory sequences obtained by clustering.
[0122] The constructed dictionary is represented as D, which consists of the key-value pairs π in equation (2-18) i ,φ i ∈R N×S where N is the number of clusters, S is the embedding dimension, and both S keys and values are generated by the encoder, which is the dimension generated by the encoder.
[0123]
[0124] When a new target trajectory is predicted, it will be generated by the past encoder E history Encode to extract its observed features π k .
[0125]
[0126] The superscript k represents the kth predicted trajectory.
[0127] Then, auxiliary features are extracted from the dictionary in two steps: query and construction. In the query process, the target trajectory feature is multiplied with all the keys in the dictionary, and the probability obtained by the softmax function represents the probability of the target trajectory and the center π of each cluster i. i The similarity q between k .
[0128] q k =softmax(π i π k ) i=1,2,...,N (2-20)
[0129] Then construct: multiply each value in the dictionary by the corresponding similarity to obtain the constructed auxiliary feature f k φ i Represents the i-th value in the dictionary.
[0130]
[0131] The auxiliary features provide possible motion trends for the target trajectory. Then, the present invention combines the auxiliary features with the latent features π of the history encoder of the target trajectory through CNN (Convolutional Neural Networks). kCombined, the fused features are used as the initial hidden state of the decoder, and the process is shown in Equation (2-22). CNN can effectively fuse these two features to produce a more robust feature representation. This process allows the decoder to acquire knowledge about past and future motions, thereby making more accurate predictions about future trajectories.
[0132] h_dec 0 =CNN[f k ,π k ] (2-22)
[0133] where h_dec 0 represents the initial hidden state of the decoder and [,] represents the concatenation of vectors.
[0134] For the above dictionary-based trajectory prediction system, the following training strategy is adopted. The principle architecture of the training strategy is as follows: Figure 2 As shown, the training strategy of the entire model is divided into three steps:
[0135] Step 1: Since the past encoder in Seq2seq is needed to build a dictionary module for feature representation, the first training step is to train the Seq2seq architecture without a dictionary module. Two LSTM encoders with 128-dimensional hidden states and one LSTM decoder with 256-dimensional hidden states constitute the architecture. The encoder is used to reconstruct the future using the observed part and the future predicted part of the same trajectory. MSE (Mean squared error) is used as a loss to calculate the difference between the true and predicted latitude and longitude, see formula (2-23). To avoid overfitting, the model is trained using the Adam optimizer with a learning rate of 0.0001 in 20 iterations.
[0136]
[0137] where ||.|| 2 is the Euclidean distance. MSE is the mean square error loss function, is the longitude and latitude predicted at time t+l, is the actual longitude and latitude at time t+l, t f is the length of the forecast period. In this formula, t represents the length of the historical trajectory and is a fixed constant.
[0138] Step 2: Once the first training step is completed, the CNN network is trained while keeping the encoder and decoder frozen. During this process, the model uses the same MSE loss function as previously used. The purpose of this training phase is to teach the CNN network how to fuse the observed trajectory features with the dictionary auxiliary features.
[0139] Step 3: In the final stage of training, the decoder is unfrozen to fine-tune the entire model. In this stage, the two previously trained parts, the dictionary module and the Seq2seq framework, are integrated together to create a unified model.
[0140] In summary, the above are only preferred embodiments of the present invention and are not intended to limit the protection scope of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A dictionary-based trajectory prediction system, characterized in that: Includes clustering module, dictionary module and encoder-attention-decoder prediction architecture; The clustering module is used to cluster the trajectory data set to select representative trajectories; the selected representative trajectories are sent to the dictionary module; The dictionary module constructs a dictionary using a past encoder and a future encoder; The dictionary module encodes the historical trajectory portion in each of the representative trajectories using a past encoder to generate a key in a dictionary; The dictionary module uses a future encoder to encode the future trajectory part of each representative trajectory to generate values in the dictionary; the dictionary is composed of key-value pairs; The encoder-attention-decoder prediction architecture is a sequence-to-sequence Seq2seq architecture consisting of a past encoder, a convolutional neural network (CNN), and an attention mechanism decoder; the target trajectory is input into the encoder-attention-decoder prediction architecture, the past encoder encodes the historical trajectory part of the target trajectory to obtain an observation feature code, and the observation feature code is used to query the dictionary to construct an auxiliary feature; the auxiliary feature is fused with the observation feature code through the convolutional neural network (CNN), and the fused feature is used as the initial hidden state of the attention mechanism decoder, and the attention mechanism decoder outputs the predicted future trajectory; The method of using the observed feature code, querying the dictionary, and constructing auxiliary features specifically includes two processes: querying and constructing: The query process is as follows: the observed feature code of the target trajectory is multiplied by all the keys in the dictionary, and the probability is obtained through the softmax function to obtain the similarity between the target trajectory and the center of cluster i corresponding to each representative trajectory; The construction process is: multiply each value in the dictionary by the corresponding similarity to obtain the constructed auxiliary features.
2. A dictionary-based trajectory prediction system as claimed in claim 1, characterized in that: The clustering module is used to cluster the trajectory data set to select representative trajectories; the clustering method adopted is the K-means method.
3. A dictionary-based trajectory prediction method, characterized in that: The steps include: Step 1: Cluster the trajectory data set to select representative trajectories; Step 2: Use the past encoder and the future encoder to construct a dictionary, including: Using a past encoder to encode the historical trajectory part of each representative trajectory to generate a key in a dictionary; using a future encoder to encode the future trajectory part of each representative trajectory to generate a value in the dictionary; forming a dictionary with key-value pairs; Step 3: Receive the input of the target trajectory, use the past encoder to encode the historical trajectory part of the target trajectory, obtain the observation feature code, use the observation feature code to query the dictionary, and construct the auxiliary feature; use the convolutional neural network CNN to fuse the auxiliary feature with the observation feature code, and use the fused feature as the initial hidden state of the attention mechanism decoder, and the attention mechanism decoder outputs the predicted future trajectory; The specific process of using the observed feature code, querying the dictionary, and constructing auxiliary features is as follows: The observed feature encoding of the target trajectory is multiplied by all the keys in the dictionary, and the probability is obtained through the softmax function to obtain the similarity between the target trajectory and the center of cluster i corresponding to each representative trajectory; Multiply each value in the dictionary by the corresponding similarity to obtain the constructed auxiliary features.
4. A dictionary-based trajectory prediction method as claimed in claim 3, characterized in that: The clustering of the trajectory data set to select representative trajectories is performed in the following specific steps: Step 101: Using a center trajectory table to represent each cluster, first randomly select k trajectories from the trajectory data set as center trajectories; Step 102: for each trajectory in the trajectory data set, calculate its distance from each center trajectory, and divide it into the set to which the nearest center trajectory belongs; Repeat step 102 until all trajectories in the trajectory data set are grouped into one set, and the central trajectory of each set is recalculated; finally, a total of N clusters are obtained; Step 104: After clustering, select representative trajectories as follows: in, Represents the historical trajectory part and The future trajectory part, the two together constitute the representative trajectory corresponding to the i-th cluster center, N is the number of clusters obtained by clustering, and M represents the representative trajectory set; t h is the time length of the historical trajectory sequence, t f is the time length of the portion of the future trajectory to be predicted.
Citation Information
Patent Citations
Cross-viewing-angle human body behavior recognition method and device based on dictionary learning
CN108108652A
Novel moving object destination prediction algorithm
CN110738370A
