Travel mode identification method based on frequency spectrum feature extraction and attention mechanism enhancement
By constructing a travel mode recognition model based on spectral feature extraction and attention mechanism enhancement, the problem of insufficient fusion of trajectory periodicity and spatiotemporal information in existing technologies is solved, achieving more efficient travel mode recognition and improving the accuracy and stability of recognition.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING JIAOTONG UNIV
- Filing Date
- 2026-01-05
- Publication Date
- 2026-05-15
AI Technical Summary
Existing technologies lack explicit modeling of the periodicity and rhythmic patterns of trajectories in travel mode identification, have weak spatiotemporal semantic information fusion capabilities, and lack a post-processing mechanism for sequence consistency, resulting in high misjudgment rates and insufficient stability.
A travel mode recognition model consisting of a sequence encoder and a sequence decoder is used to extract spatial information of trajectories through multi-scale convolutional layers. Combined with a spectral feature extraction module and an attention mechanism, it captures local motion patterns at different time scales. The model outputs a continuous and consistent travel mode sequence by using a Transformer multi-head attention mechanism and a conditional random field to constrain travel mode switching.
It significantly improves the distinguishability and robustness of travel mode identification, ensuring that the output sequence conforms to the logical patterns of actual traffic behavior, and provides a more reliable basis for traffic planning and travel services.
Smart Images

