A subway short-time in-out station passenger flow prediction method and system based on contrast learning

CN122965735APending Publication Date: 2026-10-23CRSC RESEARCH & DESIGN INSTITUTE GROUP CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610929377.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-25
Publication Date
2026-10-23

AI Technical Summary

Technical Problem

[0003]现有技术(如ConvLSTM、STGCN等深度预测模型)大多针对常规场景,在异常场景下面临固有缺陷:第一,异常事件发生频次低,样本稀疏,模型复杂度过高易导致过拟合;第二,异常扰动破坏客流的日周期、周周期规律及线路间关联特征,加大模型拟合难度;第三,不同异常场景(如活动聚集与封站绕行)的时空演化模式差异显著,单一模型特征迁移与泛化能力不足;第四,无法实时精准辨识常态与异常工况并进行预测机制动态切换,难以满足复杂动态工况下的实时调度需求

Benefits of technology

通过引入光谱正规化层的改进CycleGAN,从充足的历史常态数据生成逼真的异常仿真数据,有效扩充了训练样本集,从源头缓解了模型过拟合问题。通过结合SARIMA-NGARCH的物理规律增强与双重对比损失的自监督学习,使模型能从有限数据中提取出对各类异常扰动均鲁棒、判别性强的时空特征,克服了不同异常模式间的特征迁移障碍。通过基于KDE加权的增量学习机制,模型能够在线感知客流分布变化,并自动聚焦于对运营安全影响更大的极端客流点进行快速微调,满足了异常场景下实时、精准的预测调度需求。跨域数据生成-对比特征学习-在线自适应微调三步环环相扣,协同作用,共同实现了在稀疏、非平稳异常客流场景下预测精度与鲁棒性的显著提升。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122965735A_ABST
    Figure CN122965735A_ABST
Patent Text Reader

Abstract

The application discloses a subway short-time in-out passenger flow prediction method and system based on contrast learning, and belongs to the technical field of rail transit. The method comprises the following steps: obtaining historical normal passenger flow data; introducing an improved cycle generative adversarial network with a spectral normalization layer to generate abnormal scene simulation passenger flow data with real spatio-temporal dependence characteristics, and solving the problem of sparse abnormal samples; using a contrast learning framework, combining adaptive noise enhancement based on a SARIMA-NGARCH model and time / instance double contrast loss, performing self-supervised feature learning on simulation and normal data, and constructing a strong generalization passenger flow prediction base model; through real-time access to passenger flow data, using a Huber loss function based on kernel density estimation weighting to perform incremental learning fine-tuning on the base model, realizing dynamic adaptation and outputting high-precision prediction results. Through the collaborative framework of cross-domain data generation-contrast feature learning-online adaptive fine-tuning, the prediction accuracy and robustness of the model in sparse and non-stationary abnormal scenes are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of rail transit technology, and specifically relates to a method and system for predicting short-term passenger flow in and out of subway stations based on comparative learning. Background Technology

[0002] With the continuous expansion of urban rail transit networks and the rapid growth of passenger flow, short-term passenger flow forecasting is crucial for ensuring operational safety and scheduling efficiency. In abnormal operational scenarios such as large-scale events, temporary station closures, and extreme weather, passenger flow exhibits characteristics of suddenness, large fluctuations, and rapid transmission, placing higher demands on forecast accuracy and real-time response capabilities.

[0003] Existing technologies (such as ConvLSTM, STGCN, and other deep prediction models) are mostly designed for routine scenarios and face inherent limitations in abnormal scenarios: First, the frequency of abnormal events is low, the sample size is sparse, and the high complexity of the model can easily lead to overfitting; Second, abnormal disturbances disrupt the daily and weekly cycles of passenger flow and the correlation characteristics between lines, increasing the difficulty of model fitting; Third, the spatiotemporal evolution patterns of different abnormal scenarios (such as activity clusters and station closures and detours) differ significantly, and the feature transfer and generalization capabilities of a single model are insufficient; Fourth, it is impossible to accurately identify normal and abnormal operating conditions in real time and dynamically switch the prediction mechanism, making it difficult to meet the real-time scheduling needs under complex dynamic operating conditions. Summary of the Invention

[0004] To address the above problems, this invention provides a method for predicting short-term passenger flow in and out of subway stations based on contrastive learning, comprising the following steps: Historical normal passenger flow time series data is obtained, and abnormal scenario simulated passenger flow data with real spatiotemporal dependence characteristics is generated based on the improved CycleGAN. Using a contrastive learning framework, self-supervised feature learning is performed on the generated simulated passenger flow data and the historical normal passenger flow time series data to construct a basic model for passenger flow prediction. Real-time access to passenger flow data, based on the aforementioned passenger flow prediction model, uses incremental learning to dynamically fine-tune parameters and outputs short-term passenger flow prediction results for subway stations under abnormal scenarios.

[0005] Furthermore, the improvements to the improved recurrent generative adversarial network may include introducing regularization layers into the network structure, adjusting the generator and discriminator architecture, or optimizing the training loss function to enhance the realism of the generated data and the stability of training. As a preferred embodiment, the improvement specifically involves introducing spectral normalization layers into the network layers of the generator and discriminator.

[0006] Furthermore, the improved recurrent generative adversarial network is trained by minimizing a joint loss function, which includes adversarial loss, recurrent consistency loss, and identity mapping loss.

[0007] Furthermore, in the contrastive learning framework, at least one of perturbation enhancement, scaling enhancement, and fragment reconstruction is used to enhance the passenger flow time-series data to construct positive and negative sample pairs. The perturbation enhancement preferably employs a SARIMA-NGARCH joint model to extract time-varying passenger flow fluctuation patterns and generate adaptive noise injection positive sample pairs.

