Transform-based passenger flow prediction method and device

Through the improved Transformer model, combining sharding processing and external information data, the existing passenger flow prediction methods have solved the problems of low accuracy and high computational complexity in emergencies, and achieved more efficient and accurate passenger flow prediction , reduces processing costs.

CN119204104APending Publication Date: 2024-12-27NORTHWEST UNIV
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411125103.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-16
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

The existing passenger flow prediction methods have low accuracy in emergencies, high computational complexity and processing costs, and it is difficult to make predictions and judgments in a timely and accurate manner.

Method used

Using Transformer-based passenger flow prediction method, historical passenger flow data is processed through sharding data processing and linear projection, combined with external information data, One-Hot encoding and linear layer and activation function are used to build a position encoder, and the multi-head self-attention mechanism is used and The feedforward neural network extracts deep features and outputs passenger flow prediction results through the two-dimensional convolutional layer.

Benefits of technology

It improves the accuracy and processing efficiency of passenger flow forecasting, enhances the ability to respond in emergencies, reduces processing costs, and provides higher-precision passenger flow forecasting results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119204104A_ABST
    Figure CN119204104A_ABST
Patent Text Reader

Abstract

The invention discloses a passenger flow prediction method and device based on Transform, and relates to the technical field of traffic flow prediction. The method comprises the following steps: acquiring historical passenger flow data and external information data; the method comprises the following steps: encoding external information data to obtain an external information vector, performing fragmentation processing on historical passenger flow data to obtain fragmented data, performing linear projection on the fragmented data, and fusing the fragmented data with the external information data to obtain fusion features; a position encoder is constructed for a Transform encoding layer so that a Transform model can understand the time sequence of the input data, and deep features of the fusion features are extracted based on the Transform model; and decoding the deep features by using a two-dimensional convolutional layer, and outputting a passenger flow prediction result. According to the method, passenger flow prediction judgment can be made timely and accurately in the face of sudden traffic conditions caused by various human influence factors and natural force majeure factors.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of traffic flow prediction, and in particular to a method and device for passenger flow prediction based on Transformer. Background Art

[0002] In the modern urban transportation system, transportation stations (such as railway stations, bus stations and airports) are key nodes connecting the city with the outside world. For these stations, there are many factors that affect passenger flow. Especially in the face of emergencies such as influenza epidemics and natural disasters, the suddenness and irregularity of passenger flow pose challenges to the emergency response capabilities of transportation stations. Due to the rapid growth of the scale of transportation stations and the increasing demand for transportation station management, there are currently a variety of passenger flow prediction systems. Although they have improved operational efficiency to a certain extent, they are still not perfect.

[0003] Subway passenger flow is highly time-dependent, and recurrent neural networks (RNNs) and their famous variants, namely long short-term memory (LSTM) and gated recurrent units (GRUs), are widely used to mine its time-varying dynamics. At the same time, in order to improve the prediction performance under abnormally large passenger flows, Zheng et al. applied complex network theory to collective behavior modeling and subsequently proposed a hybrid model to capture the time-varying characteristics of passenger flow. In addition, WaveNet for sound synthesis and Transformer for natural language processing can be used for long-term passenger flow prediction due to their far receptive fields. Existing research proposes a multi-task learning method based on residual networks and Transformers to predict short-term passenger flows for multiple modes of transportation. Extensive research has been conducted on the passenger flow prediction problem, adding multiple modes of transportation and using hybrid models to capture time-varying characteristics, but this does not solve the problem of low passenger flow prediction accuracy.

[0004] The computational complexity of Transformer, namely the computational time and memory usage in practical applications, is still a bottleneck. It is not possible to make timely and accurate predictions of traffic emergencies, and it also increases the technical processing costs. Summary of the invention

[0005] The embodiment of the present application solves the problem of low accuracy of passenger flow prediction methods in the prior art by providing a Transformer-based passenger flow prediction method and device, and improves the ability of passenger flow prediction methods to respond to sudden emergencies. The historical passenger flow data is processed by sliced ​​data processing and linear projection, and the external information data is processed with the help of One-Hot encoding. The linear layer and activation function are used to obtain fusion features after merging the historical passenger flow data and the external information data, and the Transformer model is improved to improve the accuracy of passenger flow prediction under human influence and natural force majeure factors, helping managers to make decisions quickly and efficiently, and bringing users a reasonable and comfortable travel experience.

