FlashHAR-X: Subject-Generalizable Human Activity Recognition
Trained model (not a Transformers checkpoint). Custom multiscale 1D-convolution + two-block attention model for classifying smartphone inertial signals.
- GitHub source: https://github.com/SURGEOPS99/FlashHAR_X
- Official subject-disjoint UCI HAR test accuracy: 0.9627 (96.27%)
- Official test macro-F1: 0.9631
- Task: 6-class human activity recognition.
- Dataset: UCI Human Activity Recognition Using Smartphones, DOI: 10.24432/C54S4K. The original dataset is CC BY 4.0. No dataset copies are included in this model repository.
- Training: official train subjects (7,352 windows); validation subject groups selected within training to fix epoch counts, then retrained using all official training subjects. Official held-out test: 2,947 windows from distinct subjects. Scores use the standard published split, not random window splits.
- Inputs: one 2.56-second sensor window containing 9 channels ร 128 readings plus the original dataset's 561 engineered features, in the same order and normalization as training. Do not feed arbitrary accelerometer streams without replicating UCI preprocessing.
- Architecture: 3/7/15 multiscale convolution stem โ positional encoding โ two attention blocks โ mean/max pooling โ engineered-feature MLP fusion โ 6-class classifier.
- Attention: trained using a custom, educational Triton FlashAttention-style forward and backward kernel. For portability, inference can use numerically equivalent PyTorch
scaled_dot_product_attentionwith the SAME learned weights, including on CPU. This isn't a claim that the custom kernel runs faster than PyTorch SDPA.
Official test results
| Model | Accuracy | Macro-F1 |
|---|---|---|
| cnn_only | 0.9684 | 0.9692 |
| torch_sdpa | 0.9630 | 0.9635 |
| triton_flash | 0.9627 | 0.9631 |
| RBF-SVM (561 engineered features) | 0.9549 | 0.9540 |
These results are produced by this project's artifacts/official_test_metrics.csv after completing the notebook, not copied from papers. Other research numbers are only comparable when inputs, split, and metric definitions match. The checkpoint chosen here is the custom-Triton-trained model, not necessarily the highest-scoring baseline.
Files
model.safetensors: trained neural network parameters (no pickle).config.json: architecture details and class ordering.normalization.json: means/scales fitted on official train subjects only.official_test_metrics.csv: reported benchmark numbers.flashhar_model.py: network definition.
Reproduce predictions
Clone the associated GitHub project and install its inference dependencies, then:
python inference_hf.py --repo-id Saspatez/FlashHAR-X --dataset-dir data --index 0 --device cpu
The notebook must first have downloaded/extracted the official UCI HAR dataset under data/. The inference script reads a real official test window. Install torch, numpy, huggingface_hub and safetensors to run inference; running the custom Triton backend for training requires an appropriately configured CUDA GPU.
Important limitations
- Subject-independent testing on 30 volunteers does not demonstrate reliability for every user, device orientation, sensor vendor, mobility pattern, or unconstrained real-world scenario.
- The model uses UCI's precomputed 561 engineered features in addition to raw inertial signals. Real-time deployment requires reproducing those features, not just forwarding nine sensor channels.
- The notebook's GPU experiments should be independently verified; benchmark numbers and any performance claims belong to their recorded hardware and seed.
- This is a college research prototype, not a safety-critical or medical system.
References
Reyes-Ortiz et al., Human Activity Recognition Using Smartphones (2013). FlashAttention: Dao et al. (2022); FlashAttention-2: Dao (2023). Our Triton implementation is an educational reimplementation of tiled exact attention, not a novel attention algorithm.
- Downloads last month
- -