[0008] Furthermore, the loss function of the contrastive learning framework includes temporal contrastive loss and instance contrastive loss, which, through joint optimization, force the model to simultaneously capture temporal local dependencies and robust global semantic features.

[0009] Furthermore, the incremental learning employs a Huber loss function weighted by kernel density estimation (KDE), which automatically increases the focus on extreme passenger flow samples with low probability density (i.e., low frequency of occurrence), thereby improving the model's prediction accuracy for abnormal peaks. The bandwidth parameter of the KDE can be adaptively selected using the Silverman rule of thumb.

[0010] Furthermore, the encoder of the passenger flow prediction basic model includes a temporal embedding module and a temporal feature extraction network. The temporal embedding module performs fusion encoding of multi-scale temporal semantics; the temporal feature extraction network adopts a stacked residual bidirectional long short-term memory network (Bi-LSTM) that combines multi-head self-attention mechanism and channel attention mechanism to extract deep discriminative temporal features.

[0011] Furthermore, in the kernel density estimation, the bandwidth parameter is adaptively selected using the Silverman empirical rule.

[0012] This invention also provides a short-term subway passenger flow prediction system based on contrastive learning, comprising: An abnormal scenario simulation generation module is used to implement the above data generation steps; A contrastive learning self-supervised pre-training module is used to implement the above self-supervised feature learning steps; The model dynamic fine-tuning and prediction module is used to implement the above online fine-tuning and prediction steps; It may also include multi-dimensional data enhancement modules, real-time data streaming processing modules, etc.

[0013] The present invention also provides an electronic device and a computer-readable storage medium for implementing the above method.

[0014] Compared with the prior art, the present invention has the following advantages: By introducing an improved CycleGAN with a spectral normalization layer, realistic anomaly simulation data is generated from ample historical normal data, effectively expanding the training sample set and alleviating the model overfitting problem at its source. Through self-supervised learning combining SARIMA-NGARCH physical law enhancement and dual contrastive loss, the model can extract robust and discriminative spatiotemporal features from limited data, overcoming feature transfer barriers between different anomaly patterns. Using a KDE-weighted incremental learning mechanism, the model can perceive changes in passenger flow distribution online and automatically focus on extreme passenger flow points with greater impact on operational safety for rapid fine-tuning, meeting the real-time and accurate prediction and scheduling requirements in anomaly scenarios. The three interconnected steps of cross-domain data generation, contrastive feature learning, and online adaptive fine-tuning work synergistically to significantly improve prediction accuracy and robustness in sparse, non-stationary anomaly passenger flow scenarios.

[0015] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention may be realized and obtained by means of the structures pointed out in the description, claims and drawings. Attached Figure Description

[0016] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are 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 an overall flowchart of the subway short-term passenger flow prediction method based on contrastive learning provided in the embodiments of the present invention.

[0018] Figure 2 This is an example of a heatmap that compares raw, normal passenger flow data with abnormal simulated passenger flow data generated by an improved CycleGAN. Detailed Implementation

[0019] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0020] See Figure 1The prediction method provided by this invention mainly includes three stages: abnormal scene simulation data generation (S100), contrastive learning self-supervised pre-training (S200), and online adaptive fine-tuning and prediction (S300).

[0021] Phase 1 (S100): Generation of abnormal scenario simulation data based on improved recurrent generative adversarial networks.

[0022] This phase aims to address the core challenge of sparse abnormal passenger flow samples. By constructing an improved CycleGAN, it learns the mapping relationship between abundant historical normal passenger flow data and various abnormal passenger flow data, thereby generating simulated abnormal data with realistic spatiotemporal dependencies.

[0023] S101: Network construction.

[0024] like Figure 2 As shown, the example of a passenger flow heatmap displaying the original data and augmented data reveals that in the original data, most areas are dark purple (low passenger flow), with only localized bright green (medium passenger flow) appearing during a few time periods (such as after 5:00 PM and 7:00 PM). Overall, the passenger flow distribution is sparse, with very few samples of abnormal / peak scenarios. After augmentation, many areas change from dark purple to cyan, light green, or even bright yellow, especially during the entire period from 7:00 AM to 9:00 PM and across all stations from 101_01 to 107_231, where passenger flow distribution is denser and values ​​are higher. This indicates that through the "abnormal scenario simulation data generation" stage (such as improved CycleGAN), the originally sparse abnormal / peak passenger flow samples are significantly supplemented, resulting in a substantial improvement in the spatiotemporal coverage and diversity of the data. The heatmap visually illustrates the difference in passenger flow distribution between the "raw data" and the "enhanced data": the raw data shows sparse passenger flow and few samples of abnormal scenarios; the enhanced data, through the generative model, supplements a large number of abnormal / peak passenger flow samples, significantly improving the spatiotemporal density and diversity of the data, providing more abundant training material for subsequent "contrastive learning pre-training" and "online prediction". The improved CycleGAN consists of two generators (G1, G2) and two discriminators (D1, D2).

[0025] The key improvement of this invention lies in the introduction of Spectral Normalization (SN) layers in both the generator and discriminator. The SN layer effectively controls the Lipschitz constant of the model by imposing spectral norm constraints on the network weight matrix W (i.e., limiting its maximum singular value to no more than 1, which ensures the Lipschitz continuity of the generator mapping). This significantly alleviates the gradient explosion and mode collapse problems commonly encountered in GAN training, and accelerates the convergence speed on complex passenger flow time series data.

