DSHformer: Locality-Sensitive Hash Attention and Prototype Alignment for Sensor-Based Human Activity Recognition Authors: Xiaofeng Zhang, Muzi Ding, Tangzhi Teng, Jie Wan, Hong Ding Published: 2026 ABSTRACT Highlights What are the main findings? We introduce DSHformer, which combines patch-based channel–temporal feature extraction, prototype-guided feature refinement, and decomposition-guided LSH-based attention for sensor-based HAR.Extensive experiments on five public benchmarks show that DSHformer achieves competitive or superior performance compared with several HAR baselines and recent Transformer variants with attention-level efficiency advantages that become pronounced on longer sequences. What are the implications of the main findings? This paper demonstrates that strong HAR performance does not necessarily require heavy full-attention architectures.This paper offers a practical framework for balancing recognition accuracy, model compactness, and attention-level efficiency on longer wearable-sensor sequences. AbstractSensor-based human activity recognition (HAR) plays a fundamental role in healthcare monitoring, sports analytics, and ambient-assisted living. Although deep learning has substantially advanced HAR performance, two practical issues still limit its real-world deployment: (i) the distribution shift caused by changes in users or sensor placements can degrade generalization, and (ii) the quadratic O(L2) complexity of standard self-attention hinders efficient long-sequence modeling on resource-constrained wearable devices. To address these issues, we propose DSHformer, which is an accuracy-oriented HAR framework that combines compact channel–temporal encoding with locality-sensitive hashing (LSH)-based attention. Specifically, DSHformer (i) employs a low-parameter patch-based graph-attention encoder to jointly model latent relationships among sensor channel–temporal dynamics; (ii) introduces a trainable prototype pool together with a multi-layer decomposition network to improve intra-class compactness and inter-class separability via prototype alignment; and (iii) introduces a decomposition-stable LSH-based attention mechanism tailored for HAR, whose core design couples prototype-guided feature decomposition with locality-sensitive hashing to ensure that semantically related tokens remain consistently grouped in the same hash bucket even after decomposition-induced attenuation. The mechanism thereby operates at O(LlogL) attention complexity on longer sensor sequences. Extensive experiments on five public benchmarks (WISDM, UCI-HAR, PAMAP2, Opportunity, and UniMiB-SHAR) show that DSHformer achieves accuracies of 98.6%, 93.7%, 98.4%, 88.5%, and 96.6%, respectively, achieving competitive or superior performance compared with both Transformer variants and HAR-specific baselines under the adopted benchmark protocols. Ablation studies further confirm the complementary contribution of each component. 1. Introduction Sensor-based human activity recognition (HAR) methods can identify and classify activities by analyzing sensor signals. Current trends indicate that wearable devices have become widely integrated into our lives, providing a foundation for smart home and transportation applications [1,2], ranging from rehabilitation and caregiving for the growing elderly population to improving human performance [3,4]. By embedding tiny sensors in wearable devices, we can automatically and accurately recognize human activities, which are fundamental to these applications. Wearable technology creates multi-channel time-series data streams by continually recording measurement results through several sensor channels. Finding and categorizing the timing of actions within these produced time series is hence the HAR challenge. The system can identify activities and automatically extract characteristics from the raw sensor data by using deep learning networks, which increases the recognition accuracy [5,6,7]. 1.1. Problem and Motivations Although end-to-end deep learning architectures have made significant progress on HAR tasks, we identify three untapped dimensions that substantially limit the performance of current state-of-the-art frameworks: HAR systems frequently encounter distribution shifts caused by changes in users, sensor placements, or device types when moving from training to real-world testing. Although transfer learning has been shown to improve generalization in computer vision tasks [8,9,10], these methods typically require access to target-domain data during training. In real-world wearable applications, however, retraining the model whenever users or devices change is impractical. HAR data collection yields motion measurements across multiple sensors and channels, suggesting that the channel and temporal structure can jointly improve activity encoding. However, existing models often over-parameterize this process by stacking heavy convolutional or attention blocks to capture every possible inter-channel–temporal interaction. Reducing the number of trainable parameters while preserving representational capacity remains an open challenge [10,11]. Attention mechanisms allow models to focus on salient parts of the input, but the standard self-attention has O(L2) complexity, which is impractical for long sensor windows on resource-constrained wearable devices. Although several efficient Transformer variants reduce this cost, they often sacrifice recognition accuracy in doing so [12,13]. 1.2. Our Contributions The main contributions of this paper are summarized as follows:Low-parameter channel–temporal feature encoder. We design a compact yet expressive feature extractor that jointly models inter-channel correlations and temporal dependencies. Specifically, we first apply stacked 1D convolutions to capture local temporal patterns, then partition the sequence into non-overlapping patches and build a patch-wise channel graph to encode cross-sensor relations, and finally refine the patch representations with an attention-augmented LSTM. The entire encoder uses only seven convolutional layers, two fully connected layers, and a single LSTM layer, achieving strong representation capability with markedly fewer trainable parameters than existing Transformer-based HAR models (see Section 3.2).Prototype-based alignment for robust representations. To improve intra-class compactness and inter-class separability under varying data conditions, we construct a trainable prototype pool whose entries represent class-wise reference samples and stack a multi-layer decomposition network that separates similar and dissimilar components between inputs and prototypes. An inter-class margin loss further enlarges the separation between prototypes of different activities, yielding more compact and class-discriminative representations (see Section 3.3 and Section 3.4).Decomposition-guided LSH-based attention for HAR. We replace the standard self-attention with a decomposition-guided LSH-based attention mechanism tailored for multi-channel sensor sequences. By coupling prototype-guided feature decomposition with locality-sensitive hashing, DSHformer ensures that semantically related temporal tokens remain grouped in the same hash bucket even after decomposition-induced feature attenuation, and it computes attention only among those grouped tokens. The mechanism operates at O(LlogL) attention complexity—the same asymptotic class as Reformer—while the novelty lies in the HAR-tailored decomposition-stable hashing design rather than the complexity class itself.Comprehensive empirical validation. We evaluate DSHformer under a unified protocol on five widely used HAR benchmarks—WISDM, UCI-HAR, PAMAP2, Opportunity, and UniMiB-SHAR—where it achieves competitive or superior performance compared with both HAR-specific baselines and recent Transformer variants. Extensive ablation and visualization studies further verify the individual contribution of each proposed component (see Section 4.3 and Section 4.4). Low-parameter channel–temporal feature encoder. We design a compact yet expressive feature extractor that jointly models inter-channel correlations and temporal dependencies. Specifically, we first apply stacked 1D convolutions to capture local temporal patterns, then partition the sequence into non-overlapping patches and build a patch-wise channel graph to encode cross-sensor relations, and finally refine the patch representations with an attention-augmented LSTM. The entire encoder uses only seven convolutional layers, two fully connected layers, and a single LSTM layer, achieving strong representation capability with markedly fewer trainable parameters than existing Transformer-based HAR models (see Section 3.2). Low-parameter channel–temporal feature encoder. We design a compact yet expressive feature extractor that jointly models inter-channel correlations and temporal dependencies. Specifically, we first apply stacked 1D convolutions to capture local temporal patterns, then partition the sequence into non-overlapping patches and build a patch-wise channel graph to encode cross-sensor relations, and finally refine the patch representations with an attention-augmented LSTM. The entire encoder uses only seven convolutional layers, two fully connected layers, and a single LSTM layer, achieving strong representation capability with markedly fewer trainable parameters than existing Transformer-based HAR models (see Section 3.2). Prototype-based alignment for robust representations. To improve intra-class compactness and inter-class separability under varying data conditions, we construct a trainable prototype pool whose entries represent class-wise reference samples and stack a multi-layer decomposition network that separates similar and dissimilar components between inputs and prototypes. An inter-class margin loss further enlarges the separation between prototypes of different activities, yielding more compact and class-discriminative representations (see Section 3.3 and Section 3.4). Prototype-based alignment for robust representations. To improve intra-class compactness and inter-class separability under varying data conditions, we construct a trainable prototype pool whose entries represent class-wise reference samples and stack a multi-layer decomposition network that separates similar and dissimilar components between inputs and prototypes. An inter-class margin loss further enlarges the separation between prototypes of different activities, yielding more compact and class-discriminative representations (see Section 3.3 and Section 3.4). Decomposition-guided LSH-based attention for HAR. We replace the standard self-attention with a decomposition-guided LSH-based attention mechanism tailored for multi-channel sensor sequences. By coupling prototype-guided feature decomposition with locality-sensitive hashing, DSHformer ensures that semantically related temporal tokens remain grouped in the same hash bucket even after decomposition-induced feature attenuation, and it computes attention only among those grouped tokens. The mechanism operates at O(LlogL) attention complexity—the same asymptotic class as Reformer—while the novelty lies in the HAR-tailored decomposition-stable hashing design rather than the complexity class itself. Decomposition-guided LSH-based attention for HAR. We replace the standard self-attention with a decomposition-guided LSH-based attention mechanism tailored for multi-channel sensor sequences. By coupling prototype-guided feature decomposition with locality-sensitive hashing, DSHformer ensures that semantically related temporal tokens remain grouped in the same hash bucket even after decomposition-induced feature attenuation, and it computes attention only among those grouped tokens. The mechanism operates at O(LlogL) attention complexity—the same asymptotic class as Reformer—while the novelty lies in the HAR-tailored decomposition-stable hashing design rather than the complexity class itself. Comprehensive empirical validation. We evaluate DSHformer under a unified protocol on five widely used HAR benchmarks—WISDM, UCI-HAR, PAMAP2, Opportunity, and UniMiB-SHAR—where it achieves competitive or superior performance compared with both HAR-specific baselines and recent Transformer variants. Extensive ablation and visualization studies further verify the individual contribution of each proposed component (see Section 4.3 and Section 4.4). Comprehensive empirical validation. We evaluate DSHformer under a unified protocol on five widely used HAR benchmarks—WISDM, UCI-HAR, PAMAP2, Opportunity, and UniMiB-SHAR—where it achieves competitive or superior performance compared with both HAR-specific baselines and recent Transformer variants. Extensive ablation and visualization studies further verify the individual contribution of each proposed component (see Section 4.3 and Section 4.4). 2. Related Work 2.1. Deep Learning for Human Activity Recognition By making it possible to automatically extract intricate features from unprocessed sensor data, deep learning has completely transformed HAR [14]. The intricacy of human motion cannot be fully captured by traditional approaches, which frequently rely on manual feature extraction [15]. On the other hand, discriminative representations can be learned directly from data using deep learning models like Convolutional Neural Networks (CNNs) and Recurrent Neural Networks (RNNs) [16]. Accurate activity recognition depends on the spatial and temporal connections that are encoded by these representations. These models’ performance in practical applications has also been improved by the abundance of data sources made available by the growth of wearable technology and smart home technologies. This has led to a major development in the industry with deep learning-based HAR systems currently being widely employed in domains including intelligent environment control and health monitoring. Emerging deep learning techniques have recently shown remarkable results in a variety of research fields, including speech recognition, natural language processing, and traffic flow prediction [17]. Deep learning has made it possible for automatic end-to-end feature extraction in sensor-based human activity identification (HAR), greatly minimizing the need for laborious feature engineering. These developments have led to the widespread and effective use of deep learning techniques in a variety of HAR application settings [18,19,20]. The capacity of the model to capture both short-term and long-term dependencies has been improved by the recent widespread usage of deep learning architectures based on time-series decomposition to deconstruct and reconstruct temporal patterns from complicated time-series data [11,21,22,23]. In order to capture important activity aspects, these studies frequently use multi-scale convolution to break down time-series data into trend and seasonal components. Classification networks are then used to integrate and link the retrieved latent data to activity categories. Wu et al. [12,13,24], for instance, presented a Fourier transform-based time-series decomposition architecture that uses main frequency results to break down time-series data into several periodic patterns. Furthermore, in deep learning, channel and temporal encoding have emerged as crucial methods for managing intricate time-series data [16,25]. Through their ability to capture spatial information and temporal dependencies, they greatly improve the performance of models in a variety of dynamic tasks. We previously proposed a deep learning method based on spatio-temporal encoding [26], which uses a two-stage graph network to model the spatial patterns of multivariate time-series data and creates an attention-based neural control differential equation network to capture dynamic dependencies across time steps. Even while our previous work, as outlined in Section 1.1, produced some results, the current research tackles a more specialized and intricate issue that calls for novel approaches. In contrast to earlier research, this paper suggests a more effective and parameter-efficient encoding structure while delving deeper into the use of channel and temporal encoding in HAR. 2.2. Transformer-Based Methods Since the Transformer was introduced by Vaswani et al. [7], self-attention has been widely adopted in time-series modeling to capture long-range dependencies. However, a significant obstacle to directly applying Transformers from NLP to time-series jobs is the Transformer architecture’s quadratic time and memory complexity. This intricacy limits the model’s usefulness by causing a dramatic increase in memory and processing resources when working with lengthy sequences. Researchers have put out a number of computationally effective time-series Transformer models in an effort to address this problem. By altering the self-attention mechanism, these models achieve more efficient processing while lowering computational complexity. For instance, by using a variety of techniques like sparse attention matrices, divide-and-conquer tactics, or adding more inductive biases, models like Informer [27], ETC [28], Pyraformer [29], and FEDformer [30] have successfully reduced complexity to linear or near-linear levels (such as O(L) or O(LlogL)). In addition to improving the model’s capacity to manage lengthy sequences, these enhancements offer fresh avenues for investigation and techniques in the time series analysis community. Locality-Sensitive Hashing (LSH) provides an efficient approximate nearest-neighbor mechanism by mapping similar high-dimensional vectors into the same or nearby hash buckets. This property has motivated LSH-based attention mechanisms such as Reformer [5] where attention is restricted to tokens with similar hash assignments. While Transformer-based deep learning frameworks have demonstrated significant promise in managing multi-channel time-series data, there are still issues with striking a balance between complexity and accuracy. Optimizing model complexity while preserving high performance is a crucial problem that requires more research in this area, because high accuracy frequently entails greater model complexity. 3. Materials and Methods All experiments used publicly available datasets and did not involve additional physical data-collection equipment. The computational experiments were implemented in Python 3.13.5 using NumPy 2.3.0 and PyTorch 2.11.0+cu128 with CUDA 12.8; scikit-learn 1.7.2 was used for evaluation metrics and t-SNE visualization, and pandas 2.3.0 and SciPy 1.17.1 were used for data processing. The experiments were run on a computer equipped with an Intel UHD Graphics adapter and an NVIDIA GeForce RTX 4060 Laptop GPU. Problem definition. First, we provide a formal definition of the human activity recognition (HAR) task. Let D={(X(i),y(i))}i=1N denote a labeled HAR dataset containing N samples. Each sample X(i)∈RM×T is a multivariate sensor time series where M denotes the number of sensor channels or variables and T denotes the number of temporal steps within one sample window. The vector at time step t is denoted as xt(i)=[x1,t(i),x2,t(i),…,xM,t(i)]⊤∈RM, where t=1,…,T. The corresponding activity label is y(i)∈Ω={1,2,…,K} where K is the number of activity classes. The goal of HAR is to learn a classifier fθ:RM×T→Ω that predicts the activity label of an unseen multivariate sensor sequence. 3.1. Model Architecture Overview As shown in Figure 1, the input X is first processed by a channel–temporal feature encoder. Stacked 1D convolutional layers capture abstract local temporal patterns from neighboring time steps without yet fusing information across channels. The sequence is then partitioned along the temporal dimension into non-overlapping patches, and a channel-wise graph matrix is constructed for each patch to model inter-sensor dependencies. The channel-fused patch representations are fed into a single-layer LSTM that treats each patch as a temporal token, and a patch-level attention matrix, computed from the similarity between graph matrices, reweights the LSTM outputs to emphasize informative patches. In parallel, a trainable prototype pool P stores class-specific reference samples. Both X and P are fed into a multi-layer decomposition network, where Decomposition Blocks (Dec Blocks) separate similar and dissimilar components between inputs and prototypes, and alignment blocks reduce the distribution gap between training and test samples. Random projection matrices then map the decomposed features into hash buckets, and attention weights are computed only among time steps that share the same hash code—so that features with similar temporal semantics remain grouped even after decomposition-induced attenuation. Overall, the model (i) extracts channel and temporal features with few trainable parameters and linear-time encoding complexity; (ii) applies a decomposition-guided LSH-based attention mechanism that maintains semantic token groupings and operates at O(LlogL) attention complexity; and (iii) maintains a trainable prototype pool that encourages class-discriminative and compact representations. This two-stage refinement yields rich feature representations prior to classification. Each component of Figure 1 and Figure 2 is described in detail in the following sections. 3.2. Patch-Based Graph Attention and Temporal Feature Learning Module The fundamental principle behind the approach that combines the temporal decomposition network with the Locality-Sensitive Hashing (LSH) algorithm presented in Section 3.3 is that similar temporal features can be assigned to the same hash bucket even when they are in different decomposition states. As a result, we must create a feature extraction network that satisfies the following requirements. (i) The network must be able to aggregate similar characteristics across many variables and time steps, as the decomposition network necessitates continual attenuation of these features; (ii) the feature extractor should remain lightweight so that it does not dominate the computational cost before the LSH-based attention stage. As the main feature extractor, we first use a multi-layer stacked convolutional network [16]. Four convolutional layers are used to process the input sensor sequence, and each layer combines ReLU nonlinear activation with 64 one-dimensional convolutional filters of size 5 along the temporal dimension. These stacked temporal convolutions extract local motion patterns from the raw sensor sequence while preserving the channel-wise structure required for subsequent graph-based modeling. We then construct a channel feature extraction network because graph structures have been widely used to model relationships among different positions or variables in structured data [31,32,33]. After the temporal convolutional transformation, the feature map is partitioned into non-overlapping patches along the temporal dimension. This patching operation provides local temporal segments for constructing channel-wise graph representations:(1)H=Conv1D(X),r=n−(Tmodn)modn,Hpad=ConcattH,0B×Ch×r×M,Np=T+rn. where X denotes the input sensor sequence, H denotes the convolutional feature map, and Hpad denotes the temporally padded feature map. B is the batch size, Ch is the number of convolutional hidden channels, M is the sensor-channel dimension, T is the original sequence length, n is the patch length, r is the temporal padding length, and Np is the number of temporal patches. The padding vector 0B×Ch×r×M is concatenated along the temporal dimension. When T is divisible by n, r=0, and no temporal padding is added. For the i-th sample and the p-th temporal patch, let ui,pm denote the feature vector associated with the m-th sensor channel. We compute the channel-to-channel affinity within this patch as(2)αi,pm,m′=expϕ(ui,pm)⊤ψ(ui,pm′)∑ℓ=1Mexpϕ(ui,pm)⊤ψ(ui,pℓ),(3)u^i,pm=ui,pm+γ∑m′=1Mαi,pm,m′ui,pm′.For each temporal patch, the channel affinity scores form a channel relation matrix(4)Ai,p=[αi,pm,m′]m,m′=1M∈RM×M.Stacking the channel-refined patch features over all Np patches gives(5)E=Stackp=1Np(U^p)∈RB×Np×De,A=Stacki=1,p=1B,Np(Ai,p)∈RB×Np×M×M. where αi,pm,m′ denotes the channel affinity weight from the m-th sensor channel to the m′-th sensor channel in the p-th patch of the i-th sample. ϕ(·) and ψ(·) are learnable one-dimensional convolutional projections used to generate query and key features, respectively. u^i,pm is the channel-refined representation obtained through residual graph-based aggregation, and γ is a learnable scaling parameter. Ai,p is the M×M channel relation matrix for one temporal patch. After stacking all samples and patches, A∈RB×Np×M×M, where B is the batch size and Np is the number of temporal patches. E∈RB×Np×De denotes the patch-level feature tensor after local graph refinement and flattening, where De is the patch-level feature dimension. We further design a patch-level temporal feature extraction network because Recurrent Neural Networks are effective in modeling temporal dependencies [1,6,16]. The patch-level feature tensor E∈RB×Np×De is fed into a single-layer LSTM to obtain a sequence of hidden states Hlstm=[h1lstm,h2lstm,…,hNplstm]. To incorporate the graph structure of each temporal patch, the channel relation matrix Ap is flattened and mapped to a patch-level temporal weight: (6)wp=expfc(flatten(Ap))∑p′=1Npexpfc(flatten(Ap′)),(7)hpout=(1+γtwp)hplstm,p=1,…,Np. where wp denotes the temporal importance weight of the p-th patch, fc(·) denotes a linear mapping, flatten(·) denotes the flattening operation, γt is a learnable scaling parameter, hplstm is the LSTM hidden state of the p-th patch, and hpout is the temporally reweighted patch representation. The output sequence Hout=[h1out,h2out,…,hNpout] is used as the encoded temporal representation. 3.3. Decomposition Network and LSH-Based Attention Using temporal information from different postures is important for fine-grained human activity recognition with wearable sensors. To improve sensor feature representation, we design a decomposition-guided LSH-based attention module that learns interactions between input temporal features and prototype features while avoiding the quadratic computational cost of full self-attention [5,7,29]. To avoid ambiguity, Locality-Sensitive Hashing (LSH) refers to the hashing strategy that maps similar temporal tokens into the same or nearby hash buckets, whereas LSH-based attention refers to the attention mechanism that computes local attention within the selected hash buckets. In this paper, the proposed decomposition-guided LSH-based attention module consists of three main components: a multi-layer temporal decomposition network, hash-code generation based on LSH, and local attention within hash buckets, corresponding to Figure 2a, Figure 2d and Figure 2e, respectively. First, we decompose the prototype features and the input temporal features into similar and dissimilar components: (8)hs=sigmoidfcAvgPoolConv(h+β·z)⊙h,(9)hns=h−hs,(10)psk=sigmoidfcAvgPoolConv(pk)⊙pk,(11)pnsk=pk−psk. where z denotes the initialized zero vector in the first layer of the temporal decomposition network; in subsequent layers, it represents the interaction features between the input samples and the aligned prototype samples. h denotes the hidden state of the input feature; hs and hns denote its similar and dissimilar components, respectively. pk denotes the k-th prototype sample; psk and pnsk denote its similar and dissimilar components, respectively. β is the attenuation coefficient. The closest prototype sample is then determined by selecting the i-th prototype sample based on the ground-truth label during training or by finding the nearest prototype via Euclidean distance during inference. Then, we align and interact the input features with the selected prototype features. The interaction operation encourages the feature distribution of input samples to become closer to the corresponding prototype distribution, while the alignment operation provides a prototype reference for reducing the mismatch between training and inference representations.(12)xali=Wenc(hs)−enc(ps∗)+b⊙enc(ps∗)+hns,(13)pali=Wenc(ps∗)−enc(hs)+b⊙enc(hs)+pns∗. where xali and pali denote the aligned input feature and the aligned prototype feature, respectively. enc(·) is a feature encoder comprising batch normalization, ReLU activation, and a Conv2D layer. W and b denote the weight matrix and bias vector of the linear transformation, respectively. hs and hns denote the similar and dissimilar components of the input feature, respectively (see Equations (8) and (9)). ps∗ and pns∗ denote the similar and dissimilar components of the selected prototype p∗, whose selection criterion is defined in Equation (14) below. ⊙ denotes element-wise multiplication. The prototype pool is organized in a class-wise manner. Let P={P1,P2,…,PK} denote the full prototype pool, where Pk={pk,j}j=1Jk is the prototype set of the k-th activity class. The prototype used for alignment is selected as(14)p∗=p∈Py,duringtraining,argminp∈Pd(s,p),duringinference, where y is the ground-truth label available during training, s denotes the decomposed feature used for prototype matching, and d(·,·) denotes the Euclidean distance. During training, the class-wise prototype set associated with the ground-truth label is used. During inference, the ground-truth label is unavailable, and the nearest prototype is selected from the full prototype pool according to the Euclidean distance. Since bucket query and key counts can vary, we enforce H(kj)=H(qj) by setting kj=qj∥qj∥ [5], where j indexes the token position, qj∈Rd is the query vector at position j, and kj is its ℓ2-normalized key. The queries are then sorted in two levels: first by bucket number and then by sequence position within each bucket. As seen in Figure 2e, sorting yields a rearranged attention matrix with queries in the same bucket clustered near the diagonal. First, a unique combination identifier is created for each query at position (a,t) by combining its bucket assignment and sequence position:(15)bpa,t=Np×ba,t+(τa,tmodNp). where a indexes the attention head and t indexes the token position within that head; bpa,t is the combined bucket–position identifier for the query at (a,t); ba,t is the bucket number assigned to that query; τa,t is the sequence-position index of the query; and Np is the sequence length, which is equal to the number of temporal patches defined in Section 3.2. To place tokens within each bucket in their original sequence order, the identifiers bpa,t are sorted while retaining the pre-sort position indices:(16)bp˜a,t,πa,t=sort(bpa,t,τa,t), where bp˜a,t is the sorted combination identifier and πa,t is the original position index retained after sorting. The sorted query matrix Q˜ is obtained by reordering the original query matrix Q according to the within-bucket position indices: (17)sta,t=πa,tmodNp,(18)Q˜=index_select(Q,st). where sta,t is the within-bucket sequence position and Q˜ contains the reordered query vectors. Finally, the attention output within each hash bucket is computed as(19)oi=∑j∈Biexpqi·kj−Z(i;Bi)vj, where Bi denotes the set of token positions that share the same hash bucket as query position i; qi, kj, and vj are the query, key, and value vectors at positions i and j, respectively; and Z(i;Bi) is the softmax normalization term. 3.4. Training Objective To classify the output features o, we employ a multi-channel convolutional network as a classifier. We include a margin loss term that maximizes the distance between prototype samples of different categories, thereby strengthening inter-class boundaries and improving the discriminability of the prototype representations in the feature space: (20)Lcls,o=−∑iyilogp^io,(21)Lmargin=12∑k≠k′max0,m − ∥pk−pk′∥2. where Lcls,o is the classification loss computed from the output feature o; yi is the ground-truth label and p^io is the predicted class probability for the i-th sample; Lmargin is the inter-class margin loss; pk and pk′ are prototype vectors of different activity classes (k≠k′); and m>0 is the margin threshold. We additionally compute a classification loss on the prototype samples p to prevent prototype degradation while optimizing the inter-class margin:(22)Lcls,pt=−∑iyilogp^ipt. where Lcls,pt is the classification loss of the prototype samples and p^ipt is the corresponding predicted class probability. The complete training objective combines the three losses above:(23)Ltotal=Lcls,o+λ1Lmargin+λ2Lcls,pt, where λ1>0 and λ2>0 are weighting coefficients that balance the contribution of the margin loss and the prototype classification loss, respectively. 4. Experiments We evaluated DSHformer on five public sensor-based human activity recognition (HAR) benchmarks and compared it with both HAR-specific baselines and recent Transformer-based time-series models. The experiments are designed to answer four questions: (i) whether DSHformer achieves competitive recognition performance under standard benchmark protocols; (ii) whether each proposed component contributes to the final performance; (iii) whether the model remains effective under subject-disjoint cross-user evaluation; and (iv) how the LSH-based attention module behaves in terms of hyperparameter sensitivity and practical efficiency. For fair comparison, DSHformer and all baseline models were implemented within the same experimental framework and trained and evaluated under the same data partition for each dataset. In the main benchmark comparison, WISDM and UniMiB-SHAR followed the preprocessed benchmark splits, UCI-HAR followed the official train/test split, PAMAP2 followed the common preprocessed subject/file split, and Opportunity followed the common benchmark split in which the ADL4/ADL5 sessions of subjects S2/S3 were used as held-out test files. For model selection, 10% of the training portion was randomly held out as the validation set, while the original test portion was kept untouched for final evaluation. Unless otherwise stated, the main benchmark comparison and ablation experiments were conducted with a fixed random seed of 42. The additional 10-run stability analysis is introduced after the main benchmark comparison. Therefore, the performance differences reported in the main comparison reflect model-level differences rather than differences in data partitioning. 4.1. Dataset and Evaluation Metrics Datasets. Datasets. We used five public sensor-based HAR benchmarks: WISDM [34], UCI-HAR [35], PAMAP2 [36], Opportunity [37], and UniMiB-SHAR (hereafter SHAR) [38]. These datasets cover different sequence lengths, sensor dimensions, and activity categories, providing a broad evaluation of the proposed framework. The dataset statistics are summarized in Table 1. Evaluation metrics. Evaluation metrics. We report three metrics: accuracy (Acc), class-average F1-score (Fm), and weighted F1-score (Fw). Accuracy measures the overall classification correctness across all classes:(24)Accuracy=∑c=1K(TPc+TNc)∑c=1K(TPc+TNc+FPc+FNc). where K denotes the number of activity classes, and TPc, TNc, FPc, and FNc denote the true-positive, true-negative, false-positive, and false-negative instances of class c, respectively. The class-average F1-score reflects the recognition performance for each individual activity class regardless of its prevalence in the dataset. It is defined as(25)Fm=1K∑c=1K2·Precisionc·RecallcPrecisionc+Recallc. where Precisionc=TPc/(TPc+FPc) and Recallc=TPc/(TPc+FNc) represent the precision and recall for class c, respectively. The weighted F1-score accounts for class imbalance by computing the F1-score for each class and averaging them with weights proportional to the number of samples in each class:(26)Fw=∑c=1KWc2·Precisionc·RecallcPrecisionc+Recallc. where Wc=nc/N, nc represents the number of samples in class c, and N denotes the total number of samples in the dataset. 4.2. Hyperparameter Selection and Complexity Discussion Table 2 summarizes the main hyperparameter settings of DSHformer on the five HAR datasets. These hyperparameters include the temporal patch length, the number of decomposition/hash layers, the number of LSH-based attention layers, the number of attention heads, and the hash bucket size. Here, P_Length denotes the length of each temporal patch used to construct the channel graph. Number_HF denotes the number of stacked decomposition/hash layers and the corresponding number of random projection matrices. Number_AL denotes the number of stacked LSH-based attention layers, Number_AH denotes the number of attention heads in each attention layer, and B_Size denotes the hash bucket size. Since B_Size and Number_HF are important hyperparameters of the LSH-based attention module, we further analyze their robustness under small perturbations in Section 4.6. The theoretical efficiency advantage of DSHformer mainly comes from the LSH-based attention module. Standard self-attention computes pairwise interactions among all temporal tokens, leading to O(L2) attention complexity. In contrast, the LSH-based attention module first assigns temporal tokens to hash buckets through random projections and then computes attention mainly within the selected buckets. Considering the bucket sorting and local attention operations, the theoretical attention complexity is reduced to approximately O(LlogL). Here, L denotes the sequence length (corresponding to T in Section 3). For the complete DSHformer model, the computational cost also includes patch-based channel–temporal feature extraction, prototype-guided decomposition, prototype matching, hash-code generation, bucket sorting, and local attention computation. Specifically, during the channel–temporal feature extraction stage, the input sequence of length L is divided into temporal patches of length n. If the compressed channel dimension is denoted by dc, constructing the channel-relation matrix for each patch introduces a cost proportional to Odc2nL. The subsequent patch-level temporal modeling operates on Ln tokens. In the decomposition and LSH-based attention stage, the decomposition network processes the patch-level temporal features with a cost proportional to ONhfLn, where Nhf denotes the number of stacked decomposition/hash layers (Number_HF in Table 2). The LSH-based attention module sorts the Ln patch tokens according to their hash buckets, which introduces a sorting cost of OLnlogLn, which is followed by local attention computation within hash buckets. Therefore, the O(LlogL) term mainly characterizes the asymptotic behavior of the LSH-based attention component. The practical inference cost of the full model can also be affected by the overhead of feature extraction, prototype matching, hashing, and sorting. This distinction is particularly important for short-window datasets such as Opportunity, where the sequence length is only L=30 and the overhead of hashing and sorting may partially offset the theoretical advantage. To avoid overstating the theoretical result, we further report on the full-model latency, memory usage, parameter counts, and attention-core benchmarks in Section 4.7. Table 3 provides a theoretical attention-complexity comparison between DSHformer and representative Transformer variants. It should be noted that Table 3 compares asymptotic attention complexity rather than full-model wall-clock latency. The latter is evaluated separately in Section 4.7, where we measure inference latency, memory usage, and parameter counts under different sequence-length settings. As shown in Table 3, DSHformer achieves the same asymptotic attention complexity as Reformer and Informer; the O(LlogL) complexity is therefore not a contribution of this work per se. The novelty lies instead in how LSH-based attention is integrated with the decomposition and prototype-alignment framework. Reformer [5] applies random-projection hashing directly to the input query vectors without any awareness of the underlying feature structure or task-specific semantics. Informer [27] reduces complexity through ProbSparse attention, which selects dominant queries based on a query–key divergence criterion designed for long-sequence forecasting rather than classification. In DSHformer, the random projections are applied to features that have already been decomposed into similar and dissimilar components relative to class-specific prototypes. This decomposition-stable hashing design ensures that tokens sharing similar temporal semantics as identified by the prototype-matching process are consistently assigned to the same hash bucket even after decomposition-induced attenuation of the feature representations. The HAR-tailored integration thus differs from both Reformer and Informer in the structural coupling between prototype-guided decomposition and hash-bucket formation rather than in the asymptotic complexity class itself. 4.3. Comparisons with the State of the Art Table 4 reports the main benchmark comparison on five public HAR datasets. All baselines and DSHformer are evaluated under the same split of each dataset, as described above. Therefore, the results in Table 4 compare model performance under a shared benchmark protocol rather than under different data partitions. The compared methods include HAR-specific models such as TCN [39] and Atten [6], frequency-domain and patch-based time-series models such as FreTS [40] and PatchTST [41], and Transformer-based variants such as Crossformer [42], ETSformer [43], iTransformer [44], Informer [27], Autoformer [23], Transformer [7], and Reformer [5]. For baseline implementation, models with publicly available official or author-released code were implemented based on their released repositories when available. For methods without directly reusable HAR classification code, we reimplemented the corresponding model architectures according to the original papers and adapted only the input embedding and final classification head to the HAR setting. All baselines used the same preprocessed inputs, training/validation/test partitions, optimizer type, batch size, maximum training epochs, early-stopping criterion, and evaluation metrics as DSHformer unless otherwise required by the original model design. Hyperparameters of the baseline models were set according to the recommendations in the original papers or tuned on the validation set under the same protocol. No baseline used additional training data, test-set information, or a different data partition. The three metrics Acc, Fm, and Fw are calculated according to Equations (24)–(26). The main benchmark results are reported in Table 4, and the 10-run stability analysis is reported separately in Table 5. As shown in Table 4, DSHformer achieves the highest reported accuracy on all five benchmarks with Acc values of 98.6%, 93.7%, 98.4%, 88.5%, and 96.6% on WISDM, UCI-HAR, PAMAP2, Opportunity, and SHAR, respectively. DSHformer also achieves the best or tied-best Fm and Fw values in most columns. These results indicate that the proposed combination of channel–temporal feature encoding, prototype-guided feature refinement, and LSH-based attention is effective under the adopted benchmark protocols. Compared with the vanilla Transformer, DSHformer improves the reported accuracy by 2.2, 2.9, 0.3, 2.0, and 2.8 percentage points on WISDM, UCI-HAR, PAMAP2, Opportunity, and SHAR, respectively. The 0.3 pp gain on PAMAP2 is within the observed run-to-run variance (Table 5) and is therefore not claimed as a reliable improvement. Compared with Reformer, the corresponding gains are 3.2, 3.7, 0.5, 1.1, and 9.9 percentage points. The gains are particularly pronounced on WISDM and SHAR, suggesting that the channel–temporal encoder and prototype-guided refinement are effective for extracting discriminative representations from relatively low-dimensional inertial signals. Beyond the fixed-seed main comparison, Table 5 further summarizes the stability of each model over 10 independent runs. DSHformer achieves the best worst-case accuracy on all five datasets. Its variance is also among the lowest in most settings, although the lowest variance is obtained by other baselines on WISDM, PAMAP2, Opportunity, and SHAR. These results suggest that DSHformer provides a favorable balance between average performance and run-to-run stability; we do not claim that it achieves the lowest variance in every case. To further address cross-user generalization, Table 6 reports an additional subject-disjoint comparison with representative Transformer-based baselines. In this setting, the subjects used for training, validation, and testing do not overlap. For WISDM, we used five folds over 36 subjects, with test subject groups 1–7, 8–14, 15–21, 22–28, and 29–36, and validation subjects 8–9, 15–16, 22–23, 29–30, and 1–2, respectively. For UCI-HAR and UniMiB-SHAR, we used five folds over 30 subjects with six test subjects and two validation subjects in each fold. For PAMAP2, we used a nine-fold subject-disjoint protocol over subjects 101–109: in each fold, one subject was used as the test subject, the next subject was used as the validation subject, and the remaining seven subjects were used for training; the test/validation pairs were 101/102, 102/103, 103/104, 104/105, 105/106, 106/107, 107/108, 108/109, and 109/101. For Opportunity, we used four folds over subjects 1–4 with test/validation pairs 1/2, 2/3, 3/4, and 4/1. However, the subject-disjoint result on Opportunity is different from the other four datasets. On this dataset, the Reformer-style sparse-attention baseline obtains the highest Macro-F1, while DSHformer performs worse than both Transformer and Reformer-style baselines. This negative result suggests that cross-user generalization remains challenging for very short and high-dimensional sensor sequences, such as Opportunity with sequence length L=30 and 113 sensor axes. We therefore treat the subject-disjoint Opportunity result as an important limitation rather than over-claiming uniform cross-user superiority. The selected baselines cover complementary modeling strategies. TCN captures multi-scale temporal patterns with dilated convolutions, Atten introduces attention-based regularization for wearable HAR, FreTS models time-series patterns in the frequency domain, and PatchTST uses patch-wise time-series modeling. The Transformer-based models provide representative comparisons for full attention, sparse or efficient attention, frequency-enhanced decomposition, and cross-dimension dependency modeling. The recent AutoHFormer [45], an efficient hierarchical autoregressive Transformer for time-series prediction, was considered but not included as a direct baseline: its design targets causal long-horizon forecasting through hierarchical temporal modeling, intra-segment autoregressive refinement, dynamic windowed attention with exponential decay, and adaptive multi-scale temporal encoding. Its core objective—predicting continuous future values under strict temporal causality—differs fundamentally from the fixed-window single-label classification task in sensor-based HAR. Adapting AutoHFormer to HAR would require replacing its autoregressive forecasting objective and multi-step output head with a discriminative classification head, substantially altering the original model and making any comparison implementation-dependent; we therefore cite AutoHFormer as a relevant recent efficient time-series Transformer and note its faithful adaptation to HAR classification as a direction for future work. Compared with the included methods, DSHformer achieves strong recognition performance under the standard benchmark protocol and competitive subject-disjoint performance on most datasets. The efficiency of the LSH-based attention module and the practical full-model cost are analyzed separately in Section 4.7. 4.4. Ablation Studies, Visualization, and Analysis Table 7 reports the component-level ablation results under the standard benchmark protocol. The Transformer is used as the reference baseline. Ours (MT) keeps only the patch-based channel–temporal feature extraction module. Ours (att) keeps the decomposition network and the LSH-based attention module without the patch-based channel–temporal encoder. Ours (MT + att) combines the channel–temporal encoder with the decomposition-guided LSH-based attention module. Ours (att + Ltotal) further introduces the total training objective, including the prototype-related regularization terms. Ours (full) denotes the complete DSHformer model. As shown in Table 7, Ours (MT) improves over the vanilla Transformer on WISDM, UCI-HAR, and SHAR, indicating that the patch-based channel–temporal encoder provides an effective representation for wearable sensor signals. On Opportunity, however, Ours (MT) obtains lower accuracy than the Transformer. This result suggests that channel–temporal encoding alone is not sufficient for all datasets especially when the sequence length is short and the sensor dimension is high. Ours (att) contains the decomposition network and the LSH-based attention module but does not use the proposed patch-based channel–temporal encoder. Its performance is lower than the full model on all five datasets. This indicates that the LSH-based attention module requires informative patch-level representations as input; using the attention and decomposition modules alone cannot fully recover the temporal and cross-channel information needed for HAR. Ours (MT + att) combines the channel–temporal encoder with the decomposition-guided LSH-based attention module. This variant improves over Ours (MT) on Opportunity in terms of Acc and Fm, reaching 0.882 and 0.816, respectively. It also achieves strong performance on SHAR, with Acc, Fm, and Fw values of 0.958, 0.932, and 0.954, respectively. However, its performance is still lower than Ours (full) on all five datasets, indicating that the complete training objective and prototype-related regularization remain important. Ours (att + Ltotal) adds the total training objective to the attention-based variant. Compared with Ours (att), this setting improves several metrics, especially on SHAR and Opportunity, which suggests that the prototype-related loss terms help regularize the representation space. Nevertheless, without the patch-based channel–temporal encoder, its performance remains lower than the full model on most datasets. The full DSHformer model achieves the best overall results in Table 7, confirming that the three main components are complementary: the patch-based encoder provides compact channel–temporal representations, the decomposition-guided LSH-based attention module refines the temporal features, and Ltotal regularizes both the classifier output and the prototype representations. To further examine whether prototype alignment contributes to cross-user generalization, Table 8 compares the full model with a variant that disables prototype alignment under the subject-disjoint protocol. In this setting, the training, validation, and test subjects do not overlap. The w/o Prototype variant disables the prototype alignment path and removes the prototype auxiliary classification loss. The full model consistently outperforms w/o Prototype on all five datasets. On average, prototype alignment improves Acc, Fm, and Fw by 0.0267, 0.0308, and 0.0266, respectively. These subject-disjoint ablation results provide additional evidence that the prototype mechanism is not only beneficial under the standard benchmark protocol but also contributes to unseen-subject evaluation. The improvement in Macro-F1 is numerically largest on PAMAP2 and Opportunity (0.0489 and 0.0510, respectively); however, given the large cross-fold standard deviations on these two datasets (see Table 8), these gains should be interpreted with caution and their statistical significance verified. The absolute subject-disjoint performance on Opportunity remains lower than on the other datasets, which is consistent with the observation in Table 6 that short and high-dimensional sensor sequences remain challenging for cross-user generalization. We further provide qualitative visualizations to support the above quantitative findings. Figure 3 provides an illustrative comparison of the training and testing behavior of the vanilla Transformer and DSHformer. Compared with the baseline Transformer, DSHformer shows a smaller train–test gap in this example, suggesting a reduced tendency to overfit the training data. Figure 4 presents the confusion matrices of DSHformer on the five HAR benchmarks. The diagonal patterns indicate that most samples are correctly classified, while the remaining off-diagonal entries mainly correspond to activities with similar motion patterns. The goal of the patch-based channel–temporal encoder is to aggregate related information across sensor channels and temporal patches. Figure 5 visualizes the feature correlation matrices before and after the encoder. The correlation matrix is computed as xx⊤, where x denotes the feature matrix and ⊤ denotes the matrix transpose. In the illustrated UCI-HAR example, the input features show relatively weak correlations across time steps before encoding. After channel–temporal encoding, the correlations become more structured, indicating that the encoder aggregates related temporal and channel-wise information into more coherent feature representations. Figure 6 visualizes the temporal decomposition results on a representative variable channel from UCI-HAR. The decomposition network is designed to separate similar and dissimilar components between the input features and the selected prototype features. In the visualization, the similar component exhibits smoother temporal variations, whereas the dissimilar component contains more oscillatory patterns. This qualitative result is consistent with the intended role of the decomposition module: preserving shared activity-related patterns while separating residual or less aligned information. As shown in Figure 7, we further visualize the t-SNE distributions of training and testing samples from the five datasets before model input, after feature extraction, and after prototype-guided alignment. Before model processing, the samples are more dispersed and class boundaries are less clear. After feature extraction, samples of the same class tend to form more compact clusters. After prototype-guided alignment, the training and testing distributions become visually more comparable in several datasets, suggesting that the proposed alignment mechanism can reduce part of the distribution discrepancy. This visualization should be interpreted as qualitative evidence, while the quantitative subject-disjoint results provide a stricter evaluation of cross-user generalization. As shown in Figure 8, we visualize the attention matrices produced by the LSH-based attention module. Compared with the full attention matrix of the vanilla Transformer, the LSH-based attention matrix has a different sparsity pattern because attention is computed only among tokens assigned to the same hash bucket. As discussed in Section 3.3, the implementation sets kj=qj/∥qj∥, which guarantees H(kj)=H(qj); the diagonal entries of the visualized LSH-based attention matrix are therefore zero. In addition, blank cells in the LSH-based attention matrix indicate token pairs that are not involved in attention computation due to different hash assignments, whereas blank cells in the Transformer attention map mainly correspond to very small attention weights. The sparsity patterns also vary across datasets. For example, the attention matrix on SHAR is visually denser than that on WISDM. This is consistent with the dataset-specific bucket sizes reported in Table 2: the bucket sizes for WISDM, UCI-HAR, PAMAP2, Opportunity, and SHAR are 2, 8, 8, 4, and 32, respectively. Therefore, larger bucket sizes allow more tokens to participate in local attention within the same bucket, leading to denser attention maps. Overall, Figure 8 illustrates how LSH-based attention reduces unnecessary pairwise computations by restricting attention to tokens with the same hash assignment. 4.5. Effect of Feature Extraction Order To further examine the design of the channel–temporal feature encoder, we compare three feature extraction orders: Joint, Temporal-First, and Channel-First. The Joint structure extracts channel and temporal features in parallel, the Temporal-First structure first models temporal patterns and then incorporates channel information, and the Channel-First structure first models inter-channel relationships before temporal feature extraction. Figure 9 provides a visual comparison of the three structures, and Table 9 reports their quantitative results on the five HAR benchmarks in terms of Acc, Fm, and Fw. As shown in Table 9, the Joint structure achieves competitive performance on all five datasets, with accuracies of 97.3%, 92.4%, 98.0%, 86.1%, and 95.3% on WISDM, UCI-HAR, PAMAP2, Opportunity, and SHAR, respectively. This result indicates that jointly considering channel and temporal information is beneficial for HAR, but direct joint modeling does not consistently provide the best performance across datasets. The Temporal-First structure improves over the Joint structure on WISDM, Opportunity, and SHAR in terms of accuracy, reaching 98.5%, 86.7%, and 95.5%, respectively. However, its performance decreases on UCI-HAR and PAMAP2. This suggests that extracting temporal patterns before channel interaction can be effective for some datasets, but it may also weaken the modeling of inter-channel relationships when channel correlations are important for activity discrimination. The Channel-First structure achieves the best performance across all five datasets. It obtains accuracies of 98.6%, 93.7%, 98.4%, 88.5%, and 96.6% on WISDM, UCI-HAR, PAMAP2, Opportunity, and SHAR, respectively. It also achieves the highest Fm and Fw values in all reported settings. These results support the encoder design used in DSHformer, where inter-channel relationships are modeled before patch-level temporal refinement. This order allows the model to first capture dependencies among sensor axes or modalities and then use the resulting channel-aware representations for temporal modeling. Overall, the comparison in Table 9 shows that the order of feature extraction has a clear influence on HAR performance. The Channel-First design provides the most consistent results across datasets with different numbers of sensor axes and sequence lengths. This observation is consistent with the characteristics of wearable sensor data, where multiple channels often describe complementary aspects of the same physical motion. Modeling these channel relationships before temporal aggregation can therefore provide more informative inputs for subsequent sequence modeling. 4.6. Sensitivity Analysis of LSH Hyperparameters To analyze the robustness of the LSH-based attention module, we conduct a sensitivity study on two important hyperparameters: the hash bucket size B_Size and the number of hash/decomposition layers Number_HF. These two hyperparameters control the granularity of hash-based token grouping and the number of random projection rounds. Since overly small buckets may restrict useful token interactions and overly large buckets may reduce the sparsity benefit of LSH-based attention, it is important to examine whether the model remains stable under small perturbations. We perform this analysis on UCI-HAR and Opportunity. UCI-HAR has a moderate sequence length (L=128) and relatively low sensor dimension, whereas Opportunity has a very short sequence length (L=30) and a high sensor dimension of 113 axes. These two datasets therefore provide representative settings for evaluating the sensitivity of the LSH-based attention module under different temporal and channel conditions. Table 10 reports the results. As shown in Table 10, DSHformer is relatively stable on UCI-HAR under small changes of B_Size and Number_HF. Across the tested settings, the Macro-F1 ranges from 0.8924 to 0.9181, and the Acc ranges from 0.8951 to 0.9192. The best UCI-HAR result is obtained when B_Size is 4 and Number_HF is 2, but the other settings also remain close to this value. This indicates that the model is not highly sensitive to a single fixed bucket size on UCI-HAR. The behavior on Opportunity is more sensitive. The best Macro-F1 is obtained when B_Size is 4 and Number_HF is 1, while increasing Number_HF to 2 under the same bucket size leads to a clear performance drop. This is consistent with the characteristics of Opportunity: the sequence length is very short (L=30), while the sensor dimension is high. Under such a setting, additional hash/decomposition rounds may introduce extra grouping and sorting overhead without providing enough long-range temporal context to compensate for it. Overall, the sensitivity results suggest that DSHformer is reasonably robust to small hyperparameter perturbations on moderate-length sensor sequences, while short-window and high-dimensional datasets require a more careful selection of B_Size and Number_HF. This also motivates future work on adaptive or dataset-agnostic bucket/hash selection strategies. 4.7. Efficiency Analysis To further examine whether the theoretical complexity advantage of LSH-based attention leads to practical efficiency gains, we conduct two types of efficiency experiments. First, we compare the full-model inference cost of DSHformer and the vanilla Transformer under real HAR dataset configurations. Second, we isolate the attention operation and compare full attention with bucketed attention under different sequence lengths. This design allows us to distinguish between the theoretical attention-level advantage and the practical wall-clock cost of the complete HAR model. We include the vanilla Transformer in the full-model benchmark; a full-model wall-clock comparison with the original Reformer architecture is not included because the Reformer-style baseline used in our HAR experiments is a sparse-attention adaptation of the pipeline rather than a complete reproduction of the original Reformer (see Table 6 footnote), and the attention-core benchmark captures the relevant efficiency difference at the attention-mechanism level. Table 11 reports the full-model efficiency comparison under the real configurations of Opportunity and UCI-HAR. The results show that the current full DSHformer implementation has more parameters, higher inference latency, and higher peak memory usage than the vanilla Transformer. This is especially clear on Opportunity, where the sequence length is only L=30. Although the LSH-based attention module reduces the theoretical attention complexity, the complete model also includes channel–temporal feature extraction, prototype matching, decomposition, hashing, bucket sorting, and local attention computation. Therefore, the attention-level complexity advantage does not directly imply full-model latency advantage, particularly for short-window datasets. Table 12 reports the attention-core benchmark under controlled sequence lengths. For short sequences (L=32, 64, and 128), bucketed attention does not provide a latency advantage because the overhead of hashing, bucket assignment, and sorting is comparable to or larger than the cost saved from sparse attention computation. However, as the sequence length increases, the advantage of bucketed attention becomes clear. At L=256, bucketed attention is 2.47× faster and uses 3.32× less memory than full attention. At L=1024, it is 12.48× faster and reduces memory usage by 14.75×. These two efficiency experiments lead to a more precise interpretation of the proposed method. The LSH-based attention core provides clear speed and memory advantages for longer sequences, which supports the theoretical O(LlogL) attention-complexity analysis. However, the current full DSHformer implementation still incurs additional overhead from feature extraction, prototype-guided decomposition, prototype matching, hashing, and sorting. Therefore, DSHformer should not be interpreted as being faster than the vanilla Transformer in all practical settings. Instead, the empirical results show that the attention-level advantage becomes more useful as the sequence length increases, while short-window datasets such as Opportunity remain affected by implementation overhead. 5. Conclusions We presented DSHformer, which is a Transformer-based framework for sensor-based human activity recognition that jointly considers compact channel–temporal representation learning, prototype-guided feature refinement, and efficient sequence modeling. The framework integrates three complementary components: (i) a low-parameter patch-based graph-attention encoder that jointly models inter-channel correlations and temporal dynamics; (ii) a prototype pool coupled with a multi-layer decomposition network that refines input representations through prototype matching and is further regularized by an inter-class margin loss; and (iii) a decomposition-guided LSH-based attention mechanism tailored for HAR, which couples prototype-guided feature decomposition with locality-sensitive hashing to ensure that semantically related tokens remain grouped throughout the attention computation, retaining the O(LlogL) attention-level complexity of LSH-based attention. Extensive experiments on five public benchmarks—WISDM, UCI-HAR, PAMAP2, Opportunity, and SHAR—show that DSHformer achieves competitive or superior performance compared with HAR-specific baselines and recent Transformer variants under the adopted benchmark protocols. Ablation studies further validate the contribution of the main components, and additional analyses examine subject-disjoint generalization, LSH hyperparameter sensitivity, and practical efficiency under different sequence lengths. Limitations. Limitations. Despite the promising results, this paper has several limitations that warrant further investigation. First, the main benchmark experiments follow the standard or commonly used evaluation protocols of the public HAR datasets, and all baseline models are evaluated under the same data splits for fair comparison. Nevertheless, such benchmark protocols do not always fully reflect the more challenging unseen-user deployment scenario. We therefore added subject-disjoint experiments to further examine cross-user generalization, but more exhaustive LOSO evaluation across all possible subject folds remains an important direction for future work. Second, the prototype pool grows linearly with the number of activity classes, so scalability to fine-grained or open-set HAR scenarios with dozens of classes has not been systematically studied. Third, although the LSH-based attention module reduces the theoretical complexity of attention computation to O(LlogL), the practical inference cost of the full model also includes feature extraction, prototype matching, hashing, bucket sorting, and other implementation overhead. Therefore, the empirical efficiency gain is sequence-length dependent: it is more evident for relatively long sequences, whereas for very short windows such as Opportunity (L=30), the overhead of hashing and sorting can partially offset the theoretical advantage. Fourth, our current evaluation is mainly based on inertial-sensor modalities, such as accelerometers, gyroscopes, and magnetometers. Extending DSHformer to richer physiological or multimodal sensing settings, such as sEMG, PPG, or heterogeneous sensor fusion, requires further architectural adaptation. Finally, the hyperparameters of the LSH-based attention module, particularly the bucket size and the number of hash rounds, are currently selected at the dataset level. Although the added sensitivity analysis shows that the model is reasonably stable under small perturbations in several settings, an adaptive or dataset-agnostic bucket/hash selection strategy would make the framework easier to deploy in practice. Future Work. Future Work. Building on the above limitations, several directions deserve further exploration. First, for cross-user and cross-device HAR, future work will conduct more exhaustive LOSO evaluation and investigate domain adaptation techniques to improve robustness across different users, devices, and deployment environments. Second, for real-time and low-latency inference, we plan to explore model compression, quantization, and hardware-aware optimization of the LSH-based attention module and the prototype matching process. Third, for irregularly sampled and multimodal time series, future work will investigate adaptive interpolation, continuous-time sequence modeling, and modality-specific fusion strategies. Overall, this paper provides a practical step toward accurate and efficient sensor-based HAR while also identifying several important directions for improving cross-user robustness and deployment efficiency.