Figure CN122045786A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent transportation technology, and in particular to a travel mode recognition method based on spectral feature extraction and attention mechanism enhancement. Background Technology
[0002] Travel mode identification aims to label transportation modes at each sampling point or segment in a time series based on trajectory data. Some travel modes typically involve stops at stations and traffic congestion, resulting in trajectories exhibiting clear rhythmicity across multiple time scales. Short-term time scales show instantaneous dynamic characteristics such as velocity, acceleration, and angular velocity; medium-term time scales show periodic changes such as starts and stops; and long-term time scales reflect the stages of the journey and residents' travel patterns. Therefore, these characteristics require travel mode identification models to have robust processing capabilities for input data, the ability to jointly model cross-scale patterns, and to maintain physical continuity at the sequence level.
[0003] Methods for identifying travel modes using GPS trajectory data have evolved from early experience-driven to data-driven approaches, primarily encompassing three categories: rule-based methods, traditional machine learning-based methods, and deep learning-based methods. Rule-based methods typically rely on expert experience to design deterministic rules. Reference 1 first divides the trajectory into segments using thresholds such as speed and dwell time, then determines the travel mode based on intra-segment feature rules. However, these rules, dependent on manual design, struggle to cover complex travel scenarios. With the increasing volume of GPS data, traditional machine learning methods are gradually replacing rule-based methods, extracting manually designed statistical features from trajectory data and inputting them into classification models for travel mode identification. Reference 2 extracts features such as average bus location proximity and candidate bus location proximity from real-time public transport information, and uses five different machine learning models—Bayesian networks, decision trees, random forests, Naive Bayes, and multilayer perceptrons—for mode identification. Compared to machine learning methods, deep learning methods can automatically refine high-level deep features, enabling in-depth mining of GPS trajectory point-level features and temporal correlations. Reference 3 introduces a deep network structure for spatiotemporal point cloud processing into travel mode recognition, and designs a spatiotemporal point cloud network STPC-Net, which directly learns representations at the point level and outputs travel mode labels, effectively capturing the spatiotemporal correlation between GPS trajectory points and the global information of the trajectory.
[0004] The disadvantages of the existing methods for identifying people's travel modes include: Existing techniques typically lack explicit modeling mechanisms for the periodicity and rhythmic patterns of trajectories. Most existing methods are limited to characterizing dynamic features such as velocity, acceleration, and steering angle in the time domain, struggling to separate and express frequency domain information generated by station stops and congestion propagation. This results in insufficient ability to characterize the periodic patterns of bus and subway stops. Furthermore, travel mode recognition models do not adequately characterize rhythmic features, easily leading to blurred boundaries between different categories, insufficient category discrimination, and a high misclassification rate.
[0005] Existing technologies have weak spatiotemporal semantic information fusion capabilities. Current methods typically use fixed vectors as input to the mode of travel identification model, lacking a dynamic selection mechanism for semantic features during encoding. This makes it difficult to adaptively highlight key geospatial and temporal information based on the contextual features of the trajectory. Consequently, when movement patterns are similar but geographical and temporal scenarios differ, category confusion easily occurs, ultimately hindering the stable improvement of the overall performance and robustness of mode of travel identification.
[0006] Existing technologies lack post-processing mechanisms for sequence consistency, which can easily lead to label jitter. Current two-stage recognition methods typically rely on trajectory segmentation; if segmentation errors occur, these errors can be amplified in subsequent classification stages, thus disrupting the temporal continuity of the trajectory. While one-stage recognition methods avoid segmentation, they often lack structured constraints on travel mode shift patterns, easily resulting in inconsistent mode switching and fragmented labels, leading to a decline in overall recognition stability and accuracy. Summary of the Invention
[0007] Embodiments of the present invention provide a travel mode identification method based on spectral feature extraction and attention mechanism enhancement, so as to effectively identify the travel mode of travelers.
[0008] To achieve the above objectives, the present invention adopts the following technical solution.
[0009] A travel mode identification method based on spectral feature extraction and attention mechanism enhancement includes: A pedestrian travel mode recognition model is composed of a sequence encoder and a sequence decoder. Pedestrian trajectory data is acquired through positioning devices, and the trajectory data is then split to obtain the original trajectory sequence; Features are extracted from the original trajectory sequence and input into the sequence encoder. The sequence encoder extracts the spatial information of the original trajectory sequence through multi-scale convolutional layers to obtain multi-view local feature vectors. Then, the global feature vector after frequency domain enhancement and attention weighted fusion is output through the spectral feature extraction module. The sequence decoder captures the patterns of pedestrian mode switching based on the global feature vector through the Transformer multi-head attention mechanism and conditional random field, and outputs the identified pedestrian mode sequence, which includes the latitude and longitude information of the trajectory points, time information, and the identified mode label information.
[0010] Preferably, the pedestrian travel mode recognition model composed of a sequence encoder and a sequence decoder includes: A travel mode recognition model is composed of a sequence encoder and a sequence decoder. The sequence encoder includes a multi-scale convolution module and a spectral feature encoding module. The multi-scale convolution module extracts local motion patterns at different time scales. The spectral feature encoding module explicitly enhances the rhythmic components caused by station stops and traffic congestion through fast Fourier transform, frequency weighted gating and inverse transform. The sequence decoder uses a Transformer to generate a point-by-point emission distribution and combines a conditional random field to constrain mode transitions, outputting a continuous and consistent travel mode sequence. Through complementary representations in the time and frequency domains and attention enhancement, the distinguishability of similar modes is improved, thus obtaining the pedestrian travel mode recognition result.
[0011] Preferably, the step of acquiring pedestrian trajectory data through a positioning device and splitting the trajectory data to obtain the original trajectory sequence includes: Pedestrian trajectory data is acquired through satellite positioning equipment. This trajectory data contains a time-stamped sequence of pedestrian spatial locations. The trajectory data is then divided into independent trips based on the time interval between adjacent points being greater than 20 minutes or the spatial distance being greater than 100 meters. Each trip is then divided into fixed-length travel segments. Segments that are not long enough are filled with zeros to form an original trajectory sequence of uniform length.
[0012] Preferably, the step of extracting features from the original trajectory sequence, inputting the features into a sequence encoder, the sequence encoder extracting spatial information of the original trajectory sequence through multi-scale convolutional layers to obtain multi-view local feature vectors, and then outputting a global feature vector after frequency domain enhancement and attention weighted fusion through a spectral feature extraction module, includes: Features are extracted from the original trajectory sequence and input into the multi-scale convolution module in the sequence encoder. The multi-scale convolution module contains three parallel convolutional branches, a feature concatenation and activation layer, and a channel reduction convolutional layer. Different sizes of convolutional kernels are used in the same layer to capture contextual information of different ranges. The padding and stride parameters of the convolutional branches are adjusted to control the spatial resolution and coverage of the feature map. Multiple convolutional layers are stacked to gradually integrate information from local features to global features and output multi-view local feature vectors. The multi-view local feature vectors are then input into the spectral feature extraction module. The multi-view local feature vector includes a frequency domain layer and an attention mechanism layer. The frequency domain layer uses Fourier transform operations to map the time-domain signal in the multi-view local feature vector to the frequency domain space, extracting trajectory spectral features. The frequency domain layer includes a fast Fourier transform layer, a weighted gating layer, and an inverse Fourier transform layer. The fast Fourier transform layer processes the input time-series signal... Convert to frequency domain signal The calculation formula is shown in formula (1); the weighted gating layer learns the importance of different frequency components by weighting each frequency component, and obtains the weighted frequency domain signal as follows. The calculation formula is shown in formula (2); the inverse Fourier transform layer converts the weighted frequency domain signal back to the time domain, and the calculation formula is shown in formula (3). (1) (2) (3) In the above formula, The input timing signal, For frequency domain signal representation, Represents time, Represents frequency, The weighted frequency domain signal The weights for the corresponding frequency components, The weighted timing signal; The attention mechanism layer includes a multi-head self-attention mechanism and a positional attention mechanism. The multi-head self-attention mechanism focuses on acquiring the phased changes of different traffic trips and the periodic characteristics of public transportation trips. It aggregates information by weighting the relationship between queries (Q), keys (K), and values (V). The calculation formula is shown in formula (4). The outputs of all heads are concatenated and the final output is obtained through linear transformation. For h attention heads, the calculation formula of the multi-head self-attention mechanism is shown in formula (5). The positional attention mechanism uses sine and cosine position encoding for each time step t. The calculation formula is shown in formula (6). The position attention mechanism will encode... Combined with the query matrix Q and key matrix K in self-attention, the calculation formula is shown in formula (7). The combination of batch normalization layer, discard layer, residual connection layer and fully connected layer is used in sequence to identify the fusion features of the trajectory. (4) (5) (6) (7) In the above formula, For the output of the self-attention mechanism, Represents the query matrix, key matrix, and value matrix in a Transformer. For the dimension of the key, To attract attention, For the output of the multi-head self-attention mechanism, For the row-limited transformation matrix, For sine and cosine position encoding, For the hidden dimensions of the model, For the output of the position attention mechanism, is the input latent vector of the decoder.
[0013] Preferably, the sequence decoder uses a Transformer to generate a point-by-point emission distribution and combines a conditional random field to constrain mode transitions, outputting a continuous and consistent travel mode sequence. Through complementary representations in the time and frequency domains and attention enhancement, the distinguishability of similar modes is improved, obtaining the pedestrian travel mode recognition result, including: The sequence decoder comprises a Transformer decoder layer and a Conditional Random Field (CRF) sequence constraint layer. The Transformer decoder layer includes a multi-head attention mechanism module, a residual connection layer, a layer normalization module, a forward propagation layer, and a fully connected layer. The Transformer decoder uses global feature vectors. As input, return a sequence Layer normalization is used to normalize the hidden layers of the network to a standard normal distribution. Linear mapping is performed in the forward propagation layer and ReLU activation is used. The probability sequence is obtained through fully connected layers and softmax layers. ,in It is a feature sequence of shape 1×M The probability distribution vector is M, which is the number of travel mode categories. The output of the Transformer decoder is used as the emission score, which represents the score of each possible label at each time step. The transition score of the Conditional Random Field is the score of transitioning from one label to the next label. These two scores work together on the corresponding layer of the Conditional Random Field to output a complete travel mode sequence that conforms to temporal logic. Given a global feature vector V, the sequence The scoring function is calculated as shown in formula (8). A probability value is defined for each correct travel mode label sequence y using the softmax function, as shown in formula (9). The training objective is to maximize the log probability value of the correct travel mode sequence, calculated as shown in formula (10). The gradient descent method is used to learn and optimize the neural network algorithm. The highest-scoring sequence is obtained after training. As the final identified travel mode sequence, the sequence It includes the latitude and longitude information of the trajectory points, time information, and the identified travel mode label information; (8) (9) (10) In the above formula, The total score for the label sequence. The input feature vector, The sequence of travel mode labels to be predicted. The length of the label sequence. To transfer points, To score points for the launch, For label sequence The conditional probability, For the set of all possible label sequences, To score The indexation, For label sequence about The logarithmic probability.
[0014] As can be seen from the technical solutions provided by the embodiments of the present invention described above, the present invention integrates multi-scale spatiotemporal features with attention enhancement mechanisms, which can capture local motion patterns at different time scales and characterize global trajectory correlations, thus strengthening temporal and positional dependencies. The present invention significantly improves distinguishability and robustness while ensuring that the output sequence conforms to the logical patterns of actual traffic behavior, providing a more reliable decision-making basis for traffic planning and travel services.
[0015] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and will become apparent from the description or may be learned by practice of the invention. Attached Figure Description
[0016] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is a schematic diagram illustrating the implementation principle of a travel mode identification method based on spectral feature extraction and attention mechanism enhancement, provided in an embodiment of the present invention. Figure 2 The flowchart illustrates a travel mode identification method based on spectral feature extraction and attention mechanism enhancement, as provided in this embodiment of the invention. Detailed Implementation
[0018] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.
[0019] Those skilled in the art will understand that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the term “comprising” as used in this specification means the presence of the stated features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof. It should be understood that when we say an element is “connected” or “coupled” to another element, it can be directly connected or coupled to the other element, or there may be intermediate elements. Furthermore, “connected” or “coupled” as used herein can include wireless connections or couplings. The term “and / or” as used herein includes any and all combinations of one or more of the associated listed items.
[0020] It will be understood by those skilled in the art that, unless otherwise defined, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. It should also be understood that terms such as those defined in general dictionaries should be understood to have the same meaning as in the context of the prior art, and should not be interpreted in an idealized or overly formal sense unless defined as herein.
[0021] To facilitate understanding of the embodiments of the present invention, the following will provide further explanation and description with reference to the accompanying drawings and several specific embodiments. These embodiments do not constitute a limitation on the embodiments of the present invention.
[0022] The implementation principle of the travel mode identification method based on spectral feature extraction and attention mechanism enhancement provided in this embodiment of the invention is as follows: Figure 1As shown, this method uses feature sequences extracted from GPS (Global Positioning System) trajectories as input, and constructs a travel mode recognition model using a sequence encoder and a sequence decoder. The sequence encoder includes a multi-scale convolutional module and a spectral feature encoding module. The multi-scale convolutional module extracts local motion patterns at different time scales, while the spectral feature encoding module explicitly enhances the rhythmic components caused by station stops and traffic congestion through Fast Fourier Transform, frequency-weighted gating, and inverse transform, thereby improving the model's ability to identify different travel modes. The sequence decoder uses a Transformer to generate a point-by-point mode emission distribution and combines a Conditional Random Field to constrain mode transitions, outputting a continuous and consistent travel mode sequence. This method does not require pre-determining mode transition points. Through complementary representations in the time and frequency domains and attention enhancement, it improves the distinguishability of similar modes and effectively suppresses label jitter, thus obtaining accurate and stable travel mode recognition results, providing strong technical support for travel mode recognition in the field of intelligent transportation.
[0023] The processing flow of a travel mode identification method based on spectral feature extraction and attention mechanism enhancement provided in this embodiment of the invention is as follows: Figure 2 As shown, the travel mode identification method of the present invention is for identifying the mode of pedestrian travel trajectory. It can be applied to scenarios such as one-ticket aggregated payment on travel-as-a-service platforms, multimodal transport fare clearing, and navigation apps providing personalized travel route recommendations to users. It includes the following processing steps: Step S10: A pedestrian travel mode recognition model is constructed by a sequence encoder and a sequence decoder.
[0024] A travel mode recognition model consists of a sequence encoder and a sequence decoder. The sequence encoder includes a multi-scale convolutional module and a spectral feature encoding module. The multi-scale convolutional module extracts local motion patterns at different time scales, while the spectral feature encoding module explicitly enhances the rhythmic components caused by station stops and traffic congestion through Fast Fourier Transform, frequency-weighted gating, and inverse transform. This improves the model's ability to identify different travel modes.
[0025] The sequence decoder uses a Transformer to generate a point-by-point emission distribution of modes and incorporates a Conditional Random Field to constrain mode transitions, outputting a continuous and consistent mode sequence. This method eliminates the need to predetermine mode transition points, enhances the distinguishability of similar modes through complementary representations in the time and frequency domains and attention enhancement, and effectively suppresses label jitter, thereby obtaining accurate and stable mode recognition results. This provides strong technical support for mode recognition in the field of intelligent transportation.
[0026] Define the key components of the travel mode recognition model architecture of this invention.
[0027] This represents the input timing signal. This represents the frequency domain signal representation. Indicates frequency, This represents the weighted frequency domain signal. This represents the weighted frequency domain signal. This represents the weighted timing signal. This represents the output of the self-attention mechanism. This represents the query matrix, key matrix, and value matrix in a Transformer, including the dimensions of the keys. The dimension representing the key. This represents the output of the multi-head self-attention mechanism. Represents the row-limited transformation matrix. Indicates the positional encoding of sine and cosine. Represents the hidden dimensions of the model. This represents the output of the position attention mechanism. Represents the latent vector, the input to the decoder. This represents the output sequence returned by the decoder. This represents the probability sequence obtained through a fully connected layer and a softmax layer. For shape Feature sequences The probability distribution vector, The number of different modes of transportation. Represents the transition score matrix. Indicates the mode of travel from arrive The transfer score, Represents the launch score matrix. Represents latent vector The method is inferred through the Transformer's decoder layer. The launch score, This represents all modes of transportation. Indicates a certain mode of transportation. The sequence score representation of the conditional random field layer. This represents the probability value defined by the softmax function for a sequence of travel modes. The training objective is to maximize the log probability of the correct mode of transport sequence.
[0028] Step S20: Obtain pedestrian trajectory data through GPS positioning device, divide the trajectory data, and obtain the original trajectory sequence.
[0029] Pedestrian trajectory data is obtained through GPS positioning devices. This trajectory data contains a time-stamped spatial location sequence. The trajectory sequence is the smallest processing unit after the trajectory data has been standardized. The trajectory data is divided into independent trips according to the time interval between adjacent points being greater than 20 minutes or the spatial distance being greater than 100 meters. Each trip is then divided into trip segments of fixed length. Segments that are not long enough are filled with zeros to form the original trajectory sequence of uniform length.
[0030] Step S30: Extract features from the original trajectory sequence to obtain features, then input the features into the sequence encoder, extract the spatial information of the original trajectory sequence through multi-scale convolutional layers to obtain multi-view local feature vectors, and then output the global feature vector after frequency domain enhancement and attention weighted fusion through the spectral feature extraction module.
[0031] The sequence encoder takes trajectory feature sequences as input, covering three core feature categories: first, motion features, including point-level and segment-level motion features; second, temporal attribute features, including whether it is a weekday or peak period; and third, geographical environment features, including public transportation-related features and intersection-related features. The sequence encoding module focuses on the periodicity and trend characteristics of the trajectory data, incorporating a multi-scale convolution module and a spectral feature extraction module, ultimately outputting a latent vector enhanced by time-frequency domain fusion.
[0032] First, the multi-scale convolutional module takes the original trajectory sequence as input and includes three parallel convolutional branches, a feature concatenation and activation layer, and a channel reduction convolutional layer. The role of the multi-scale convolutional layer is to extract spatial information from the trajectory sequence. Using convolutional kernels of different sizes within the same layer helps the model capture contextual information at different ranges. Adjusting the padding and stride parameters of the convolutional layers controls the spatial resolution and coverage of the feature maps. Stacking multiple convolutional layers allows each layer to gradually expand the receptive field, integrating information from local to global features, and ultimately outputting multi-view local feature vectors that can characterize the local motion patterns of the trajectory at different spatial scales. Second, travel trajectories contain rich frequency domain information. Combined with an attention mechanism, the model can dynamically focus on the periodic and global features of the input trajectory data, enabling a more comprehensive understanding of the characteristics of travel modes.
[0033] The spectral feature extraction module uses the multi-view local feature vectors output by the multi-scale convolution module as input data. This data is sequentially passed through a frequency domain layer, a self-attention layer, and a positional attention layer, ultimately outputting a global feature vector after frequency domain enhancement and attention-weighted fusion. Specifically, the frequency domain layer maps the time-domain signal of the trajectory to the frequency domain space using Fourier transform, extracting the spectral features of the motion pattern. The attention layer employs a multi-head self-attention mechanism and a positional attention mechanism to jointly model features, fully utilizing global and positional information to improve model performance. Simultaneously, to enhance the model's sequence perception capability, positional encoding is embedded to obtain information about the preceding and following parts of the trajectory sequence, enabling the model to focus on information from different representations at different locations.
[0034] The multi-scale convolution module inputs features of shape B×L×C into a multi-scale convolutional neural network, where B is the batch size, L is the input sequence length, and C is the feature dimension. The original features are processed in parallel through convolutional branches of different scales (3×3, 5×5, and 7×7) to extract sub-features of different granularities. The resulting three types of sub-features are concatenated and activated using a ReLU function, then input into the output channel of the reduced features in the 3×3 convolutional neural network to obtain a multi-view feature vector.
[0035] The spectral feature extraction module borrows from the SpectFormer architecture, utilizing a spectral module and attention mechanism to transform trajectory data into a frequency domain representation and extract key frequency domain features. This module comprises three main layers: a frequency domain layer, a self-attention layer, and a position attention layer. The frequency domain layer uses Fourier transform operations to map the time-domain signal of the trajectory to the frequency domain space to extract the trajectory's spectral features. This layer includes a Fast Fourier Transform (FFT) layer, a weighted gating layer, an Inverse Fourier Transform (IFFT) layer, and weight parameters. This determines the weight of each frequency component. The Fast Fourier Transform (FFT) layer then processes the input time-series signal. Convert to frequency domain signal The calculation formula is shown in formula (1); the weighted gating layer learns the importance of different frequency components by weighting each frequency component, and the weighted frequency domain signal is... The calculation formula is shown in formula (2); the inverse Fourier transform layer converts the weighted frequency domain signal back to the time domain, and the calculation formula is shown in formula (3).
[0036] (1) (2) (3) In the above formula, The input timing signal, For frequency domain signal representation, Represents time, Represents frequency, The weighted frequency domain signal The weights for the corresponding frequency components, This is the weighted timing signal.
[0037] The attention module includes a multi-head self-attention mechanism and a positional attention mechanism. The multi-head self-attention mechanism focuses on acquiring the phased changes of different transportation trips and the periodic characteristics of public transportation trips. Its core idea is to aggregate information by weighting the relationship between query (Q), key (K), and value (V). The calculation formula is shown in formula (4). It can concatenate the outputs of all heads and obtain the final output through linear transformation. For h attention heads, the calculation formula of the multi-head self-attention mechanism is shown in formula (5). The positional attention mechanism further enhances the feature extraction capability by capturing the positional dependencies of the trajectory sequence. By stacking multiple frequency domain layers and attention layers, and by using sine-cosine positional encoding to give positional information to the GPS trajectory points of the input trajectory sequence, it works in synergy with the attention mechanism to enhance the model's ability to capture positional relationships. For each time step t, the sine-cosine positional encoding... The calculation formula is shown in formula (6). Then the position attention mechanism will encode the... Combined with the query matrix Q and key matrix K in self-attention, the positional relationship weights of the segments within the trajectory are considered during calculation, as shown in formula (7). Finally, a combination of batch normalization layer, dropout layer, residual connection layer and fully connected layer (FC) is used in sequence to identify the mode of the fused features of the trajectory. The latent vector V after the fully connected layer is the latent feature representation of the input features, which is the input data of the sequence decoder.
[0038] (4) (5) (6) (7) In the above formula, For the output of the self-attention mechanism, Represents the query matrix, key matrix, and value matrix in a Transformer. For the dimension of the key, To attract attention, For the output of the multi-head self-attention mechanism, For the row-limited transformation matrix, For sine and cosine position encoding, For the hidden dimensions of the model, For the output of the position attention mechanism, is the input latent vector of the decoder.
[0039] Step S40: The sequence decoder captures the pattern of pedestrian mode switching based on the global feature vector through the Transformer multi-head attention mechanism, generates the probability distribution of pedestrian mode of travel, and outputs the identified pedestrian mode of travel sequence. The mode of travel sequence includes the latitude and longitude information, time information, feature information and identified mode of travel label information of the trajectory points.
[0040] The sequence decoder is responsible for joint inference and decision optimization. It employs a cascaded structure of Transformer and Conditional Random Field (CRF), comprising two core modules: a Transformer decoder layer and a CRF sequence constraint layer. The Transformer decoder layer further includes a multi-head attention mechanism module, a residual connection layer, a layer normalization module, a forward propagation layer, and a fully connected layer. The Transformer generates an initial travel mode probability distribution based on the multi-head attention mechanism. Simultaneously, to model the physical laws governing mode transitions, a CRF is introduced as a sequence labeling constraint layer. The transition probability matrix mitigates short-term jitter issues, further improving the accuracy of travel mode classification.
[0041] The Transformer decoder uses latent vectors As input, return a sequence In the network's structural design, a multi-head attention mechanism and residual connection layers are implemented. Layer normalization is used to normalize the network's hidden layers to a standard normal distribution. Linear mapping and ReLU activation are performed in the forward propagation layer, and then the probability sequence is obtained through fully connected layers and softmax layers. ,in This is a probability distribution vector of feature sequence i with shape 1×M, where M is the number of travel mode categories. After the Transformer decoder captures the contextual information of the trajectory sequence, the Conditional Random Field (CRF) captures the patterns of travel mode switching, improving the short-term jitter problem of trajectory labels. The output of the Transformer is used as emission scores, representing the score for each possible label at each time step. The transition scores of the CRF are the scores for transitioning from one label to the next. These two scores work together on the corresponding layer of the CRF, ultimately outputting a complete travel mode sequence that conforms to temporal logic.
[0042] Specifically, given a sequence of feature vectors V, the sequence The scoring function is calculated as shown in formula (8). This invention uses the softmax function to define a probability value for each correct travel mode sequence y, as shown in formula (9). The final training objective is to maximize the logarithmic probability value of the correct travel mode sequence, calculated as shown in formula (10). Gradient descent is used to optimize the neural network algorithm, and the highest-scoring sequence obtained after training is... The final identified travel mode sequence includes the latitude and longitude information of the trajectory points, time information, and the identified travel mode label information.
[0043] (8) (9) (10) In the above formula, The total score for the label sequence. The input feature vector, The sequence of travel mode labels to be predicted. The length of the label sequence. To transfer points, To score points for the launch, For label sequence The conditional probability, For the set of all possible label sequences, To score The indexation, For label sequence about The logarithmic probability.
[0044] In summary, this invention constructs a travel mode recognition model based on spectral feature extraction and attention mechanism enhancement, achieving accurate recognition of complex trajectory sequences. This method addresses the problems of existing technologies neglecting trajectory periodicity and temporal sequence, insufficient utilization of geospatial and temporal information, and over-reliance on or susceptibility to unreasonable transition points in multimodal travel processing. It fills the gap in existing technologies regarding insufficient consideration of traffic network environment and spatiotemporal dynamic factors. On one hand, it employs an encoder-decoder architecture to achieve complementary enhancement of time-frequency domain features, combined with a Transformer-CRF joint inference mechanism to constrain the rationality of the recognition sequence, overcoming the drawbacks of traditional segmented processing that loses temporal continuity and is prone to recognition gaps. On the other hand, it ensures the robustness and recognition accuracy of the model through a hierarchical data preprocessing mechanism and multi-source feature extraction methods, providing stable and reliable technical support for mode recognition in complex travel scenarios. This invention provides a systematic technical method for improving the accuracy of travel mode recognition based on trajectory data and enhancing the model's adaptability to diverse geographical environments and travel scenarios.
[0045] Previous studies have largely relied on time-domain feature modeling, failing to capture the periodic patterns of trajectories, such as the regular start-stop cycles of buses due to station stops, and the speed fluctuation cycles of various transportation modes. This makes it difficult to effectively distinguish travel modes with similar motion characteristics but significantly different periodicities. To address this issue, this invention designs a spectral feature encoding module. It maps the time-domain trajectory signal to the frequency domain using a Fast Fourier Transform (FFT) to mine the frequency energy distribution of different travel modes. Then, frequency-weighted gating is used to strengthen frequency components strongly correlated with travel modes and suppress noise frequencies. Finally, an inverse FFT is applied to return the signal to the time domain, achieving time-frequency complementarity and significantly improving the accuracy of distinguishing travel modes with similar motion patterns. Therefore, this invention has a wider range of applications.
[0046] This invention deeply integrates multi-scale spatiotemporal features with attention enhancement mechanisms, enabling it to capture local motion patterns at different scales and characterize global trajectory correlations, thus strengthening temporal and positional dependencies. In the sequence decoding stage, the Transformer layer generates a point-by-point travel mode probability distribution, and the Conditional Random Field layer introduces a travel mode transition matrix, suppressing short-term jitter and explicitly constraining unreasonable switching, thereby significantly improving distinguishability and robustness. At the same time, it ensures that the output sequence conforms to the logical laws of actual traffic behavior, providing a more reliable decision-making basis for traffic planning and travel services.
[0047] Those skilled in the art will understand that the accompanying drawings are merely schematic diagrams of one embodiment, and the modules or processes shown in the drawings are not necessarily essential for implementing the present invention.
[0048] As can be seen from the above description of the embodiments, those skilled in the art can clearly understand that the present invention can be implemented by means of software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in various embodiments or some parts of the embodiments of the present invention.
[0049] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, for apparatus or system embodiments, since they are basically similar to method embodiments, the description is relatively simple, and relevant parts can be referred to the description of the method embodiments. The apparatus and system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0050] The above description is merely a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A travel mode identification method based on spectral feature extraction and attention mechanism enhancement, characterized in that, include: A pedestrian travel mode recognition model is composed of a sequence encoder and a sequence decoder. Pedestrian trajectory data is acquired through positioning devices, and the trajectory data is then split to obtain the original trajectory sequence; Features are extracted from the original trajectory sequence and input into the sequence encoder. The sequence encoder extracts the spatial information of the original trajectory sequence through multi-scale convolutional layers to obtain multi-view local feature vectors. Then, the global feature vector after frequency domain enhancement and attention weighted fusion is output through the spectral feature extraction module. The sequence decoder captures the patterns of pedestrian mode switching based on the global feature vector through the Transformer multi-head attention mechanism and conditional random field, and outputs the identified pedestrian mode sequence, which includes the latitude and longitude information of the trajectory points, time information, and the identified mode label information.
2. The method according to claim 1, characterized in that, The pedestrian travel mode recognition model, consisting of a sequence encoder and a sequence decoder, includes: A travel mode recognition model is composed of a sequence encoder and a sequence decoder. The sequence encoder includes a multi-scale convolution module and a spectral feature encoding module. The multi-scale convolution module extracts local motion patterns at different time scales. The spectral feature encoding module explicitly enhances the rhythmic components caused by station stops and traffic congestion through fast Fourier transform, frequency weighted gating and inverse transform. The sequence decoder uses a Transformer to generate a point-by-point emission distribution and combines a conditional random field to constrain mode transitions, outputting a continuous and consistent travel mode sequence. Through complementary representations in the time and frequency domains and attention enhancement, the distinguishability of similar modes is improved, thus obtaining the pedestrian travel mode recognition result.
3. The method according to claim 1, characterized in that, The process of acquiring pedestrian trajectory data through a positioning device, splitting the trajectory data to obtain the original trajectory sequence includes: Pedestrian trajectory data is acquired through satellite positioning equipment. This trajectory data contains a time-stamped sequence of pedestrian spatial locations. The trajectory data is then divided into independent trips based on the time interval between adjacent points being greater than 20 minutes or the spatial distance being greater than 100 meters. Each trip is then divided into fixed-length travel segments. Segments that are not long enough are filled with zeros to form an original trajectory sequence of uniform length.
4. The method according to claim 3, characterized in that, The process involves extracting features from the original trajectory sequence, inputting these features into a sequence encoder, which then extracts spatial information from the original trajectory sequence through multi-scale convolutional layers to obtain multi-view local feature vectors. Finally, a spectral feature extraction module outputs a global feature vector after frequency domain enhancement and attention-weighted fusion, including: Features are extracted from the original trajectory sequence and input into the multi-scale convolution module in the sequence encoder. The multi-scale convolution module contains three parallel convolutional branches, a feature concatenation and activation layer, and a channel reduction convolutional layer. Different sizes of convolutional kernels are used in the same layer to capture contextual information of different ranges. The padding and stride parameters of the convolutional branches are adjusted to control the spatial resolution and coverage of the feature map. Multiple convolutional layers are stacked to gradually integrate information from local features to global features and output multi-view local feature vectors. The multi-view local feature vectors are then input into the spectral feature extraction module. The multi-view local feature vector includes a frequency domain layer and an attention mechanism layer. The frequency domain layer uses Fourier transform operations to map the time-domain signal in the multi-view local feature vector to the frequency domain space, extracting trajectory spectral features. The frequency domain layer includes a fast Fourier transform layer, a weighted gating layer, and an inverse Fourier transform layer. The fast Fourier transform layer processes the input time-series signal... Convert to frequency domain signal The calculation formula is shown in formula (1); the weighted gating layer learns the importance of different frequency components by weighting each frequency component, and obtains the weighted frequency domain signal as follows. The calculation formula is shown in formula (2); the inverse Fourier transform layer converts the weighted frequency domain signal back to the time domain, and the calculation formula is shown in formula (3). (1) (2) (3) In the above formula, The input timing signal, For frequency domain signal representation, Represents time, Represents frequency, The weighted frequency domain signal The weights for the corresponding frequency components, The weighted timing signal; The attention mechanism layer includes a multi-head self-attention mechanism and a positional attention mechanism. The multi-head self-attention mechanism focuses on acquiring the phased changes of different traffic trips and the periodic characteristics of public transportation trips. It aggregates information by weighting the relationship between queries (Q), keys (K), and values (V). The calculation formula is shown in formula (4). The outputs of all heads are concatenated and the final output is obtained through linear transformation. For h attention heads, the calculation formula of the multi-head self-attention mechanism is shown in formula (5). The positional attention mechanism uses sine and cosine position encoding for each time step t. The calculation formula is shown in formula (6). The position attention mechanism will encode... Combined with the query matrix Q and key matrix K in self-attention, the calculation formula is shown in formula (7). The combination of batch normalization layer, discard layer, residual connection layer and fully connected layer is used in sequence to identify the fusion features of the trajectory. (4) (5) (6) (7) In the above formula, For the output of the self-attention mechanism, Represents the query matrix, key matrix, and value matrix in a Transformer. For the dimension of the key, To attract attention, For the output of the multi-head self-attention mechanism, For the row-limited transformation matrix, For sine and cosine position encoding, For the hidden dimensions of the model, For the output of the position attention mechanism, is the input latent vector of the decoder.
5. The method according to claim 4, characterized in that, The sequence decoder uses a Transformer to generate a pointwise emission distribution and combines a Conditional Random Field to constrain mode transitions, outputting a continuous and consistent travel mode sequence. Through complementary representations in the time and frequency domains and attention enhancement, the distinguishability of similar modes is improved, resulting in pedestrian travel mode recognition results, including: The sequence decoder comprises a Transformer decoder layer and a Conditional Random Field (CRF) sequence constraint layer. The Transformer decoder layer includes a multi-head attention mechanism module, a residual connection layer, a layer normalization module, a forward propagation layer, and a fully connected layer. The Transformer decoder uses global feature vectors. As input, return a sequence Layer normalization is used to normalize the hidden layers of the network to a standard normal distribution. Linear mapping is performed in the forward propagation layer and ReLU activation is used. The probability sequence is obtained through fully connected layers and softmax layers. ,in It is a feature sequence of shape 1×M The probability distribution vector is M, which is the number of travel mode categories. The output of the Transformer decoder is used as the emission score, which represents the score of each possible label at each time step. The transition score of the Conditional Random Field is the score of transitioning from one label to the next label. These two scores work together on the corresponding layer of the Conditional Random Field to output a complete travel mode sequence that conforms to temporal logic. Given a global feature vector V, the sequence The scoring function is calculated as shown in formula (8). A probability value is defined for each correct travel mode label sequence y using the softmax function, as shown in formula (9). The training objective is to maximize the log probability value of the correct travel mode sequence, calculated as shown in formula (10). The gradient descent method is used to learn and optimize the neural network algorithm. The highest-scoring sequence is obtained after training. As the final identified travel mode sequence, the sequence It includes the latitude and longitude information of the trajectory points, time information, and the identified travel mode label information; (8) (9) (10) In the above formula, The total score for the label sequence. The input feature vector, The sequence of travel mode labels to be predicted. The length of the label sequence. To transfer points, To score points for the launch, For label sequence The conditional probability, For the set of all possible label sequences, To score The indexation, For label sequence about The logarithmic probability.