[0026] Specifically, in the generator, the SN layer is integrated after the linear interpolation (LN) operation and before the LeakyReLU activation function (LeakyReLU, LR) to normalize the transformed features; similarly, spectral normalization in the discriminator is applied to the weights of each linear or convolutional layer. Utilizing a dual-generator architecture, the normal time series data is mapped to an anomalous latent space. Through a nonlinear combination of linear interpolation (LN) and the LeakyReLU activation function, the two generators within it have the same architecture but different inputs. Let x... l Let z be the original time series vector in the latent space, and z be the vector with respect to x. l Given random matrices of the same shape, the outputs of the two generators, i.e., the augmented data x, will be... aug and reconstructed data x re Specifically, it can be expressed as:

[0027] Where SN represents the spectral normalization layer that makes the network converge faster, LN is linear interpolation, LR represents the LeakyReLU activation function, i represents the current module iteration, Sig represents the Sigmoid function, and n is the total number of layers.

[0028] Correspondingly, the outputs of the two discriminators y1 and y2 can be described as follows:

[0029]

[0030] DROP stands for Dropout, which is used to prevent overfitting; other symbols are the same as above.

[0031] S102: Network Training and Data Generation.

[0032] When training the improved CycleGAN, a joint loss function is used for optimization, and the total loss L consists of four parts: Combat loss (L GAN ): Forces the generated data distribution to approximate the target data distribution.

[0033] Cyclic consistency loss (L cyc ): Ensure that when data is transformed by one generator and then transformed back to the original domain by another generator, it remains consistent with the original data, thereby preserving the spatiotemporal structure of passenger flow sequences (such as commuting cycles and station associations).

[0034]

[0035] Identity mapping loss (L identity ): Suppress unnecessary feature drift and stabilize training.

[0036]

[0037] Total loss:

[0038] Where γ and η are hyperparameters used to balance the importance of different loss terms; E z~Pdata(z) For the latent spatial data z (which follows the true distribution P) data(z) Take the expected value; E X~Pdata(X) For the normal passenger flow data x (which follows a true distribution P) data(x) D1() is the expected value; D2() is the discriminator D2, which outputs the probability that the data is "real / fake"; G1() is the generator G1, which maps normal data X to abnormal data Z; L GAN (G2, D1, X, Z) represents the adversarial loss between generator G2 and discriminator D1 (and L). GAN (G1, D2, X, Z) are symmetric, and G2 maps outlier data Z back to normal data X); L cyc (G1, G2) is the cycle-consistent loss, ensuring that G2(G1(x))≈x and G1(G2(z))≈z; L identity (G1, G2) is the identity mapping loss, which guarantees G1(x)≈x (if the input is abnormal data) and G2(z)≈z (if the input is normal data).

[0039] By training the network by minimizing the total loss L, the generator G1 can convert the input historical normal passenger flow time series x into the corresponding abnormal scenario simulated passenger flow data x after training. aug This greatly expands the abnormal training sample set.

[0040] The improved recurrent adversarial generative network (RBN) trained as described above outputs passenger flow data for abnormal scenarios. In terms of loss function design, the system jointly optimizes the adversarial loss enhanced by the spectral normalization layer (SN), the cycle consistency loss to ensure spatiotemporal structural consistency, and the identity mapping loss to suppress illegal feature drift. The adversarial loss, through the game between the discriminator and the generator, forces the simulated sequence to approximate the distribution of real abnormal data, while the cycle consistency loss, through bidirectional reconstruction constraints, ensures that the passenger flow sequence retains the original commuting cycle and station association characteristics during dimensional transformations. In the training process, the final loss is L.

[0041] Phase 2 (S200): Self-supervised pre-training based on contrastive learning.

[0042] The goal of this stage is to use the generated simulation data and historical normal data to train a feature extractor (i.e. an encoder) with strong generalization ability, which extracts spatiotemporal features with strong discriminative power and robustness to various abnormal disturbances through self-supervised contrastive learning, thus forming the basic model for passenger flow prediction.

[0043] S201: Multidimensional data augmentation and positive / negative sample construction.

[0044] Data augmentation is performed for contrastive learning to generate positive and negative sample pairs. Considering that passenger flow prediction data is typically limited and exhibits strong periodicity and trends, data augmentation not only increases the sample size but also helps the model better capture passenger flow patterns. Passenger flow data exhibits strong periodicity and trends; feature extraction needs to capture these patterns, while augmentation may need to preserve these patterns. Therefore, three data augmentation methods are employed to capture these periodic and fluctuating patterns.

[0045] 1. Disturbance Enhancement: Simulating passenger flow fluctuation noise (this noise generation is based on the data structure itself). To generate adaptive noise that conforms to the physical laws of passenger flow, this invention employs SARIMA-NGARCH joint modeling. The specific steps are as follows: a. Historical passenger flow sequence X t Establish a SARIMA model:

[0046]

[0047] Among them, X t Let be the passenger flow sequence at time t. and It is a multinomial with real coefficients, and B is defined as... The shift operator (i.e., B shifts the sequence "one period back", B2 shifts it two periods back, and so on). It is an autoregressive (AR) polynomial (passenger flow is influenced by its own past p periods (e.g., "today's passenger flow" depends on "passenger flow yesterday, the day before yesterday... p days ago")), d refers to the order of difference required to achieve steady state, and w t The disturbance is represented as period t, with a mean of zero and a variance of . p refers to the order of the autoregressive (AR) model (the order of "time lag," meaning the model depends on its own values ​​over the past p periods), and q refers to the order of the moving average (MA) model. iThe autoregressive coefficients (real coefficients) are i=1,2,…,p, and θ(B) is the moving average (MA) polynomial (passenger flow fluctuations are affected by the cumulative influence of random noise (such as sudden weather or temporary events) over the past q periods). j The moving average coefficients (real coefficients) are j=1,2,…,q, w t It represents unpredictable random fluctuations or sudden shocks that occur at time t.