[0006] In the first aspect, an embodiment of the present application provides a Transformer-based passenger flow prediction method and device, including: obtaining historical passenger flow data and external information data; wherein the historical passenger flow data includes the inbound flow, outbound flow, boarding volume and alighting volume of passengers at each station within a set time interval obtained in sequence; the external information data includes weather data and date data; encoding the external information data to obtain an external information vector, slicing the historical passenger flow data to obtain slicing data, linearly projecting the slicing data and fusing it with the external information data to obtain fused features; constructing a position encoder for the Transformer encoding layer so that the Transformer model understands the time sequence of the input data, and extracting deep features of the fused features based on the Transformer model; using a two-dimensional convolutional layer to decode the deep features, and outputting the passenger flow prediction results.

[0007] In a possible implementation, encoding the external information data to obtain an external information vector includes: using One-Hot coding to convert the weather data and the corresponding date data in the external information data into binary to obtain the external information vector.

[0008] In a possible implementation, the slicing the historical passenger flow data to obtain the slicing data includes: slicing the historical passenger flow data according to a slicing formula to obtain the slicing data; wherein the slicing formula is as follows: ; In the formula, Indicates the total number of shards of the shard data, represents the total length of the historical passenger flow data, represents the fragment length of the fragment data, Indicates the step length.

[0009] In a possible implementation, the slicing of the historical passenger flow data to obtain slicing data further includes: if the total length of the historical passenger flow data is not an integer multiple of the step length, using the last data point in the last slicing data to fill the slicing data to reach the slicing length.

[0010] In a possible implementation, obtaining the fusion feature includes: converting the external information data through a linear layer and an activation function, and merging the external information data with the sliced ​​data and inputting the resultant data into a Transformer model.

[0011] In a possible implementation, before constructing a position encoder for the Transformer encoding layer so that the Transformer model understands the time sequence of the input data, it also includes: adding a position code to each of the sliced ​​data to maintain the position information of the sliced ​​data.

[0012] In one possible implementation, constructing a position encoder for the Transformer encoding layer so that the Transformer model understands the temporal order of input data includes: constructing a multi-layer encoder and stacking them in sequence; wherein each layer of the multi-layer encoder includes a multi-head self-attention mechanism and a feedforward neural network.

[0013] In a possible implementation, the deep features of the fused features are extracted based on the Transformer model, including: using a linear projection matrix and a position encoding matrix to execute a multi-head self-attention mechanism in the Transformer encoding layer to mine the temporal dependencies between them; using the feedforward neural network to process the output of each layer of the encoder, and then performing residual connection and layer normalization processing; wherein the output of each layer of the Transformer encoding layer is used as the input of the next layer and stacked sequentially to train the Transformer model's data processing capabilities and understanding depth.

[0014] In a possible implementation, the decoding of the deep features using a two-dimensional convolutional layer includes: using a filter of the two-dimensional convolutional layer to scan the output data of the Transformer encoding layer and decoding it to obtain decoded data; extracting and identifying spatial features of the decoded data to obtain the passenger flow prediction result.

[0015] In the second aspect, an embodiment of the present application provides a Transformer-based passenger flow prediction device, including: a data storage module, used to obtain historical passenger flow data and external information data; wherein the historical passenger flow data includes the inbound flow, outbound flow, boarding volume and alighting volume of passengers at each station within a set time interval obtained in sequence; the external information data includes weather data and date data; a data processing module, used to encode the external information data to obtain an external information vector, slice the historical passenger flow data to obtain slice data, linearly project the slice data and fuse it with the external information data to obtain a fused feature; an encoding module, used to construct a position encoder for the Transformer encoding layer so that the Transformer model understands the time sequence of the input data, and extracts the deep features of the fused features based on the Transformer model; a decoding module, used to decode the deep features using a two-dimensional convolutional layer, and output the passenger flow prediction result.

