Physics-Guided Adaptive Patch Routing for Temporal–Spectral Fusion in Wearable Human Activity Recognition
This repository implements the methodology proposed in the paper "Physics-Guided Adaptive Patch Routing for Temporal–Spectral Fusion in Wearable Human Activity Recognition"
Abstract: Wearable inertial sensor-based human activity recognition (HAR) must handle heterogeneous local motion regimes within a fixed analysis window, including steady, periodic, transitional, and locally corrupted segments. However, existing temporal–spectral HAR models commonly apply fixed or globally shared fusion at the window level, limiting their ability to adapt to patch-wise differences in motion structure. To address this limitation, we propose a physics-guided adaptive patch-routing dual-branch network. The model separately encodes temporal and spectral representations and uses a lightweight gate to adjust their contributions for each patch. Routing is guided by compact, physically interpretable descriptors of motion energy, jerk, spectral structure, and cross-signal coordination, while a physics-derived soft target stabilizes gate learning. The spectral branch further uses a learnable channel-wise projection of local Fourier magnitudes to capture task-relevant frequency patterns. Experiments on UCI-HAR, WISDM, PAMAP2, and UniMiB-SHAR show that the proposed method consistently achieves the highest Macro-F1 among the evaluated variants and outperforms uniform and sample-level fusion. Ablation results confirm the complementary roles of the two branches and the contributions of patch-level routing, rich motion descriptors, spectral projection, and routing supervision. Gate analyses further show non-trivial variation across patches and activity classes. Perturbation tests show that the proposed model maintains the highest absolute recognition performance among the evaluated fusion variants under the tested signal distortions, while Raspberry Pi 4 measurements demonstrate practical on-device feasibility. These results support physics-guided patch-wise routing as an effective and interpretable alternative to globally shared temporal–spectral fusion for wearable HAR.
This repository does not include datasets. Please download them from the official sources below and configure the dataset path accordingly.
- UCI-HAR dataset is available at https://archive.ics.uci.edu/dataset/240/human+activity+recognition+using+smartphones
- WISDM dataset is available at https://www.cis.fordham.edu/wisdm/dataset.php
- PAMAP2 dataset is available at https://archive.ics.uci.edu/dataset/231/pamap2+physical+activity+monitoring
- UniMiB-SHAR dataset is available at http://www.sal.disco.unimib.it/technologies/unimib-shar/
torch==2.5.0
numpy
scikit-learn
To install all required packages:
pip install -r requirements.txt
All experiments were conducted in Google Colaboratory using Python 3.12.12 and PyTorch 2.5.0 with CUDA 12.6.
model.py: Implementation of the proposed PGPRDT (Physics-Guided Patch-Routing Dual Transformer) architecture. The implementation is based on PyTorch and includes the time-domain patch embedding, the frequency-domain branch with a learnable spectral filterbank, the two branch Transformer encoders, the patch-level physics gate for routing, and the classifier head.
If you use this code in your research, please cite:
@article{PGPRDT,
title = {Physics-Guided Adaptive Patch Routing for Temporal--Spectral Fusion in Wearable Human Activity Recognition},
author = {Jimin Kim and Myung-Kyu Yi},
journal = {},
volume = {},
number = {},
pages = {},
year = {},
publisher = {}
}
This project is licensed under the MIT License. See the LICENSE file for details.
For questions or issues, please contact:
- Jimin Kim: sispo3314@gmail.com