[0048] b. After training the SARIMA model, extract the residual sequence. .

[0049] c. For the residual sequence Establish an NGARCH model and characterize its conditional heteroscedasticity:

[0050]

[0051] Among them, z t Let be independent and identically distributed standard normal random variables, each with a mean and unit variance of zero. Independent of δ is a constant term. α i Here, η is the innovation impact coefficient, and η is the leverage effect parameter. β j ε is the volatility persistence coefficient, where p represents the lag order of the news shock, q represents the lag order of volatility, and ε is the volatility persistence coefficient. t i This represents the error term with a lag of i periods, where i = 1, 2, ..., n. It is the standard conditional variance, X t σ represents the time series data of passenger flow at time t; t Let z be the conditional volatility at time t. t For standard normal white noise, β j It is the volatility persistence coefficient, which is the coefficient of the "historical volatility" term in the conditional variance equation (it is a coefficient vector (corresponding to the lag order q), and each j=1,2,...,q has a corresponding β). j ), Let be the conditional variance with lag j (represented by t) At time j, the best prediction of future volatility based on all available information sets at that time.

[0052] d. Generate time-varying conditional variance using the trained NGARCH model. Then, an adaptive noise sequence ε is synthesized. t' =σt z t' (z) t' (The newly sampled random number) is injected into the original passenger flow sequence to complete the perturbation enhancement.

[0053] 2. Enhanced Scaling: Simulates overall passenger flow changes caused by weekdays / holidays or large events by multiplying by a global scaling factor. Simulates overall passenger flow changes under different scenarios, including full-day passenger flow scaling on weekdays and holidays, and regional passenger flow surges caused by special events (such as concerts and sporting events).

[0054] 3. Fragment Reorganization: Randomly swapping or shuffling local continuous segments in the time series simulates local pattern disturbances such as peak-hour shifts. This simulates local sequence disturbances in passenger flow patterns, such as time shifts during peak hours. The instantaneous disturbance enhancement method, inspired by the research of Enhui Chen et al., employs SARIMA-NGARCH joint modeling to extract time-varying fluctuation patterns. Adaptive noise conforming to passenger flow fluctuation patterns is generated through dynamic conditional heteroscedasticity, and contrastive learning positive sample pairs are injected to enhance the model's sensitivity to local temporal disturbances.

[0055] Positive samples are obtained from the same original passenger flow time series instance, each enhanced using the same enhancement method or with different parameters. Negative samples, on the other hand, come from other different passenger flow time series instances and their enhanced views within the same training batch.

[0056] It should be noted that the SARIMA-NGARCH joint model is used to model the time-varying fluctuation patterns of passenger flow time series, and its training and parameter selection are as follows: (1) First, perform a stationarity test (such as the ADF test) on the historical normal passenger flow time series. The difference order d is usually chosen as the minimum difference number that makes the series stationary (mean and variance basically do not change with time). The seasonal difference order D is used to eliminate periodic fluctuations in the series and is usually set to 1.

[0057] (2) For passenger flow data, S is usually taken as 24 hours / day or S as 168 hours / week.

[0058] (3) Use historical passenger flow data to perform maximum likelihood estimation (MLE) or conditional least squares estimation on the selected SARIMA model to obtain the model parameters. The optimal value.

[0059] (4) After training, extract the residual sequence of the model. This sequence should be approximately white noise, but its square may exhibit conditional heteroscedasticity. Use this as the input of the NGARCH model.

[0060] This method, taking into account the characteristics of passenger flow time-series data, designs a strategy for constructing positive and negative samples, as follows: (1) Positive sample pairs consist of two “views” of the same passenger flow time series instance after different data augmentation transformations. The core objective is to enable the model to learn to bring these semantically similar but slightly different views closer together in the feature space. The construction of the two “views” is based on the aforementioned three data augmentation methods. Different data augmentation parameters are selected for an original sample to construct different perspectives, which forces the model to identify the essential features of passenger flow patterns from different augmentation perspectives.

[0061] (2) Negative sample pairs consist of augmented views of different passenger flow time-series instances. The goal is to enable the model to learn to push these semantically different samples further apart in the feature space. In a training batch, for any sample and its augmented view, all other samples and their augmented views in the same batch are considered negative samples of that sample. Specifically, if the batch size is N, and 2N views can be obtained through augmentation, then for a certain view, the number of negative sample pairs is 2(N). 1) This constitutes a difficult set of negative samples, prompting the model to learn more discriminative features.

[0062] S202: Encoder Structure and Comparative Learning Training.

[0063] The core of the passenger flow prediction basic model is a feature encoder, the structure of which is as follows: 1. Input: The encoder input consists of three parts: short-term fluctuation sequence X t (Passenger flow data at time t, subsequences segmented by delay dimension d (retaining commuting cycle and station association)), periodic sequence X T (Time series data after dimensional transformation (i1, i2, ... are indices, d1, d2, ... are corresponding delays)) and external factor matrix X external (such as weather, temperature, etc.).

[0064] Specifically, time-series data mainly focuses on the cyclical characteristics and short-term fluctuations of passenger flow.

[0065]

[0066]

[0067]

[0068] in, Represents a time-series fluctuation sequence. Represents a time-series periodic sequence. This represents data on external influencing factors; Indicated as a point in time of day. Represented as a date, where This indicates the passenger flow corresponding to the predicted time. This can be represented by different external factors, including weather temperature, etc. The corresponding data corresponds to the timestamp.