[0016] One or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages: The embodiment of the present application adopts an improved Transformer passenger flow prediction method, introduces external information data into the original data, and uses One-Hot for encoding to enrich the original data features. By using sharding processing, continuous time steps are aggregated into subsequence-level "patches", so that the Transformer model can capture local semantic information that a single time point cannot provide, enhance the expressiveness of the data, effectively solve the problem of low passenger flow prediction accuracy, improve the efficiency of processing external information data and historical passenger flow data, and the ability of the Transformer model to learn complex patterns, thereby achieving a higher accuracy prediction of passenger flow conditions and reducing processing costs. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0018] Figure 1 A flowchart of a Transformer-based passenger flow prediction method provided in an embodiment of the present application; Figure 2 A flowchart illustrating the process of the Transformer passenger flow prediction method provided in an embodiment of the present application; Figure 3A comparison chart of the prediction performance of the Transformer passenger flow prediction method provided in the embodiment of the present application; Figure 4 A passenger flow prediction result diagram of the HZMetro Hangzhou subway dataset provided in an embodiment of the present application; Figure 5 A passenger flow prediction result diagram of the SHMetro Shanghai Metro dataset provided in the embodiment of the present application; Figure 6 This is a diagram of the ablation experiment results of the HZMetro Hangzhou subway dataset provided in the embodiment of the present application; Figure 7 A schematic diagram of the structure of a Transformer-based passenger flow prediction device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0019] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are 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 creative work are within the scope of protection of the present invention.

[0020] The following describes some of the techniques involved in the embodiments of the present application to facilitate understanding, and they should be considered as merely exemplary. Therefore, it should be appreciated by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, for the sake of clarity and conciseness, some descriptions of well-known functions and structures are omitted in the following description.

[0021] The embodiment of the present application proposes a Transformer-based passenger flow prediction method, which collects data on factors affecting passenger flow prediction at transportation stations, uses sharded data to process historical passenger flow data, enhances the Transformer model's ability to understand historical passenger flow data, uses a multi-head self-attention mechanism to add a position encoder, effectively captures the dependency between data in different time periods, uses a two-dimensional convolutional network to output the final passenger flow prediction results, and constructs an improved Transformer passenger flow prediction framework. The passenger flow prediction effect is verified on the data set using deep learning to optimize the Transformer model prediction results.

[0022] Figure 1 It is a flowchart of a Transformer-based passenger flow prediction method provided in an embodiment of the present application, including steps 101 to 104. Figure 1This is only an execution order shown in the embodiment of the present application, and does not represent the only execution order of the passenger flow prediction method based on Transformer. If the final result can be achieved, Figure 1 The steps shown may be performed in parallel or in reverse, as follows.

[0023] Step 101: Obtain historical passenger flow data and external information data. In an embodiment of the present application, historical passenger flow data includes, but is not limited to, the inbound flow, outbound flow, boarding and alighting volume of passengers at each station within a set time interval. External information data includes weather data and date data. Specifically, the historical passenger flow data is acquired and stored in sequence in chronological order, and statistics are performed with 15 minutes as the historical time step. The present application exemplarily collects relevant external information data on a weather website, and weather data includes factors such as weather conditions, temperature, humidity, rainfall, wind speed, etc.; date data includes date types such as weekdays, weekends, holidays, and special events such as large-scale events and public holidays.

[0024] Step 102: Encode the external information data to obtain an external information vector, slice the historical passenger flow data to obtain slice data, perform linear projection on the slice data and fuse it with the external information data to obtain a fusion feature. Figure 2 As shown, this application uses One-Hot encoding to process external information data, and then passes through two linear layers and a The activation function is used to process the converted data, and the converted data is suitable for merging with the historical passenger flow data after sharding. For weather data, assume that there are n different weather conditions, including sunny, rainy, snowy, etc. Each condition is converted into a corresponding binary vector. For example, when the weather condition is "rainy", the first state, then the corresponding One-Hot encoding elements are set to 1, and the rest are set to 0. For date data, Monday to Sunday are converted into corresponding One-Hot encoded 7-dimensional binary vectors. One-Hot encoding can be expressed as follows: ; In the formula, Represents the external information vector obtained by binary One-Hot encoding of the external information data. Indicates a specific weather or date category, Indicates the specific state of a particular weather or date. Represents the position of 1 in a binary vector.

