# BSTCA-HAR: Human Activity Recognition Model Based on Wearable Mobile Sensors
## 3 Methods
### BSTCA-HAR Prediction Modeling  
Based on the proposed improvement of the LSTM neural network, a BSTCA-HAR action recognition model combining attention mechanism and TCN parts is proposed. BiLSTM is used as a network layer for feature extraction and preprocessing of the input sequence data, which is a three-dimensional tensor, (i.e., Samples, Time_Steps, and Features), with one processing the sequence front-to-back and the other processing it back-to-front, leading to a better understanding of the context and coherence of the actions and capturing the bidirectional information in the action sequences during action recognition.  
With the expansion of network depth and iterations, the weights change too quickly for a network degradation effect to appear. We introduce the TCN to deal with time series that become too long by using the reusable convolutional layer module and residual connection to solve the problem of training difficulties' however, it is easy for the model to ignore key time points or features. The key time points or features can be automatically identified incorporation of the attention layer, thereby enhancing the precision of the HAR framework. Figure 1 depicts the BSTCA-HAR model's network structure.  
The bidirectional LSTM layer in the BSTCA-HAR model receives a three-dimensional tensor as its input. To align with the expected input dimensions of the TCN layer, the input samples introduced for the TCN layer are similarly structured as a three-dimensional tensor. As a result, there is no need to resize or scale the output of the BiLSTM layer to fit these dimensions, which streamlines the model's architecture. The causal convolution process within the TCN layer performs advanced feature refinement on the feature representation from the preceding layer, facilitating a deeper level of feature extraction.  
It is worth noting that the architecture outlined in this study substitutes for the traditional fully connected layer with a global average pooling (GAP) layer subsequent to a 1D convolutional layer. The GAP layer efficiently conducts a global average pooling operation across each feature map, ensuring a streamlined process with no additional optimization parameters required within the layer itself. This improvement reduces the number of parameters for model training from 81,382 to 34,631, which substantially reduces the consumed memory and computational cost and somewhat simplifies the model structure while maintaining the model performance. In addition, we incorporate a batch normalization (BN) layer subsequent to the GAP layer, aiming to expedite the model's  
Figure 1: Framework diagram of the BSTCA-HAR model.  
convergence and solve the problem of network training difficulty due to the changing input data distribution in each layer. Finally, the computational results of the attention network layer are output through the dense layer, and the output serves as an indication of the probability of the present sample being part of a specific class. The equation is stated as follows:  
\[S_{j}=\frac{e^{a_{j}}}{\sum_{k=1}^{N}e^{a_{k}}} \tag{10}\]  
where \(N\) represents the total number of categories and \(a_{j}\) specifically refers to the \(j\)-th value within that output vector.