Abstract
This paper proposes a deep learning approach for traffic flow prediction in complex road networks. Traffic flow data from induction loop sensors are essentially a time series, which is also spatially related to traffic in different road segments. The spatio-temporal traffic data can be converted into an image where the traffic data are expressed in a 3D space with respect to space and time axes. Although convolutional neural networks (CNNs) have been showing surprising performance in understanding images, they have a major drawback. In the max pooling operation, CNNs are losing important information by locally taking the highest activation values. The inter-relationship in traffic data measured by sparsely located sensors in different time intervals should not be neglected in order to obtain accurate predictions. Thus, we propose a neural network with capsules that replaces max pooling by dynamic routing. This is the first approach that employs the capsule network on a time series forecasting problem, to our best knowledge. Moreover, an experiment on real traffic speed data measured in the Santander city of Spain demonstrates the proposed method outperforms the state-of-the-art method based on a CNN by 13.1% in terms of root mean squared error.
Introduction
Predicting traffic flow and speed is a cornerstone of modern Intelligent Transportation Systems (ITS). However, traffic is a complex spatio-temporal phenomenon; a bottleneck on one road segment inevitably propagates to neighboring segments over time. While Convolutional Neural Networks (CNNs) have set benchmarks in spatial feature extraction, they suffer from a fundamental limitation in this context: the max pooling operation. By selecting only the highest activation values within a local neighborhood, CNNs discard precise spatial hierarchies and the relative relationships between sparsely located sensors. This paper proposes a Capsule Network (CapsNet) approach that replaces max pooling with dynamic routing to preserve these vital inter-relationships.
Methodology
Data Representation
To leverage deep learning architectures, traffic speed data is transformed into an image-like format. As shown in the figure below, the vertical axis represents time steps ($M$) and the horizontal axis represents different sensors or road segments ($N$). This allows the model to treat traffic patterns as visual features that evolve across both space and time.
Capsule Network Architecture
The core innovation lies in the use of capsules—groups of neurons whose outputs are vectors rather than scalars. The length of a capsule's output vector represents the probability of a feature's presence, while its orientation (the "pose") encodes specific properties of that feature.
The architecture begins with standard convolutional layers to extract low-level features. These are then passed to a PrimaryCaps layer and finally a TrafficCaps layer. Instead of max pooling, the network employs dynamic routing (routing-by-agreement). This iterative process allows low-level capsules to "vote" on the state of higher-level capsules, ensuring that spatial relationships are maintained throughout the network hierarchy.
Experimental Evaluation
The model was evaluated using real-world traffic speed data from the Santander city road network in Spain. The dataset comprised a full year of measurements (2016) taken at 15-minute intervals. The network was trained on data from January to September and tested on the final quarter of the year.
The performance of the CapsNet was compared against a state-of-the-art CNN baseline across four tasks of increasing complexity. Results indicated that the CapsNet consistently outperformed the CNN, achieving an average 13.1% improvement in Root Mean Squared Error (RMSE) and an 8.24% improvement in Mean Absolute Error (MAE). Notably, the performance advantage of the CapsNet widened as the complexity of the prediction task (number of sensors and prediction horizon) increased.
Conclusion and Future Work
By preserving the spatial hierarchy of road networks through dynamic routing, Capsule Networks offer a more robust framework for traffic forecasting than traditional CNNs. However, this accuracy comes at a computational cost: the proposed CapsNet was approximately 30 times slower to train than the CNN baseline due to the iterative nature of the routing algorithm. Future research will focus on optimizing these routing mechanisms to enable real-time deployment in large-scale urban environments.
Summary updated