[0025] In the Transformer embedding layer, the historical passenger flow data is segmented according to the segmentation formula, where the segmentation formula is as follows: ; ; In the formula, Indicates the total number of shards for sharded data. Indicates rounding down. Indicates the total length of historical passenger flow data, Indicates the custom segment length according to the segment data. represents the step length, Indicates the shard data obtained by shard processing. Indicates The shard data obtained by sharding the historical passenger flow data is Indicates the number of historical passenger flow data The value corresponding to the point in the slice data, The historical passenger flow data The first Points, Indicates the number of shards in the historical passenger flow data. 2 Points, , Respectively represent the fragmented data of historical passenger flow data , Points, In the shard data representing historical passenger flow data points.

[0026] Among them, the fragment length is customized according to the fragment data and step length , split each slice from the historical passenger flow data, split the input single variable historical passenger flow data into multiple overlapping or non-overlapping slices, and the slice length Defines the number of consecutive data points contained in each shard. If the total length of historical passenger flow data is Not step length If the value is an integer multiple of , the last data point in the last shard is used for padding. A trainable linear projection is applied to each generated shard to map it to a higher-dimensional feature space. By using independent channel processing and adding sharding processing to the processing of historical passenger flow data, the Transformer model can capture local patterns and features in the data more carefully, and improve the embedding layer. At the same time, it also reduces the consumption of computing resources. Specifically, the time complexity and space complexity can be expressed as: , where L Indicates the total length of historical passenger flow data, S Indicates the step length.

[0027] The processed historical passenger flow data is combined with the external information data to obtain the fusion features, as follows: ; In the formula, represents the fusion feature, Indicates the operation of splicing historical passenger flow data with external information data. The weights of the first linear layer representing the external information data, represents the bias of the first linear layer, The weights of the second linear layer representing the external information data, represents the bias of the second linear layer, Represents the external information vector obtained by One-Hot encoding, represents the activation function of the external information vector, Represents the historical passenger flow data obtained through sharding data processing. Among them, the fusion feature As the input feature of the Transformer model, compared with the channel mixing method of the existing Transformer model, channel independent processing processes different variables separately and then splices them together along the dimension direction, so as to better capture the characteristics of external information data and historical passenger flow data and prevent the problem of overfitting of the Transformer model.

[0028] Step 103: Construct a position encoder for the Transformer encoding layer to enable the Transformer model to understand the temporal order of the input data, and extract deep features of the fused features based on the Transformer model.

[0029] The traditional Transformer model adopts a multi-head self-attention mechanism and usually does not directly rely on the order of elements. It uses parallel computing to independently calculate the position of each element in the input historical passenger flow data and its relationship with the positions of other elements. Although it avoids the large time cost of recurrent neural networks (RNNs), it can also capture longer dependencies and periodic changes in sentences and directly calculate the relationship between any two points. However, when feature elements pass through the Transformer encoder and decoder stacks at the same time, the Transformer model itself does not have any position information for each feature element. In practical applications, this may affect the behavior of the Transformer model.

[0030] In the embodiment of the present application, position coding is added to each shard data to maintain the position order of the historical passenger flow data, a multi-layer Transformer encoder is constructed, and a multi-head self-attention mechanism is used to comprehensively analyze the historical passenger flow data of different time and space to extract the deep features of the historical passenger flow data, as follows: Initialize the input features using the linear projection matrix and the position encoding matrix, perform a multi-head self-attention mechanism in each Transformer encoding layer, and generate queries ,key ,value Matrix, according to , , Matrix to calculate attention scores.

[0031] The output of each encoder layer is subjected to residual connection and layer normalization operations using a feedforward neural network. Each encoder layer contains a multi-head self-attention mechanism and a feedforward neural network. The encoder layers are stacked sequentially to increase the Transformer model's data processing capabilities and understanding depth layer by layer. Inter-layer connections, normalization, and feedforward neural networks are constructed. After each multi-head self-attention module and feedforward neural network, residual connections and layer normalization are used to further process and refine the features obtained from the multi-head self-attention mechanism, enhancing the Transformer model's ability to express features.

