A pedestrian trajectory prediction method based on spatiotemporal attention mechanism
By combining a pedestrian trajectory prediction method based on the spatiotemporal attention mechanism with dynamic programming and information entropy loss optimization, the problem of existing methods failing to fully capture users' long-term and short-term preferences is solved, achieving more accurate trajectory prediction results.
Patent Information
- Application Number
- CN202311170381.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-12
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2043-09-12
AI Technical Summary
Existing trajectory prediction methods fail to fully capture users' long-term and short-term preferences, ignoring the representation of geographical factors in users' long-term preferences and the suddenness of users' short-term preferences.
A pedestrian trajectory prediction method based on the spatiotemporal attention mechanism is adopted. By obtaining the user's historical long-term trajectory sequence and current short-term trajectory sequence, the dynamic programming algorithm and attention mechanism are used to integrate geographic location characteristics, model the user's long-term and short-term preferences, and optimize the model parameters in combination with information entropy loss.
The accuracy and robustness of trajectory prediction are improved, and it can better capture users' long-term and short-term preferences, especially showing excellent prediction performance on real pedestrian trajectory datasets.
Smart Images

Figure CN117149934B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of pedestrian trajectory prediction, and specifically relates to a pedestrian trajectory prediction method based on a spatiotemporal attention mechanism. Background Art
[0002] In recent years, location-based social networking services, such as Foursquare, Gowalla, and Facebook, have grown rapidly. These services attract users to share their locations and accumulate vast amounts of trajectory data. By mining this trajectory data, we can understand user behavior patterns and predict their future whereabouts, providing decision support for ride-sharing services, government traffic scheduling, and other applications. In real life, trajectory prediction primarily mines historical trajectory sequences to model user behavior preferences and provide personalized recommendations for more accurate predictions.
[0003] Early research methods focused on modeling the sequential dependencies of user trajectories and can be categorized into Markov chain-based models and deep learning-based models. Markov chain-based models model short-term user trajectories to evaluate the corresponding transition matrix and provide the probability of visiting the next location. However, due to the sparsity of sequential data, Markov chain-based models struggle to accurately estimate the transition matrix. To address this issue, the FPMC model uses personalized Markov chains and matrix factorization to estimate the transition matrix and capture users' regular sequential preferences, respectively. Matrix factorization is then used to model users' short-term preferences. However, population migration transition patterns, resulting from diverse behavioral habits, exhibit strong correlations with time and location and are highly irregular, defying simple Markov assumptions. For example, during weekday morning and evening rush hours, most urban residents migrate between work and home. However, on weekends and holidays, during the same time periods, people typically visit other locations, such as restaurants and shopping malls. Deep learning models, such as RNNs and their variants, such as gated recurrent units (GRUs) and long short-term memory networks (LSTMs), have been applied to trajectory prediction tasks. These recurrent neural networks, with their memory mechanisms, can better locally model long-term input sequences, achieving superior performance compared to Markov chain-based prediction methods. For example, a real-time preference mining model (RTPM) that combines users' long-term and short-term preferences has achieved promising results. However, this approach suffers from two issues: 1) it fails to fully consider the impact of visit order and distance between locations on user preferences when modeling long-term preferences; and 2) it ignores sudden changes in preferences caused by changes in the distance between users' visits when modeling short-term preferences. Summary of the Invention
[0004] Existing trajectory prediction methods fail to fully capture users' long-term and short-term preferences. Specifically, they ignore the geographical factors in users' long-term preferences and the suddenness in users' short-term preferences. To address the shortcomings of existing technologies, this paper proposes a pedestrian trajectory prediction method based on a spatiotemporal attention mechanism. The method comprises: obtaining a user's historical long-term trajectory sequence and current short-term trajectory sequence, and inputting them into a trained pedestrian trajectory prediction model based on the spatiotemporal attention mechanism to obtain a pedestrian trajectory prediction result;
[0005] The training process of the pedestrian trajectory prediction model based on the spatiotemporal attention mechanism includes:
[0006] S1: Obtain the training trajectory sequence and divide it into a historical long-term trajectory sequence and a current short-term trajectory sequence; the historical long-term trajectory sequence includes multiple historical short-term trajectory sequences;
[0007] S2: Input the historical long-term trajectory sequence and the current short-term trajectory sequence into the input layer for processing, and obtain the preference vector of the historical long-term trajectory sequence, the preference vector of the current short-term trajectory sequence, and the preference vector of the current short-term optimal trajectory sequence;
[0008] S3: Use the historical long-term processing module to process the preference vectors of the historical long-term trajectory sequence and the current short-term trajectory sequence to obtain the user's long-term behavior preference representation that integrates geographic location characteristics;
[0009] S4: Use the current short-term processing module to perform weighted summation on the preference vector of the current short-term trajectory sequence and the current short-term optimal preference representation to obtain a comprehensive short-term preference representation;
[0010] S5: The comprehensive short-term preference representation and the user's long-term behavior preference representation integrated with geographic location characteristics are input into the prediction module to obtain the pedestrian trajectory prediction result;
[0011] S6: Calculate the information entropy loss and adjust the model parameters according to the information entropy loss to obtain a trained pedestrian trajectory prediction model based on the spatiotemporal attention mechanism.
[0012] Preferably, the input layer processes the historical long-term trajectory sequence and the current short-term trajectory sequence in the following manner:
[0013] The dynamic programming optimal path algorithm is used to process the current short-term trajectory sequence to obtain the current short-term optimal trajectory sequence;
[0014] Encode the POI information in the historical long-term trajectory sequence, the current short-term trajectory sequence, and the current short-term optimal trajectory sequence respectively to obtain the embedding representation of the corresponding trajectory sequence;
[0015] The embedded representation of the historical long-term trajectory sequence is input into the LSTM network to obtain the preference vector of the historical long-term trajectory sequence; the embedded representation of the current short-term trajectory sequence and the embedded representation of the current short-term optimal trajectory sequence are input into the GRU network to obtain the preference vector of the current short-term trajectory sequence and the preference vector of the current short-term optimal trajectory sequence.
[0016] Preferably, the process of obtaining the user's long-term behavior preference representation includes:
[0017] S31: Using the temporal context perception module to process the preference vectors of the long-term historical trajectory sequence, a long-term historical trajectory sequence representation is obtained; the long-term historical trajectory sequence representation includes multiple short-term historical trajectory sequence representations;
[0018] S32: Based on the preference vectors of the historical long-term trajectory sequence representation and the current short-term trajectory sequence, the geographic self-attention perception module is used to process the historical long-term trajectory sequence and the current short-term trajectory sequence to obtain the user's long-term behavior preference representation that integrates geographic location characteristics.
[0019] Furthermore, the process of obtaining the long-term historical trajectory sequence representation includes:
[0020] The long-term historical trajectory sequence is divided into time slots to obtain multiple access time slot sequences; the Levenshtein similarity between each POI in the short-term historical trajectory sequence and the current access time slot sequence is calculated;
[0021] Normalize the Levenshtein similarity to obtain the time weight of the POI;
[0022] The time weight and preference vector of the POI in each historical short-term trajectory sequence are weighted and summed to obtain the representation of all historical short-term trajectory sequences; the representation of all historical short-term trajectory sequences is the representation of the historical long-term trajectory sequence.
[0023] Furthermore, the formula for characterizing the historical short-term trajectory sequence is obtained as follows:
[0024]
[0025] Among them, s h represents the hth historical short-term sequence representation in the historical long-term trajectory sequence, |S h | represents the length of the h-th historical short-term sequence, ω t represents the time weight of the t-th POI in the h-th historical short period sequence, h t represents the preference vector of the t-th POI in the h-th historical short-term sequence.
[0026] Furthermore, the process of using the geographic self-attention perception module to process the historical long-term trajectory sequence and the current short-term trajectory sequence includes:
[0027] Calculate the current short-term trajectory sequence representation according to the preference vector of the current short-term trajectory sequence;
[0028] The importance representation of the historical long-term trajectory sequence is calculated based on the historical long-term trajectory sequence representation and the current short-term trajectory sequence representation;
[0029] Calculate the center position coordinates of each historical short-term trajectory sequence and the center position coordinates of the current short-term trajectory sequence; calculate the center distance between each historical short-term trajectory sequence and the current short-term trajectory sequence based on the center position coordinates of the historical short-term trajectory sequence and the center position coordinates of the current short-term trajectory sequence;
[0030] The user's long-term behavior preference representation that integrates geographic location characteristics is calculated based on the center distance between the historical short-term trajectory sequence and the current short-term trajectory sequence, the importance representation of the historical long-term trajectory sequence, and the representation of the historical short-term trajectory sequence.
[0031] Furthermore, the calculation formula for the current short-term trajectory sequence representation is:
[0032]
[0033] Among them, s n represents the current short-term trajectory sequence representation, |S n | represents the length of the current short-term trajectory sequence, h′ t represents the preference vector of the t-th POI in the current short-term trajectory sequence.
[0034] Furthermore, the formula for calculating the user's long-term behavioral preference representation that incorporates geographic location characteristics is:
[0035]
[0036] Among them, s n Represents the user's long-term behavioral preference representation, represents the center distance between the hth historical short-term trajectory sequence and the current short-term trajectory sequence, s′ n Represents the importance of the long-term historical trajectory sequence, s h Represents the hth historical short-term trajectory sequence in the historical long-term trajectory sequence.
[0037] Preferably, the formula for obtaining the pedestrian trajectory prediction result is:
[0038]
[0039] Among them, p represents the pedestrian trajectory prediction result, s″ n represents the user's long-term behavior preference representation, h″ represents the comprehensive short-term preference representation, and W p A trainable projection matrix representing all visited locations, Indicates splicing.
[0040] Preferably, the formula for calculating information entropy loss is:
[0041]
[0042] Among them, Loss represents information entropy loss, p i represents the user's preference probability for the i-th POI in the training sample, and N represents the total number of POIs in the training sample.
[0043] The present invention has the following advantages: It incorporates a distance metric between historical long-term trajectory sequences and current short-term trajectory sequences when modeling users' long-term preferences; It also employs a dynamic programming algorithm to determine the user's optimal access sequence and, from this, the optimal preference representation for the current short period. Finally, the user's long-term and short-term preferences are combined to form an overall preference representation, which is then input into the prediction module to obtain the final pedestrian trajectory prediction results. To evaluate the effectiveness of the proposed model, experiments were conducted on three real-world, geographically based pedestrian trajectory datasets. The results demonstrate that the proposed model outperforms existing trajectory prediction methods and exhibits excellent robustness. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 Schematic diagram of the STAMM model structure in the present invention;
[0045] Figure 2 This is the ablation experiment result diagram of the STAMM model in the present invention;
[0046] Figure 3 This is a comparison chart of the robustness accuracy of the STAMM model in the present invention when verifying the embedding vector dimension on different data sets. DETAILED DESCRIPTION
[0047] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0048] The present invention proposes a pedestrian trajectory prediction method based on a spatiotemporal attention mechanism. The method comprises the following steps: obtaining a user's historical long-term trajectory sequence and current short-term trajectory sequence, and inputting them into a trained pedestrian trajectory prediction model based on the spatiotemporal attention mechanism to obtain a pedestrian trajectory prediction result;
[0049] Pedestrian trajectory prediction model based on spatiotemporal attention mechanism (STAMM) Figure 1 As shown in the figure, the model consists of an input layer, a processing layer, and a prediction layer; the processing layer includes a historical long-term processing module and a current short-term processing module, and the historical long-term processing module consists of a temporal context perception module and a geographic self-attention perception module.
[0050] The training process of the pedestrian trajectory prediction model based on the spatiotemporal attention mechanism includes:
[0051] S1: Obtain the training trajectory sequence and divide it into a historical long-term trajectory sequence and a current short-term trajectory sequence; the historical long-term trajectory sequence includes multiple historical short-term trajectory sequences.
[0052] Obtain the training trajectory sequence and divide it into a long-term historical trajectory sequence and a short-term current trajectory sequence on a daily basis. For example, in a week, the trajectory sequences of the first six days are used as the long-term historical trajectory sequence, and the trajectory sequence of the last day is used as the short-term current trajectory sequence. The long-term historical trajectory sequence includes multiple short-term historical sequences, each of which is the trajectory sequence of one of the first six days.
[0053] S2: Input the historical long-term trajectory sequence and the current short-term trajectory sequence into the input layer for processing to obtain the preference vector of the historical long-term trajectory sequence, the preference vector of the current short-term trajectory sequence, and the preference vector of the current short-term optimal trajectory sequence.
[0054] The input layer processes the historical long-term trajectory sequence and the current short-term trajectory sequence in the following ways:
[0055] The dynamic programming optimal path algorithm is used to process the current short-term trajectory sequence to obtain the current short-term optimal trajectory sequence. Specifically:
[0056] 1) Input the current short-term trajectory sequence S n ={l1, l2, ..., l T}); After that, the distance between each POI is calculated from the beginning to the end, and the distance matrix Dist is constructed based on this.
[0057] Initialize the res array and set its size equal to the length of the current short-term trajectory sequence. Then, starting from the starting point of the current short-term trajectory sequence, calculate the shortest distance d between the starting position and each subsequent position according to the distance matrix Dist and store it in the corresponding position of the res array.
[0058] 2) Initialize stack st, initialize indexes i and j, set i equal to the index of the last position in the res array, set j equal to 0, and traverse from back to front while keeping j less than i. When the condition res[i]-Dist[i][j] == res[j] is met, push j into the stack and increment it by one unit. If this condition is not met, increment j by one unit. In addition, if j increases to be greater than or equal to i during this process, set i equal to the top element of the stack, reset j to 0, and repeat the above process until i equals 0 and terminate the entire process.
[0059] 3) Pop the elements in stack st in sequence to obtain the optimal trajectory sequence for the current short period
[0060] Encode the POI information in the historical long-term trajectory sequence, the current short-term trajectory sequence, and the current short-term optimal trajectory sequence respectively to obtain the embedding representation of the corresponding trajectory sequence;
[0061] The embedded representation of the historical long-term trajectory sequence is input into the LSTM network to obtain the preference vector of the historical long-term trajectory sequence. The embedded representation of the current short-term trajectory sequence and the embedded representation of the current short-term optimal trajectory sequence are input into the GRU network to obtain the preference vector of the current short-term trajectory sequence and the preference vector of the current short-term optimal trajectory sequence. The preference vectors of different trajectory sequences are the preference vectors of all POIs in the corresponding trajectory sequence.
[0062] The embedded representation of the historical long-term trajectory sequence is input into the LSTM network to obtain the preference vector of the historical long-term trajectory sequence; it is expressed as:
[0063] h t =LSTM(x t , h t-1 ), t∈{1, 2, …, |S h |}
[0064] Among them, h t represents the hidden state of LSTM, and also represents the preference vector when user u visits the t-th POI location, x t represents the d-dimensional embedding vector of the t-th access position, |S h | represents the total number of POIs in the historical short-term trajectory sequence.
[0065] The GRU network processes the embedding representation of the current short-term optimal trajectory sequence, which is expressed as:
[0066]
[0067] in, Represented by the sequence middle The calculated preference vector of the t-th POI in the current short-term optimal trajectory sequence is: represents the embedding representation of the t-th POI in the current short-term optimal trajectory sequence, represents the preference vector of the t-1th POI in the optimal trajectory sequence.
[0068] The process of the GRU network processing the embedding representation of the current short-term trajectory sequence is the same as above and will not be repeated here.
[0069] S3: The historical long-term processing module is used to process the preference vectors of the historical long-term trajectory sequence and the current short-term trajectory sequence to obtain the user's long-term behavior preference representation that integrates geographic location characteristics.
[0070] S31: Use the temporal context perception module to process the preference vectors of the long-term historical trajectory sequence to obtain the long-term historical trajectory sequence representation. The long-term historical trajectory sequence representation includes multiple short-term historical trajectory sequence representations;
[0071] The context-aware module models users' long-term preferences from the perspective of their access time. Its main idea is to explore the connection between users' historical long-term preferences and current short-term preferences based on their access time and access sequence. Generally, the higher the similarity between historical and current behavior, the greater the influence of historical preferences on current decisions. To fully explore users' personalized preferences and corresponding spatiotemporal context features, this paper uses an attention mechanism that integrates access time and access sequence to obtain a temporal representation of users' long-term preferences. Specifically:
[0072] (1) Divide the long-term historical trajectory sequence into time slots to obtain multiple access time slot sequences.
[0073] For example, a long-term historical trajectory sequence (e.g., a week) is divided into 50 time slot segments, with half being weekdays and half being weekends. The set of access time slot sequences after the division can be expressed as: represents the |εth historical short-term trajectory sequence of the hth historical long-term trajectory sequence after the time slot division operation h |POI. )
[0074] (2) Calculate the Levenshtein similarity between each POI in the historical short-term trajectory sequence and the current visit time slot sequence.
[0075] Models based on recurrent neural networks focus on capturing users' sequential visit preferences. However, in the daily lives of urban residents, the popularity of each POI changes over time and with each user's behavioral habits. For example, most LBSN users choose to take public transportation during rush hour on weekdays and visit entertainment and leisure venues after get off work. These daily behavioral preferences determine the locations they will visit in future time periods. To achieve this, the present invention employs a time-weighted operation to capture the time-sensitive nature of trajectory behavior. Specifically, the higher the spatiotemporal similarity between the historical trajectory sequence and the current access time slot sequence, the higher the weight coefficient assigned to the corresponding historical time period sequence. Since the order of visits to different locations in real life can also influence future behavior trajectories to a certain extent, for example, flight attendants may spend time at the airport during the day and in the lounge at night in some seasons, while the opposite is true in other seasons. Based on this, the present invention uses the Levenshtein algorithm to calculate the similarity between different time periods:
[0076]
[0077] The formula for calculating Levenshtein similarity is:
[0078]
[0079] in, represents the Levenshtein similarity between the t-th POI in a historical short-term trajectory sequence and the current access time slot sequence, |cur| represents the length of the current access time slot sequence; |p t | is the length of the t-th POI, and its value is 1.
[0080] (3) Normalize the Levenshtein similarity to obtain the time weight of the POI.
[0081]
[0082] Among them, ω t represents the time weight of the t-th POI in the h-th historical short-term trajectory sequence, |S h | represents the length of the h-th historical short-term trajectory sequence.
[0083] (4) The time weight and preference vector of the POI in each historical short-term trajectory sequence are weighted and summed to obtain the representation of all historical short-term trajectory sequences; the representation of all historical short-term trajectory sequences is the representation of the historical long-term trajectory sequence.
[0084] The formula for characterizing the historical short-term trajectory sequence is:
[0085]
[0086] Among them, s h represents the hth historical short-term sequence representation in the historical long-term trajectory sequence, h t represents the preference vector of the t-th POI in the h-th historical short-term sequence.
[0087] S32: Based on the preference vectors of the historical long-term trajectory sequence representation and the current short-term trajectory sequence, the geographic self-attention perception module is used to process the historical long-term trajectory sequence and the current short-term trajectory sequence to obtain the user's long-term behavior preference representation that integrates geographic location characteristics.
[0088] The geographic self-attention perception module takes into account the cyclical nature of users' daily habits and the influence of locations they have visited in different historical time periods on their future locations. To capture these behavioral preferences related to location, the module fully explores and models the behavioral characteristics of user visits from a spatial perspective. Specifically:
[0089] Calculate the current short-term trajectory sequence representation based on the preference vector of the current short-term trajectory sequence:
[0090] The calculation formula for the current short-term trajectory sequence representation is:
[0091]
[0092] Among them, s n represents the current short-term trajectory sequence representation, |S n | represents the length of the current short-term trajectory sequence, h′ t represents the preference vector of the t-th POI in the current short-term trajectory sequence.
[0093] The importance representation of the trajectory sequence is calculated based on the historical long-term trajectory sequence representation and the current short-term trajectory sequence representation:
[0094] The present invention compares the historical trajectory sequence with the current short-term trajectory sequence one by one to obtain the importance representation of the historical long-term trajectory sequence:
[0095]
[0096] Among them, s′ n It represents the importance of the historical long-term trajectory sequence, which is the user's personalized preference that integrates the time factor; C(S) represents the normalization factor, s hrepresents the hth historical period sequence in the long historical trajectory sequence; f(s n ,s h ) function is used to calculate the similarity measurement function between each historical short-term trajectory sequence and the current short-term trajectory sequence.
[0097] The present invention also considers that the location a user will visit next will depend to some extent on their current location. For example, people tend to pick up packages when they get home from get off work, and when choosing a delivery point, they often choose a location close to home. Therefore, the present invention incorporates geographic location factors to ultimately represent the user's long-term behavioral preferences. First, calculate the center coordinates of the historical trajectory sequence:
[0098]
[0099]
[0100] in, represents the central longitude coordinate of the hth historical short-term trajectory sequence, represents the central latitude coordinate of the trajectory sequence of the hth historical period, represents the longitude coordinate of the t-th POI in the h-th historical short-term trajectory sequence, represents the latitude coordinate of the t-th POI in the h-th historical short-term trajectory sequence, where t is |S h |. |S h | represents the length of the h-th historical short-term trajectory sequence, i.e., the total number of POIs.
[0101] Similarly, calculate the center coordinates of the current short-term series:
[0102]
[0103]
[0104] Among them, lon cur Indicates the central longitude coordinate of the current short-term trajectory sequence, lat cur Represents the central latitude coordinate of the current short-term trajectory sequence, represents the longitude coordinate of the t-th POI in the current short-term trajectory sequence, Represents the latitude coordinate of the t-th POI in the current short-term trajectory sequence, where t is |S n |;|S n | represents the length of the current short-term sequence, i.e. the total number of POIs.
[0105] According to the center position coordinates of the historical short-term trajectory sequence and the center position coordinates of the current short-term trajectory sequence, the center distance between each historical short-term trajectory sequence and the current short-term trajectory sequence is calculated:
[0106]
[0107] in, It represents the center distance between the hth historical short-term trajectory sequence and the current short-term trajectory sequence.
[0108] The user's long-term behavior preference representation that integrates geographic location characteristics is calculated based on the center distance between the historical short-term trajectory sequence and the current short-term trajectory sequence, the importance representation of the historical long-term trajectory sequence, and the historical short-term trajectory sequence representation:
[0109]
[0110] Among them, s n It represents the user's long-term behavioral preference representation, which is a comprehensive representation obtained through the temporal context perception module and the geographic self-attention perception module. It is more comprehensive than the representation that only considers the time factor or the geographic location factor.
[0111] S4: Use the current short-term processing module to perform weighted summation on the preference vector of the current short-term trajectory sequence and the current short-term optimal preference representation to obtain a comprehensive short-term preference representation.
[0112] The comprehensive short-term preference representation is expressed as:
[0113]
[0114] Among them, h″ represents the user’s comprehensive short-term preference representation, represents the preference vector of the last POI in the current short-term trajectory sequence, It represents the preference vector of the last POI in the optimal trajectory sequence in the previous short period. ε is a hyperparameter, which is set to 0.5 by default in the experiment and can be adjusted accordingly according to the actual situation of different datasets.
[0115] S5: The comprehensive short-term preference representation and the user's long-term behavior preference representation integrated with geographic location characteristics are input into the prediction module to obtain the pedestrian trajectory prediction result.
[0116]
[0117] Among them, p represents the pedestrian trajectory prediction result, s″ n represents the user's long-term behavior preference representation, h″ represents the comprehensive short-term preference representation, and Wp p A trainable projection matrix representing all visited locations, represents concatenation, and softmax represents the softmax function.
[0118] S6: Calculate the information entropy loss and adjust the model parameters according to the information entropy loss to obtain a trained pedestrian trajectory prediction model based on the spatiotemporal attention mechanism.
[0119] The formula for calculating information entropy loss is:
[0120]
[0121] Among them, Loss represents information entropy loss, p i represents the user's preference probability for the i-th POI in the training sample, and N represents the total number of POIs in the training sample.
[0122] After obtaining the trained pedestrian trajectory prediction model based on the spatiotemporal attention mechanism, the historical long-term trajectory sequence to be predicted and the current short-term trajectory sequence are input into the model to obtain the pedestrian trajectory prediction result at the next moment.
[0123] Evaluation of the present invention:
[0124] The STAMM model (total), STAMM-L (long term), and STAMM-S (short term) were tested on three datasets. The experimental results are shown in the following table. Figure 2 As shown in the figure, the three datasets are NYC, TKY, and Gowalla. NYC and TKY are partial user trajectory data in New York and Tokyo from April 12, 2012, to February 16, 2013, and Gowalla is partial user trajectory data worldwide from February 2009 to October 2010. It can be observed that STAMM-L consistently outperforms STAMM-S. This may be because the spatiotemporal attention mechanism used by STAMM-L can better represent the periodicity of user visits based on the spatiotemporal contextual features of the trajectory sequence, demonstrating the importance of long-term preferences for next-hop trajectory prediction. Although STAMM-S is not as effective as STAMM-L, its performance on all three datasets is close to or even exceeds that of baseline methods such as GRU and ST-RNN. The STAMM model achieves the best performance on all three datasets, demonstrating the importance of modeling both long-term and short-term user preferences for next-hop trajectory prediction.
[0125] The performance of the model under different embedding vector dimensions can reflect its robustness. A small embedding vector dimension will cause the model to be unable to model some more complex semantic relationships well, thus making it unable to capture important features of the data, resulting in a decrease in prediction accuracy. On the contrary, a larger embedding vector dimension can provide richer information expression capabilities, but once it is too large, it will cause the model to overfit. The results of the experiment of adjusting the size of the embedding vector dimension and the hidden state dimension are shown in the figure below. Figure 3 As shown in the figure, the model's accuracy initially improves with increasing embedding vector and hidden state dimensions. It stabilizes on the NYC and TKY datasets after reaching 500 dimensions, and on the Gowalla dataset after reaching 800 dimensions. The model exhibits no overfitting until reaching 2000 dimensions. Therefore, the STAMM model exhibits good robustness.
[0126] In summary, this paper proposes a new trajectory prediction model, STAMM, which deeply explores and models the periodicity and suddenness of user behavior patterns based on long-term and short-term preferences. On the one hand, the model uses a two-layer attention mechanism with spatiotemporal awareness to capture the spatiotemporal factors in users' long-term preferences, reflecting the cyclical trends of access through cumulative integration. On the other hand, while considering the dependency of sequential access, the model introduces a dynamic programming optimal path algorithm to capture the suddenness of users' short-term preferences. Experimental results confirm that the proposed model can better capture user preferences than the baseline model, improving prediction accuracy while also maintaining good robustness.
[0127] The above embodiments further illustrate the purpose, technical solutions and advantages of the present invention in detail. It should be understood that the above embodiments are only preferred implementation plans of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made to the present invention within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A pedestrian trajectory prediction method based on spatiotemporal attention mechanism, characterized in that: include: Obtain the user's historical long-term trajectory sequence and current short-term trajectory sequence, and input them into the trained pedestrian trajectory prediction model based on the spatiotemporal attention mechanism to obtain the pedestrian trajectory prediction result; The training process of the pedestrian trajectory prediction model based on the spatiotemporal attention mechanism includes: S1: Obtain the training trajectory sequence and divide it into a historical long-term trajectory sequence and a current short-term trajectory sequence; the historical long-term trajectory sequence includes multiple historical short-term trajectory sequences; S2: Input the historical long-term trajectory sequence and the current short-term trajectory sequence into the input layer for processing, and obtain the preference vector of the historical long-term trajectory sequence, the preference vector of the current short-term trajectory sequence, and the preference vector of the current short-term optimal trajectory sequence; S3: Use the historical long-term processing module to process the preference vectors of the historical long-term trajectory sequence and the current short-term trajectory sequence to obtain the user's long-term behavior preference representation that integrates geographic location characteristics; S4: Use the current short-term processing module to perform weighted summation on the preference vector of the current short-term trajectory sequence and the current short-term optimal preference representation to obtain a comprehensive short-term preference representation; S5: The comprehensive short-term preference representation and the user's long-term behavior preference representation integrated with geographic location characteristics are input into the prediction module to obtain the pedestrian trajectory prediction result; S6: Calculate the information entropy loss and adjust the model parameters according to the information entropy loss to obtain a trained pedestrian trajectory prediction model based on the spatiotemporal attention mechanism.
2. The pedestrian trajectory prediction method based on spatiotemporal attention mechanism according to claim 1 is characterized in that: The input layer processes the historical long-term trajectory sequence and the current short-term trajectory sequence in the following ways: The dynamic programming optimal path algorithm is used to process the current short-term trajectory sequence to obtain the current short-term optimal trajectory sequence; Encode the POI information in the historical long-term trajectory sequence, the current short-term trajectory sequence, and the current short-term optimal trajectory sequence respectively to obtain the embedding representation of the corresponding trajectory sequence; The embedded representation of the historical long-term trajectory sequence is input into the LSTM network to obtain the preference vector of the historical long-term trajectory sequence; the embedded representation of the current short-term trajectory sequence and the embedded representation of the current short-term optimal trajectory sequence are input into the GRU network to obtain the preference vector of the current short-term trajectory sequence and the preference vector of the current short-term optimal trajectory sequence.
3. The pedestrian trajectory prediction method based on spatiotemporal attention mechanism according to claim 1 is characterized in that: The process of obtaining a representation of a user's long-term behavioral preferences includes: S31: Using the temporal context perception module to process the preference vectors of the long-term historical trajectory sequence, a long-term historical trajectory sequence representation is obtained; the long-term historical trajectory sequence representation includes multiple short-term historical trajectory sequence representations; S32: Based on the preference vectors of the historical long-term trajectory sequence representation and the current short-term trajectory sequence, the geographic self-attention perception module is used to process the historical long-term trajectory sequence and the current short-term trajectory sequence to obtain the user's long-term behavior preference representation that integrates geographic location characteristics.
4. The pedestrian trajectory prediction method based on spatiotemporal attention mechanism according to claim 3 is characterized in that: The process of obtaining a long-term historical trajectory sequence representation includes: The long-term historical trajectory sequence is divided into time slots to obtain multiple access time slot sequences; the Levenshtein similarity between each POI in the short-term historical trajectory sequence and the current access time slot sequence is calculated; Normalize the Levenshtein similarity to obtain the time weight of the POI; The time weight and preference vector of the POI in each historical short-term trajectory sequence are weighted and summed to obtain the representation of all historical short-term trajectory sequences; the representation of all historical short-term trajectory sequences is the representation of the historical long-term trajectory sequence.
5. The pedestrian trajectory prediction method based on spatiotemporal attention mechanism according to claim 4 is characterized in that: The formula for characterizing the historical short-term trajectory sequence is: Among them, s h represents the hth historical short-term sequence representation in the historical long-term trajectory sequence, |S h | represents the length of the h-th historical short-term sequence, ω t represents the time weight of the t-th POI in the h-th historical short period sequence, h t represents the preference vector of the t-th POI in the h-th historical short-term sequence.
6. The pedestrian trajectory prediction method based on spatiotemporal attention mechanism according to claim 3 is characterized in that: The process of using the geographic self-attention perception module to process the historical long-term trajectory sequence and the current short-term trajectory sequence includes: Calculate the current short-term trajectory sequence representation according to the preference vector of the current short-term trajectory sequence; The importance representation of the historical long-term trajectory sequence is calculated based on the historical long-term trajectory sequence representation and the current short-term trajectory sequence representation; Calculate the center position coordinates of each historical short-term trajectory sequence and the center position coordinates of the current short-term trajectory sequence; calculate the center distance between each historical short-term trajectory sequence and the current short-term trajectory sequence based on the center position coordinates of the historical short-term trajectory sequence and the center position coordinates of the current short-term trajectory sequence; The user's long-term behavior preference representation that integrates geographic location characteristics is calculated based on the center distance between the historical short-term trajectory sequence and the current short-term trajectory sequence, the importance representation of the historical long-term trajectory sequence, and the representation of the historical short-term trajectory sequence.
7. The pedestrian trajectory prediction method based on spatiotemporal attention mechanism according to claim 6 is characterized in that: The calculation formula for the current short-term trajectory sequence representation is: Among them, s n represents the current short-term trajectory sequence representation, |S n | represents the length of the current short-term trajectory sequence, h′ t represents the preference vector of the t-th POI in the current short-term trajectory sequence.
8. The pedestrian trajectory prediction method based on spatiotemporal attention mechanism according to claim 6 is characterized in that: The formula for calculating the user's long-term behavioral preference representation that incorporates geographic location characteristics is: Among them, s n Represents the user's long-term behavioral preference representation, represents the center distance between the hth historical short-term trajectory sequence and the current short-term trajectory sequence, s′ n Represents the importance of the long-term historical trajectory sequence, s h Represents the hth historical short-term trajectory sequence in the historical long-term trajectory sequence.
9. The pedestrian trajectory prediction method based on spatiotemporal attention mechanism according to claim 1, characterized in that: The formula for obtaining pedestrian trajectory prediction results is: Among them, p represents the pedestrian trajectory prediction result, s″ n represents the user's long-term behavior preference representation, h″ represents the comprehensive short-term preference representation, and W p A trainable projection matrix representing all visited locations, Indicates splicing.
10. The pedestrian trajectory prediction method based on spatiotemporal attention mechanism according to claim 1, characterized in that: The formula for calculating information entropy loss is: Among them, Loss represents information entropy loss, p i represents the user's preference probability for the i-th POI in the training sample, and N represents the total number of POIs in the training sample.