# xLSTM-Based Urban Traffic Flow Prediction for Intelligent Transportation Governance
## 2 Materials and Methods
### xLSTM Model Architecture and Training [8]  
At the core of the proposed forecasting framework lies the extended Long Short-Term Memory (xLSTM) model, an advanced variant of the traditional LSTM architecture. Unlike conventional LSTM networks, xLSTM employs matrix-based memory cells and exponential gating mechanisms, which significantly enhance its capacity to model long-term dependencies and nonlinear spatio-temporal interactions. These architectural innovations are particularly well suited for urban traffic environments, where congestion patterns are often abrupt and spatially diffused across interconnected road segments [6,8]. The model takes as input a set of multivariate time series features derived from the VD sensor network, including vehicle speed, volume, and occupancy rates. To account for spatial positioning, positional embeddings are incorporated, encoding the physical location of each sensor within the urban road network. The xLSTM outputs a multi-horizon congestion score for each monitored segment, which is subsequently mapped to discrete congestion levels--normal, moderate, or severe--based on empirically determined thresholds. The training process adopts a dual-objective loss formulation: the mean squared error (MSE) is used for optimizing the regression-based congestion score predictions, while cross-entropy loss evaluates the classification accuracy of congestion levels. To ensure robust model generalization, the dataset is temporally partitioned into training (70%), validation (15%), and testing (15%) sets. The model is implemented using the PyTorch v2.5.1 framework and trained using the Adam optimizer, with early stopping applied based on validation loss performance [8]. The xLSTM architecture is particularly well suited to the unique characteristics of Taiwanese urban environments, which feature highly variable road geometries, diverse  
Figure 1: System workflow. modal splits (e.g., motorcycles versus private vehicles), and uneven patterns of population density. These conditions introduce significant spatial and temporal variability, making accurate short-term traffic forecasting especially challenging. First, exponential gating replaces conventional sigmoid-based activation in the gating functions with exponential mechanisms. This adjustment yields smoother gradients and greater stability across extended time steps, thereby improving the model's ability to retain long-range temporal dependencies. Such capability is crucial for capturing peak-hour surges and irregular flow patterns that frequently occur in Taiwanese cities. Second, matrix memory cells extend traditional scalar memory units into higher-dimensional matrix structures. This enables the model to process complex spatial features, including multi-road junction densities, regional travel time vectors, and localized congestion heatmaps. These enhanced representations allow xLSTM to learn spatial dependencies that are often overlooked by standard LSTM architectures (Figure 2). The xLSTM architecture integrates two cell types: mLSTM and sLSTM. The mLSTM cells encode both input \(\mathbf{x_{t}}\) and previous hidden state \(h_{t-1}\) into structured matrix memories, followed by memory mixing and exponential gating. The flattened outputs are passed to the sLSTM cells, which perform cross-memory interactions and apply exponential gating to produce the final output \(h_{t}\). This hybrid structure enhances temporal modeling and information flow across time steps. Third, multi-branch parallelization supports the concurrent execution of multiple xLSTM blocks across subdivided temporal windows or spatial clusters. This parallel learning strategy improves training and inference efficiency while enhancing system robustness in the face of sensor failures, missing data, or communication latency--challenges commonly encountered in city-scale traffic monitoring systems. Unlike Transformer-based models, which provide strong global context modeling at the cost of quadratic memory complexity, xLSTM maintains linear scalability and low inference latency.