[0032] For the output data of the embedding layer, the position encoding operation can be expressed as: , , ; In the formula, represents the positional encoding of the output features of the embedding layer, represents the output of the embedding layer, represents the position encoding matrix, represents the position of the time step, represents the dimension index, Represents the dimension of the Transformer model position encoding vector. The position encoding uses sine and cosine functions alternately for combined calculations. Due to the different frequencies of different dimensions, the position encoding is the position information of each time step in the historical passenger flow data provided by the Transformer model, allowing the Transformer model to learn the temporal relationship of the input features.

[0033] In the multi-head self-attention mechanism, the position of the output feature of the embedding layer is encoded Mapped to the query matrix through different linear layers , which can be expressed as: , , ; In the formula, represents the query matrix, represents the key matrix, represents the value matrix, represents the positional encoding of the output features of the embedding layer, express The weight matrix of the matrix, express The weight matrix of the key matrix, express The weight matrix of the value matrix.

[0034] The calculation of multi-head self-attention and each head can be expressed as: , ;in, ; In the formula, represents the attention score, express Activation function, represents the multi-head self-attention output, Indicates The number of heads for multi-head self-attention, Representation Matrix , The number of columns is to prevent The restriction condition that the inner product is too large, Represents a splicing operation, represents the output weight matrix. Among them, The function can be used to normalize the original calculated scores into a probability distribution where the sum of all element weights is 1. On the other hand, The internal mechanism of the activation function emphasizes the weights of important elements.

[0035] The feedforward neural network layer is represented as: , ; In the formula, Representation layer normalization, Indicates with ReLU The sequence of fully connected layers with activation functions, , , Represent the weights of the first, second, and third linear layers of the activation function, respectively. , , Represent the bias of the first, second, and third linear layers respectively, represents the multi-head self-attention output, , represents the set of all real numbers, Indicates the length of historical passenger flow data, Represents the dimension of the Transformer model position encoding vector.

[0036] The final Transformer encoding layer output is obtained through layer normalization operation, which can be expressed as: ; In the formula, Representation layer normalization, express The mean of express The standard deviation of represents the learnable parameters, Indicates the amount of re-displaceable offset.

[0037] Step 104: Use a two-dimensional convolutional layer to decode the deep features and output the passenger flow prediction result.

[0038] The block output obtained after the Transformer encoder layer is in a high-dimensional space. The two-dimensional convolution is used for decoding in the output layer, so that the Transformer model can perform feature conversion without significantly increasing the number of parameters. While processing high-dimensional data, the spatiotemporal structure of the input data is retained to obtain the final passenger flow prediction result. The output of the two-dimensional convolution can be expressed as: ; In the formula, represents the output of the two-dimensional convolution, represents a two-dimensional convolution operation, represents the output of the Transformer encoder layer, represents the output of the weight, Represents the output of the bias. Among them, the two-dimensional convolution not only helps the Transformer model better understand the spatial structure of the input data, but also improves the efficiency of data processing through the sharing characteristics of its parameters. Although channel independence regards dimensions as independent, weights and biases are shareable in each dimension.

[0039] The passenger flow prediction results of the output layer of the Transformer model are verified and analyzed and evaluated from multiple angles. The prediction problem is defined as follows: ; In the formula, represents the passenger flow data predicted for future time steps, Represents the method model to be learned during training, represents the historical passenger flow data under the historical time step, Represents external information data at historical time steps.

[0040] In an embodiment of the present application, a real data set is used to train a method model to verify the predictive performance of the Transformer model, wherein the method model is built on an NVIDIA 4080 GPU (a high-end graphics card of NVIDIA) using Pytorch1.9.1 (a version of a deep learning framework), using Adam (an optimization algorithm) as the optimizer, and setting the learning rate to 0.001, the batch size to 8, and the hidden dimension to 256. In addition, a learning rate decay and early termination strategy are used to avoid overfitting.

[0041] The datasets include HZMetro (Hangzhou Metro) and SHMetro (Shanghai Metro). The specific descriptions are shown in Table 1: Table 1 Dataset comparison table