[0069] 2. Temporal Embedding Module: A bimodal temporal embedding module is designed to jointly model multi-scale temporal semantics. Addressing the need for joint modeling of multi-scale temporal semantics in time series prediction tasks, this work designs a bimodal temporal embedding component. This component explicitly models short-term fluctuation patterns (intraday cycles) and long-term trend patterns (holiday effects and calendar cycles). Each feature is mapped to a dense vector through an independent embedding layer, and finally, a temporal embedding representation is generated through feature-level summation and fusion. The short-term mode focuses on hourly high-frequency prediction scenarios, embedding three sets of temporal identifier features: Short-term patterns: embedding hours (classes 0-23, 24, encoding intraday periodicity), quarter-hour intervals (classes 0-3, 4, refining 15-minute time resolution), peak markers (classes 0 / 1, 2, indicating time-period characteristics in scenarios such as traffic), and event markers (classes 0 / 1, 2, indicating whether an abnormal event has occurred).

[0070] Long-term mode: embeds holiday feature groups (statutory holiday status (0 / 1), adjusted workday identifier (0 / 1), distance to adjacent holiday (0 / 1), holiday period status (0 / 1), current holiday duration (0-9)) and date feature groups (month (0-11), date (0-30), weekday (0-6), weekend marker (0 / 1), quarter (0-3), etc.).

[0071] Each feature is mapped to a dense vector through an independent embedding layer Embed{a->d} (where a is the number of classes and d is the embedding dimension), and then summed to obtain the temporal embedding representation H. t .

[0072]

[0073]

[0074]

[0075]

[0076]

