# Human Activity Recognition Method Based on Edge Computing-Assisted and GRU Deep Learning Network
## 3 Methods
### EleAttG-GRU Block for More Accurate HAR Prediction  
Standard RNN (sRNN), LSTM, GRU, etc., have proven to be effective for working on sequence information, such as human activity recognition [5]. Additionally, according to research, the attention mechanism that selectively focuses on different data elements is also effective for human activity recognition. Therefore, combining the gating mechanism and attention, we use an Element-wise-Attention Gate to provide attention to RNN neurons, allowing these RNN neurons to gain the ability to adaptively focus on the key elements of the input. We use a shareable EleAttG with the same dimension of the output attention  
Figure 2: Improved O-Inception module. vector as the input to apply to all neurons of the RNN block. The original input undergoes modulation by the attention vector, thereby amplifying the significance of crucial information on the analysis results. Recurrent neural networks can model the spatial correlation and temporal dynamics of time series. To better illustrate the features of EleAttG-GRU, we briefly compare it with the widely used RNN structure. The output response \(r_{t}\) of time step \(t\) is calculated from the input \(x_{t}\) of this layer, and the output \(r_{t}\) of the last phase is as follows:  
\[r_{t}=tanh(W_{xx}x_{t}+W_{rr}r_{t-1}+\varepsilon_{r}) \tag{8}\]  
where \(W_{ab}\) represents the weight matrix related to \(a\) and \(b\), and \(\varepsilon_{c}\) is the bias vector, \(a\in\{x,r\}\), \(b\in\{r\}\) and \(c\in\{r\}\). We use EleAttG to give RNN neurons attention ability. \(a_{t}\) is a response vector, and its dimension is the same as the previous RNN's input \(x_{t}\). The calculation formulas are as follows:  
\[a_{t}=\varphi(W_{xa}x_{t}+W_{ra}r_{t-1}+\varepsilon_{a}) \tag{9}\]  
where \(\varphi\) represents the activation function of Sigmoid. The importance level of the input \(\widetilde{x_{t}}\) is determined by the current input \(r_{t-1}\) and the previous hidden state \(x_{t}\). By means of the attentional response mechanism, the input \(x\) is updated, represented as:  
\[\widetilde{x_{t}}=x_{t}\odot a_{t} \tag{10}\]  
Afterwards, the GRU network will perform a recursive calculation based on updated input \(x\). The GRU is a type of RNN that was designed to tackle the problems of gradient vanishing and long-term memory. It consists of two types of gates: update gates and reset gates. The former determines how much of the previous state's information should be carried over to the current state, while the latter controls how much of the new input should be incorporated into the current state. When EleAttG is added to GRU blocks, it endows RNN neurons with the ability to selectively attend to key elements in the input sequence. The calculation formulas for EleAttG-GRU blocks are as follows:  
\[r_{t}=\sigma(W_{r}\odot[h_{t-1},a_{t}\odot x_{t}]+\varepsilon_{r}) \tag{11}\]  
\[z_{t}=\sigma(W_{z}\odot[h_{t-1},a_{t}\odot x_{t}]+\varepsilon_{z}) \tag{12}\]  
\[\widetilde{h_{t}}=tanh(W\odot[r_{t}\times h_{t-1},a_{t}\odot x_{t}]+\varepsilon _{h}) \tag{13}\]  
\[h_{t}=h_{t-1}+z_{t}\Big{(}\widetilde{h_{t}}-h_{t-1}\Big{)} \tag{14}\]  
where \(h_{t}\) refers to the output vector of the hidden state. \(r_{t}\) is the reset gate and \(z_{t}\) is the update gate. \(a_{t}\) is a response vector, \(W\) represents the corresponding weight matrix, \(tanh\), and \(\sigma\) denotes Activation functions. \(\widetilde{h_{t}}\) is the vector after being activated, and \(\varepsilon\) is the bias vector. Figure 3 illustrates the EleAttG-GRU structure with Element-Wise-Attention. The EleAttG is marked in red, the GRU network structure is marked in green, the calculation unit is marked in yellow, and each line represents a vector. We use the response of \(a_{t}\), the EleAttG, to modulate \(X_{t}\) to \(\widetilde{X_{t}}\), and then replaced \(X_{t}\) with \(\widetilde{X_{t}}\) to perform the follow-up. this can be defined as the EleAttG-GRU.