[0042] In Table 1, Dataset represents the dataset, City represents the city where the data is collected, Station represents the number of stations in the subway station, Time Interval represents the time interval taken by the experiment, Training Timespan represents the time interval of the training dataset, Validation Timespan represents the time interval of the validation dataset, and Testing Timespan represents the time interval of the testing dataset.

[0043] The Transformer model is evaluated using a full range of error statistics for the training set data, as follows: , , , ; In the formula, represents the mean square error, represents the mean absolute error, represents the mean absolute percentage error, represents the root mean square error, represents the true value, represents the predicted value, represents the number of all predicted values. Can be used as the loss function of the Transformer model, , , It can be used as an evaluation indicator for the prediction effect of the Transformer model.

[0044] The prediction effects of the Transformer model and the baseline model are compared on the dataset. For the prediction performance comparison, see Table 2 and Table 3. The last column is the prediction performance of the Transformer model method. The bold items indicate the best prediction performance of the model at this time step, and the underlined items indicate the suboptimal performance of the model at this time step. Tables 2 and 3 show the comparison of the prediction performance of different models in the HZMetro Hangzhou subway dataset and the SHMetro Shanghai subway dataset, respectively.

[0045] Table 2 Comparison of prediction performance of Transformer model and baseline model on HZMetro Hangzhou subway dataset

[0046] Table 3 Comparison of prediction performance of Transformer model and baseline model on SHMetro Shanghai subway dataset

[0047] In Tables 2 and 3, Metric represents the statistical classification of algorithm errors, ASTGCN represents that the model improves the accuracy of spatial-temporal network data prediction by designing a model to simultaneously capture complex spatial-temporal correlations and consider the heterogeneity in spatial-temporal data. VTransformer represents that the long-distance dependencies in traffic flow data are captured through the self-attention mechanism to improve the prediction accuracy. Informer represents that the model improves the efficiency and accuracy of long-sequence historical passenger flow data prediction by improving the traditional Transformer model. DLinear represents that the model is compared with a simple linear model and finds that the latter performs better on multiple data sets, challenging the application of the Transformer model in this field. PatchTST represents that the model significantly improves the accuracy and efficiency of long-term prediction of multivariate historical passenger flow data through sharding processing and channel independent design. iTransformer represents that the model captures multivariate correlations and learns passenger flow representation by applying attention and feedforward networks on the variable dimension, which significantly improves the prediction performance and model generalization ability. PatchFlow represents that the model can generate high-quality completion results based on sharding processing, which is the final result representation of the prediction performance.

[0048] Through the test results of different data sets, the best results were achieved in multiple evaluation indicators of the two data sets, showing that the Transformer model has good generalization ability. MAE They are 46.27 and 50.60 respectively. MAPE They are 32.87 and 56.70 respectively. RMSE In the embodiment of the present application, a comparison chart of the prediction performance of the passenger flow prediction method of Transformer is also provided, such as Figure 3 As shown in the figure, the horizontal axis represents time. The Transformer model obtains data at 15 minutes, 30 minutes, 45 minutes and 60 minutes on the HZMetro Hangzhou Metro and SHMetro Shanghai Metro datasets respectively. The vertical axis represents the error comparison. Mean absolute error, (%) Mean absolute percentage error, The root mean square error is used to compare and analyze the performance of the prediction results made for each data set. Figure 4 and Figure 5 These are the passenger flow prediction results of the HZMetro Hangzhou Metro and SHMetro Shanghai Metro datasets. Figure 4 The results shown in the figure are the passenger flow prediction results of the 56th station of the HZMetro Hangzhou Metro dataset. The horizontal axis represents time, the vertical axis represents passenger flow, and the ground truth represents the actual passenger flow of the 56th station. Figure 5 The results shown in the figure are the passenger flow prediction results of the third station of the SHMetro Shanghai Metro dataset, and the ground truth represents the actual passenger flow of the third station.