[0077] in, Represented as a short-lived embedding layer, x i The input value for the i-th short-term feature (such as the current hour, the current quarter, etc.) Indicates a long-term embedding layer, x jThe input value for the j-th long-term feature (such as the current day of the week, the current date, etc.) This represents an embedding layer that maps 'a' categories to a 'b'-dimensional space. Passenger flow data; H t The characteristic modes (short / long-term modes) at time t; E h (h)=Embed 24→d (h) is the embedding of hour h (mapping 24 hours into a d-dimensional vector); E q (q)=Embed 4→d (q) is the embedding of quarter q (mapping the four quarters to d-dimensional vectors); E r (r)=Embed 2→d (r) is the embedding of whether it is weekend r (mapping 2 classes (yes / no) to d-dimensional vectors); E p (p)=Embed 2→d (p) is the embedding of whether it is a holiday p (mapping the 2 classes (yes / no) to d-dimensional vectors); E l The embedding summation is performed on the holiday features (k=1-5, summed after embedding each of the 5 holiday-related features (e.g., whether it's Spring Festival, National Day, or a weekend)) and the data features (m=6-10, summed after embedding each of the 5 data-related features (e.g., "hour", "day of the week", "temperature"), x. k x is the input value for the feature of the kth holiday (e.g., whether it is Chinese New Year: 0 or 1). m The input value for the m-th data feature (e.g., hour: 0~23); H v H is a 1D convolutional layer for feature extraction of temporal data X; final After layer normalization (after residual connection), the final feature representation is obtained.

[0078] 3. Temporal Feature Extraction Networks: These networks demonstrate powerful performance in extracting bidirectional time series features. Bi-LSTM, in particular, combines forward and backward LSTM networks to achieve bidirectional modeling of the sequence data's contextual information. Bi-LSTM significantly enhances sequence modeling capabilities even with limited data volume due to its bidirectional structure. To overcome the depth limitations of traditional Bi-LSTM, a stacked residual Bi-LSTM architecture is proposed. This architecture enhances time series modeling capabilities through deep layer stacking. An attention mechanism is introduced after the LSTM layers, primarily to enhance the model's ability to focus on key time steps and different feature channels, resulting in more accurate predictions. A self-attention mechanism is introduced, enabling the model to adaptively allocate attention weights. This enhances the influence of key time steps, mitigates long-term dependencies, improves model interpretability, calculates the association weights between each element in the sequence and other elements, and generates a new representation through weighted summation. Considering that different channels contribute differently to the prediction target, a channel attention mechanism is further applied to optimize feature representation.

[0079] Specifically, the main structure employs a stacked residual bidirectional LSTM (Bi-LSTM). The forward and backward hidden states of the l-th layer at time t are calculated as follows:

[0080]

[0081] After merging, the remaining parts are joined together:

[0082] Attention mechanism: Multi-head self-attention: enables the model to focus on key time steps.

[0083]

[0084] Where Q (query matrix), K (key matrix), and V (value matrix) are obtained by projecting the input X onto a learnable weight matrix. These are the forward and backward weight matrices for the l-th layer, respectively; For from the upper layer (l) The output features of layer 1 at the current time step t. For the previous time step (t) 1) Forward hidden state, The hidden states before and after the next time step (t+1) QK is the projection matrix used to map the concatenated high-dimensional vector back to the appropriate dimension and fuse forward and backward information. T To calculate the similarity (dot product) between the query and all keys. This represents the forward hidden state of layer l at time t; This represents the backward hidden state of the l-th layer at time t; Vector concatenation operation Represented as a residual connection; Represented as an activation function; Represented as a weight parameter matrix; , , It is a learnable weight matrix; It is the scaling factor, Q=XW Q K=XW K V=XW V These are respectively a query matrix, a key matrix, and a value matrix; After the hidden states of the bidirectional LSTM are concatenated, they are activated by ReLU and connected to the residuals (W). c (Q, K, V is the weight matrix); Attention(Q, K, V) is the scaled dot product attention (d k (This is the dimension of the key, to prevent the inner product from becoming too large).

[0085] Channel attention: Learning the importance of different feature channels. First, global average pooling is performed to obtain the channel statistics z. c Then, the channel weights w are obtained through two fully connected layers and a sigmoid activation function, and finally the features are recalibrated.

[0086] in, For channel statistics (i.e., z); and These are the parameters for the fully connected layer; For activation function, This represents channel-wise multiplication, x c Feature map data for a specific channel; x c (i, j) represents the pixel or feature value located at coordinates (i, j) in the c-th channel, where i represents the row index (from top to bottom, ranging from 1 to H, 1 to W); H×W represent the height and width of the feature map, respectively; w is the weight; z is the channel statistic; and δ is the activation function of the hidden layer. The original input feature map of XWE1 (typically with dimensions C×H×W). This is the output feature map after channel attention weighting.

[0087] To learn more robust temporal features, a rigorous downstream excuse task is introduced. This task requires the model to cross-predict augmented and original data, forcing it to ignore noise introduced by data augmentation and focus on learning semantically invariant features. Specifically, we use the Transformer as the downstream model, whose global self-attention mechanism can effectively model long-term dependencies and enhance feature representation. Furthermore, the Transformer architecture performs well in large-scale data scenarios, adaptively capturing information at different time scales and improving the discriminative power of features through contrastive learning. This design not only enhances the model's generalization ability but also improves its ability to capture complex temporal patterns. The Transformer downstream model uses a common Transformer structure, as shown in the following formula:

[0088]

[0089]

[0090] in, and This represents the learnable parameter matrix; and Indicates positional encoding; Indicates a fully connected layer; This is represented as a self-attention mechanism; This represents a multi-head attention mechanism; MulitHead(Q, K, V) is the multi-head attention function (h heads, each head independently calculates attention and then concatenates the results, W...). O (for output weights), Concat(head1,…,head) h ) represents the splicing operation; head i Calculate the attention for the i-th head ( , , (where is the weight of the i-th head); FFN(x) is a feedforward neural network (ReLU activation + linear transformation); pos is the position, i is the dimension index, and d is the weight of the i-th head. model Let x be the model dimension, x be the input vector or matrix, and W1 and b1 be the weight matrix and bias vector of the first linear transformation, respectively; and the weight matrix and bias vector of the second linear transformation.

[0091] The training process simultaneously optimizes the model through a contrastive learning objective function, which includes two losses: a temporal contrastive loss, which brings features of adjacent time slices closer together and pushes features of non-adjacent time slices further apart, enabling the model to learn to capture the local dependencies and smooth changes in passenger flow over time; and an instance contrastive loss, which brings features of the same instance in different augmented views closer together and pushes features of different instances further apart, forcing the model to ignore random perturbations introduced during augmentation and thus focus on learning robust global semantic features from passenger flow data. In this way, the model can automatically learn discriminative and robust passenger flow feature representations from augmented data.

[0092] Specifically, within the contrastive learning framework, the enhanced positive and negative samples are mapped to feature representations by the encoder with shared weights. The model is trained by minimizing the joint contrastive loss: Instance contrast loss (L) NTXen t-loss): Bringing positive sample pairs closer to feature z i , z j , pushing away and negative sample features z k The distance;

[0093] Temporal contrast loss: bringing features closer together in adjacent time slices and ;

[0094] Total self-monitoring loss:

[0095] in, and This is represented as feature input; This is represented as a temperature adjustment parameter, used to control the sharpness of the similarity distribution; Represented as batch normalization factor; Indicated as batch size, Represented as time step; This represents the predicted features after passing through the Seq-transformer. This is represented as the true feature vector of a randomly selected time segment. , For the self-supervised learning loss weight parameters, This represents the total loss of self-supervised learning; N is the number of samples, and K is the number of negative samples.

[0096] By optimizing the aforementioned loss, the model learns to extract robust passenger flow features that are invariant to data augmentation and have strong discriminative power, thus completing the pre-training of the basic model.

[0097] Phase 3 (S300): Online Adaptive Fine-tuning and Prediction Based on Incremental Learning In this phase, the pre-trained model will be deployed online, and through incremental learning, it will dynamically adapt to real-time changes in passenger flow and make high-precision predictions for abnormal scenarios.

[0098] S301: Multi-source real-time data streaming processing.

[0099] The system integrates real-time data streams from multiple sources, including the subway's Automatic Fare Collection (AFC) system and video passenger flow statistics system. The raw streaming data is parsed in real time, time-aligned, and outlier-cleaned. Then, a sliding window is used to extract real-time time segments S at the same time granularity Δt (e.g., 15 minutes) as during the training phase. ; It is simulation data of abnormal scenarios (Φ is the generation function, This indicates that real-time passenger flow data, such as AFC and video surveillance data, can be obtained.

[0100] It is the set of outlier data within the time window τ (Δt is the time step). Finally, the global mean μt calculated during the training phase is used. rain and standard deviation σ train , for S Standardization is performed to obtain standardized data, which can be used for subsequent model input or comparative learning.

[0101] in, These are extremely small positive numbers, specifically the mean and standard deviation of normal data.

[0102] S302: Incremental learning and dynamic prediction.

[0103] The system triggers a model fine-tuning process at fixed intervals (e.g., hourly). Processed real-time data from recent windows is used to construct the fine-tuning dataset. Starting with pre-trained base model parameters, a small learning rate is employed to adapt to new distributions while avoiding catastrophic forgetting of existing knowledge. The final output is an optimized short-term passenger flow prediction, visualized for operations personnel, supporting scheduling decisions. Rapid training (e.g., 5-10 rounds) is performed on the fine-tuning dataset. This incremental learning process uses a Huber loss function weighted by kernel density estimation (KDE) to focus on predicting extreme passenger flows.

[0104] It should be noted that the system accesses multi-source heterogeneous data streams in real time to perceive passenger flow status. The data sources include: 1) gate transaction records generated by the subway automatic fare collection (AFC) system, which accurately includes entry / exit times, station and equipment numbers; 2) real-time aggregated passenger flow count data provided by the intelligent video surveillance system. The raw stream data undergoes real-time parsing, time alignment, outlier cleaning and repair, and generates station-level real-time passenger flow time-series segments aggregated at fixed time granularity (e.g., 15 minutes) as model input.