[0049] The influence of the Transformer model structure on the prediction accuracy is further studied through ablation experiments. The control variable method is used to keep part of the structure of the Transformer model unchanged. In the embodiment of the present application, the ablation experiment results of the HZMetro Hangzhou subway data set are shown in the figure below. Figure 6 As shown, the horizontal axis represents the time interval, and the vertical axis represents the error comparison. The specific experimental settings are as follows: Table 4 Ablation experiment results

[0050] In Table 4, Model name indicates the name of the benchmark model. Indicates the model that removes the sharding operation and external information data in the Transformer model. Represents a model with the two-dimensional convolutional module in the Transformer model removed. Indicates that no processing is done on the Transformer model. The results show that the proposed Transformer model has good prediction performance and robustness, and can provide strong support for the practical application of passenger flow prediction in transportation stations.

[0051] Although the present application provides method operation steps as described in the embodiments or flowcharts, more or fewer operation steps may be included based on conventional or non-creative labor. The order of steps listed in this embodiment is only one way of executing the order of many steps and does not represent the only execution order. When the actual device or client product is executed, it can be executed in sequence or in parallel according to the method shown in this embodiment or the accompanying drawings (for example, in a parallel processor or multi-threaded processing environment).

[0052] like Figure 7 As shown, the embodiment of the present application also provides a Transformer-based passenger flow prediction device 700. The device includes: a data storage module 701, a data processing module 702, an encoding module 703, and a decoding module 704, as follows.

[0053] The data storage module 701 is used to obtain historical passenger flow data and external information data; wherein the historical passenger flow data includes the inbound flow, outbound flow, boarding volume and alighting volume of passengers at each station within a set time interval obtained in sequence; the external information data includes weather data and date data; The data processing module 702 is used to encode the external information data to obtain an external information vector, slice the historical passenger flow data to obtain slice data, perform linear projection on the slice data and fuse it with the external information data to obtain a fusion feature; The encoding module 703 is used to construct a position encoder for the Transformer encoding layer so that the Transformer model understands the time sequence of the input data, and extracts deep features of the fused features based on the Transformer model; The decoding module 704 is used to decode the deep features using a two-dimensional convolutional layer and output the passenger flow prediction result.

[0054] Some modules in the apparatus described in the present application can be described in the general context of computer executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, classes, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.

[0055] The devices or modules described in the above application embodiments can be implemented by computer chips or entities, or by products with certain functions. For the convenience of description, the above devices are described in various modules according to their functions. When implementing the embodiments of the present application, the functions of each module can be implemented in the same or multiple software and / or hardware. Of course, the module that implements a certain function can also be implemented by combining multiple sub-modules or sub-units.

[0056] The methods, devices or modules described in this application can be implemented in the form of computer-readable program codes. The controller can be implemented in any appropriate manner. For example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program codes (such as software or firmware) that can be executed by the (micro)processor, logic gates, switches, application-specific integrated circuits (English: Application Specific Integrated Circuit; Abbreviation: ASIC), programmable logic controllers and embedded microcontrollers. Examples of controllers include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20 and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in the form of pure computer-readable program codes, the controller can be implemented in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers and embedded microcontrollers by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included in it for implementing various functions can also be regarded as structures within the hardware component. Or even, the means for realizing various functions may be regarded as both a software module for realizing the method and a structure within a hardware component.

[0057] In addition, each functional module in each embodiment of the present invention may be integrated into one processing module, or each module may exist independently, or two or more modules may be integrated into one module.

[0058] The above storage media include but are not limited to random access memory (RAM), read-only memory (ROM), cache, hard disk drive (HDD) or memory card. The memory can be used to store computer program instructions.

[0059] It can be seen from the description of the above implementation methods that those skilled in the art can clearly understand that the present application can be implemented by means of software plus necessary hardware. Based on this understanding, the technical solution of the present application can be essentially or partly reflected in the prior art in the form of a software product, or it can be reflected in the implementation process of data migration. The computer software product can be stored in a storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a mobile terminal, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present application or certain parts of the embodiments.

[0060] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. All or part of this application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld devices or portable devices, tablet devices, mobile communication terminals, multi-processor systems, microprocessor-based systems, programmable electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc.

[0061] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit the present application. Although the present application has been described in detail with reference to the aforementioned embodiments, a person of ordinary skill in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some or all of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the present application.

Claims

1. A passenger flow prediction method based on Transformer, characterized in that: include: Acquire historical passenger flow data and external information data; wherein the historical passenger flow data includes the inbound flow, outbound flow, boarding volume and alighting volume of passengers at each station within a set time interval acquired in sequence; the external information data includes weather data and date data; Encoding the external information data to obtain an external information vector, slicing the historical passenger flow data to obtain slicing data, and linearly projecting the slicing data and fusing it with the external information data to obtain a fusion feature; Constructing a position encoder for the Transformer encoding layer to enable the Transformer model to understand the temporal order of the input data, and extracting deep features of the fused features based on the Transformer model; The deep features are decoded using a two-dimensional convolutional layer to output passenger flow prediction results.

2. The method according to claim 1, characterized in that The encoding of the external information data to obtain the external information vector includes: using One-Hot encoding to convert the weather data in the external information data and the corresponding date data into binary to obtain the external information vector.

3. The method according to claim 1, characterized in that The slicing process of the historical passenger flow data to obtain slicing data includes: The historical passenger flow data is sliced ​​according to a slicing formula to obtain the slicing data; wherein the slicing formula is as follows: ; In the formula, Indicates the total number of shards of the shard data, represents the total length of the historical passenger flow data, represents the fragment length of the fragment data, Indicates the step length.

4. The method according to claim 3, characterized in that The slicing process of the historical passenger flow data to obtain the slicing data also includes: If the total length of the historical passenger flow data is not an integer multiple of the step length, the last data point in the last slice data is used to fill the slice data to make it reach the slice length.

5. The method according to claim 1, characterized in that The obtaining of the fusion features includes: converting the external information data through a linear layer and an activation function, and merging the external information data with the sliced ​​data and then inputting the data into a Transformer model.

6. The method according to claim 1, characterized in that Before constructing a position encoder for the Transformer encoding layer so that the Transformer model understands the temporal order of the input data, it also includes: A position code is added to each of the slice data to maintain the position information of the slice data.

7. The method according to claim 1, characterized in that The construction of a position encoder for the Transformer encoding layer enables the Transformer model to understand the temporal order of the input data, including: A multi-layer encoder is constructed and stacked sequentially; wherein each layer of the multi-layer encoder includes a multi-head self-attention mechanism and a feedforward neural network.

8. The method according to claim 1, characterized in that The extracting the deep features of the fusion features based on the Transformer model includes: Using the linear projection matrix and the position encoding matrix, a multi-head self-attention mechanism is implemented in the Transformer encoding layer to mine the temporal dependencies between them; The output of each layer of encoder is processed using the feedforward neural network, and then residual connection and layer normalization are performed; wherein the output of each layer of the Transformer encoding layer is used as the input of the next layer and stacked sequentially, so as to train the Transformer model's data processing capability and understanding depth.

9. The method according to claim 1, characterized in that: The step of decoding the deep features by using a two-dimensional convolutional layer includes: Scan the output data of the Transformer encoding layer using the filter of the two-dimensional convolutional layer and decode it to obtain decoded data; The spatial features of the decoded data are extracted and identified to obtain the passenger flow prediction result.

10. A device for passenger flow prediction based on Transformer, characterized in that: include: A data storage module, used to obtain historical passenger flow data and external information data; wherein the historical passenger flow data includes the inbound flow, outbound flow, boarding volume and alighting volume of passengers at each station within a set time interval obtained in sequence; the external information data includes weather data and date data; A data processing module, used for encoding the external information data to obtain an external information vector, performing slicing processing on the historical passenger flow data to obtain slicing data, and performing linear projection on the slicing data and fusing it with the external information data to obtain a fusion feature; An encoding module, configured to construct a position encoder for a Transformer encoding layer so that the Transformer model understands the temporal order of input data, and extract deep features of the fused features based on the Transformer model; The decoding module is used to decode the deep features using a two-dimensional convolutional layer and output a passenger flow prediction result.

Citation Information

Cited By

  • Scenic spot passenger flow volume prediction method based on multi-source information fusion

    CN120822673A