[0105] The system employs an automatic model fine-tuning process with fixed time intervals, ensuring the model absorbs the latest data patterns at a stable pace, maintaining prediction accuracy while avoiding unnecessary frequent calculations. Training utilizes the AdamW optimizer, with the KDE-weighted Huber loss function as the optimization objective. This loss function automatically identifies and focuses on samples with large prediction errors (typically during periods of abnormal passenger flow), driving the model to specifically improve its predictive ability for extreme scenarios during fine-tuning. Its inherent weighting mechanism has embedded an awareness of "abnormalities," thus eliminating the need for additional event-triggered logic.

[0106] The bandwidth of this loss function is a key parameter controlling the smoothness of density estimation. It is adaptively selected using the Silverman rule of thumb, achieving a good balance between computational efficiency and estimation accuracy. Empirically, a bandwidth of around 30 is recommended for testing. The fusion of KDE and Huber loss involves dynamically modulating the Huber loss weight for each sample using the probability density estimated by KDE. First, using the KDE method described above, the probability density corresponding to the true passenger flow value for each sample is estimated based on the batch data (or combined with recent historical data). The obtained sample weights are then combined with the standard Huber loss to form the final KDE-weighted Huber loss. Through this fusion method, the model uses a weighted average of the prediction error (measured by the Huber loss) during fine-tuning. For extreme peak or trough passenger flow samples with low probability density, i.e., infrequent occurrences, their weights are increased, making the model pay more attention to fitting these "difficult cases" or "outliers" when updating parameters. The standard Huber loss is already robust to outliers, while the KDE weighting mechanism further endows it with the ability to adaptively focus on uneven distribution of passenger flow data, thereby improving the model's prediction accuracy in abnormal scenarios.

[0107] Specifically, KDE weighted: Based on fine-tuned batch data, it estimates the actual passenger flow value y. true The probability density. Using a Gaussian kernel function:

[0108] Among them, P KDE(y) represents the probability density of the kernel density estimate (KDE) (n is the sample size, y) i (Using passenger flow training samples), bandwidth σ is a key parameter for controlling smoothness, and can be adaptively selected using the Silverman rule of thumb: σ = 1.06 min(standard deviation, interquartile range / 1.34) n^{-1 / 5}. For passenger flow data, an empirical value can also be set between 20 and 40.

[0109] Weighted Huber Loss: This method combines the inverse of the estimated probability density with the Huber loss, using the inverse as weights.

[0110]

[0111] Where δ is the Huber loss threshold, which controls the switching point between squared loss and linear loss; It is expressed as the probability density function of the random variable y calculated using kernel density estimation (KDE); For passenger flow samples; For a specific value of the probability density that needs to be estimated; This is represented as the expectation operator. Actual passenger flow This is a passenger flow forecast. It is a very small positive number (usually taken as 10⁻⁶) to prevent numerically stable terms with a denominator of zero; The threshold parameter for Huber loss controls the switching point between squared loss and linear loss; e represents the prediction error.

[0112] The present invention also provides a prediction system applying the above method, comprising: Abnormal Scene Simulation Generation Module: This module incorporates the improved CycleGAN to implement S100. Specifically, it constructs an improved Recurrent Adversarial Generative Network (CycleGAN) and, by introducing techniques such as spectral normalization (SN) and linear interpolation (LN), maps historical normal passenger flow data into abnormal scene simulation data with real spatiotemporal dependencies, thereby achieving cross-domain enhancement of the sample set.

[0113] Multidimensional data augmentation module: Integrating SARIMA-NGARCH joint model, etc., to achieve the data augmentation described in S201. This module is used to perform perturbation augmentation, scaling augmentation, and segment reconstruction on passenger flow sequences; among them, SARIMA-NGARCH joint modeling is used to extract the time-varying fluctuation pattern of passenger flow and generate adaptive noise injection positive sample pairs to capture the periodicity and heteroscedasticity characteristics of passenger flow.

[0114] The contrastive learning self-supervised pre-training module includes the encoder and contrastive learning framework, used to implement S200. Specifically, this module is used to construct an encoder and contrastive learning framework based on shared weights. By jointly optimizing the temporal contrastive loss and the instance contrastive loss, it learns highly discriminative and robust global semantic features of passenger flow from simulation and normal data to build a basic prediction model.

[0115] Real-time data streaming processing module: This module interfaces with multi-source data streams to enable streaming processing of the S301. Specifically, it dynamically accesses multi-source passenger flow data from turnstiles and video surveillance, and transforms the real-time data streams into time-series segments that meet the model input requirements through windowed processing and standardized preprocessing.

[0116] Model Dynamic Fine-tuning and Prediction Module: This module performs incremental learning and KDE-weighted loss optimization to predict S302. It uses an incremental learning strategy to periodically update the parameters of the base model and leverages a kernel density estimation (KDE)-weighted loss function to improve the model's attention to extreme passenger flow values, ultimately outputting and visualizing high-precision short-term prediction results for abnormal scenarios.

[0117] The present invention also provides an electronic device, including a processor and a memory. The memory stores programs or instructions that can run on the processor. When the program or instructions are executed by the processor, they implement the above-mentioned method for predicting short-term passenger flow in and out of subway stations based on contrastive learning, specifically implementing the steps of the spatiotemporal dynamic prediction method for heterogeneous graph convolutional rail transit OD matrix based on completion mechanism.

[0118] The present invention also provides a readable storage medium on which a program or instruction is stored. When the program or instruction is executed by a processor, it implements the above-mentioned method for predicting short-term passenger flow in and out of subway stations based on contrastive learning, specifically implementing the steps of the spatiotemporal dynamic prediction method for heterogeneous graph convolutional rail transit OD matrix based on completion mechanism.

[0119] While specific embodiments of the invention have been described in detail by way of examples, those skilled in the art should understand that the examples are for illustrative purposes only and not intended to limit the scope of the invention. Those skilled in the art should understand that modifications can be made to the above embodiments without departing from the scope and spirit of the invention. The scope of the invention is defined by the appended claims.

[0120] Those skilled in the art will recognize that the modules and algorithm steps described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0121] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the above-described apparatus and equipment can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0122] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or modules may be electrical, mechanical, or other forms.

[0123] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of the embodiments of the present invention, depending on actual needs.

[0124] In addition, the functional modules in the embodiments of the present invention can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module.

[0125] If the functionality is implemented as a software module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, external hard drives, ROM, RAM, magnetic disks, or optical disks.

[0126] In summary, this invention, through an improved CycleGAN (Generative Recurrent Adversarial Network) and contrastive learning mechanism, accurately constructs and reconstructs the spatiotemporal dependence characteristics of passenger flow under abnormal operating conditions, breaking through the industry bottleneck of traditional models experiencing a precipitous drop in prediction accuracy in extreme scenarios due to sparse samples and distribution drift. The prediction architecture of this invention is based on physically driven fluctuation modeling and self-supervised feature extraction, possessing strong feature decoupling and generalization capabilities. Utilizing the built-in SARIMA-NGARCH joint enhancement operator and kernel density estimation (KDE) weighted loss function, it not only significantly improves the model's sensitivity to capturing extreme values ​​such as sudden large passenger flows, but also further compresses prediction bias and enhances model generalization performance through incremental learning in a dynamically evolving traffic environment through real-time fine-tuning, providing reliable technical support for accurate decision-making in complex and variable urban subway conditions.

[0127] Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for predicting short-term passenger flow in and out of subway stations based on contrastive learning, characterized in that, Includes the following steps: Historical normal passenger flow time series data is obtained, and abnormal scenario simulated passenger flow data with real spatiotemporal dependence characteristics is generated based on an improved cyclic generative adversarial network; Using a contrastive learning framework, self-supervised feature learning is performed on the generated simulated passenger flow data and the historical normal passenger flow time series data to construct a basic model for passenger flow prediction. Real-time access to passenger flow data, based on the aforementioned passenger flow prediction model, uses incremental learning to dynamically fine-tune parameters and outputs short-term passenger flow prediction results for subway stations under abnormal scenarios.

2. The method according to claim 1, characterized in that, In the improved recurrent generative adversarial network, a spectral normalization layer is introduced into the network layers of the generator and discriminator.

3. The method according to claim 1 or 2, characterized in that, The improved recurrent generative adversarial network is trained by minimizing a joint loss function, which includes adversarial loss, recurrent consistency loss, and identity mapping loss.

4. The method according to claim 1, characterized in that, In the contrastive learning framework, positive and negative sample pairs for self-supervised learning are constructed by perturbation enhancement, scaling enhancement, and fragment reconstruction of passenger flow time series data.

5. The method according to claim 4, characterized in that, The disturbance enhancement employs a SARIMA-NGARCH joint model to model the fluctuation patterns of historical passenger flow time series, generating adaptive noise that conforms to the time-varying fluctuation law of passenger flow, and injecting the adaptive noise into the original passenger flow data to construct positive sample pairs.

6. The method according to claim 1, characterized in that, The loss function of the contrastive learning framework includes temporal contrastive loss and instance contrastive loss; The time contrast loss is used to bring the feature representations of adjacent time segments closer together and push the feature representations of non-adjacent time segments further apart. The instance contrast loss is used to bring the feature representations of the same passenger flow time series instance closer together after different data augmentations, and to push the feature representations of different passenger flow time series instances further apart.

7. The method according to claim 1, characterized in that, In the incremental learning step, the model parameters are optimized using the Huber loss function weighted by kernel density estimation.

8. The method according to claim 1, characterized in that, The passenger flow prediction model includes an encoder, which comprises: The time embedding module is used to embed, encode, and fuse the hour, quarter-hour, date, day of the week, and holiday information in the input time series data; The temporal feature extraction network employs a stacked residual bidirectional long short-term memory network that combines multi-head self-attention and channel attention mechanisms to extract deep temporal features from the output of the temporal embedding module.

9. The method according to claim 7, characterized in that, In the kernel density estimation, the bandwidth parameter is adaptively selected using the Silverman empirical rule.

10. A short-term passenger flow prediction system for subway stations based on contrastive learning, characterized in that, include: The abnormal scenario simulation generation module is used to acquire historical normal passenger flow time series data and generate abnormal scenario simulation passenger flow data with real spatiotemporal dependence characteristics based on an improved recurrent generative adversarial network. The contrastive learning self-supervised pre-training module is used to perform self-supervised feature learning on the generated simulated passenger flow data and the historical normal passenger flow time series data using a contrastive learning framework, and to build a basic model for passenger flow prediction. The model dynamic fine-tuning and prediction module is used to access passenger flow data in real time. Based on the passenger flow prediction basic model, it uses incremental learning to dynamically fine-tune the parameters and outputs the short-term passenger flow prediction results of the subway station under abnormal scenarios.

11. An electronic device comprising a processor and a memory, the memory storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the method as described in any one of claims 1 to 7.

12. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 7.