## 3 The Conventional and Proposed UWB Localization Approaches
### LSTM Based UWB Localization
The error function from Figure 7 is expressed in time dimension and layer structure and is given by  
\[E_{t}=\sqrt{\left(x_{t}-\tilde{x}_{t}\right)^{2}+\left(y_{t}-\tilde{y}_{t} \right)^{2}}. \tag{26}\]  
The input of LSTM network is the combination of \(h_{(t-1)}\) and \(D_{(xt,yt)},W_{f},W_{g},W_{c}\) and \(W_{o}\). These values can be divided into \(W_{f}x,W_{f}h,W_{g}x,W_{g}h,W_{c}h,W_{f}ox\) and \(W_{o}h\). An example of backpropagation using \(W_{o}h\) is expressed as  
\[\frac{\partial E_{t}}{\partial W_{oh,t}}=\frac{\partial E_{t}}{\partial net_{ o,t}}\times\frac{\partial net_{o,t}}{\partial W_{oh,t}} \tag{27}\]  
\[\frac{\partial E_{t}}{\partial W_{oh,t}}=\delta_{o,t}^{T}\times h_{t-1}^{T} \tag{28}\]  
\[f_{t}=\sigma\left(w_{f}\times\left[h_{t-1},D_{xt,yt}\right]+b_{f}\right), \tag{20}\]0 Forward propagation of long short-term memory (LSTM). \[f_{t}=\sigma\left(w_{f}\times\left[h_{t-1},D_{xt,yt}\right]+b_{f}\right), \tag{20}\]1  
where \(\delta_{t}^{T}\) is the error term in time dimension of layer o and is expressed as  
\[f_{t}=\sigma\left(w_{f}\times\left[h_{t-1},D_{xt,yt}\right]+b_{f}\right), \tag{20}\]2  
The LSTM network builds the regression model based on the iteration and the initial weight settings. The ReLu function in the model reduces the vanishing gradient problems and converges faster than RNN models. The localization algorithm using LSTM network is summarized in Algorithm 1. Input: \(D_{(xt,yt)}\) in each time slot, \(M\)  
output: Regression model based on LSTM  
1. Collect the distance values from the trajectory when the user moves and repeat this step until the amount of data in this trajectory is enough. 2. Generate the distance database in each time slot
3. Initialize the structure of LSTM
4. Train LSTM and compute the LSTM parameters
5. Collect distance data for testing, then verify the trained LSTM model in step 4
6. Change the LSTM parameters and estimate the best parameters for accurate localization using steps 5 and 6. **Algorithm 1** LSTM Based Localization. From Algorithm 1, it can be seen that the proposed approach uses the distance values from anchors to tag for localization. When the UWB system reaches the enough number of distance data from the simulation trajectory, the system initializes the two-layer LSTM model. The total amount of data collected from the trajectory is divided into train data and test data. The LSTM model uses the train data for training the model with initial hyperparameter settings. Next, the system changes the hyperparameter values by several simulations and reach the best LSTM hyperparameter values for localization. After the hyperparameter estimation, the system collects another set of data for testing. Using the test data, the system verifies the LSTM model and predicts the user positions. Localization using the LSTM model is efficient when the user moves a certain trajectory in the experiment area. Figure 8 shows the LSTM structure used for the localization. The model structure of LSTM from Figure 8 shows that the proposed model uses two LSTM layers after the input layer. The two LSTM layers improve the performance of our model and gives reasonable position results than conventional neural network models. To compensate the overfitting problem, we add a dropout layer after each LSTM layer and these dropout layers enhance the localization accuracy of our proposed model. For the last layer of the proposed network, we use a time distributed dense layer which enables an interaction between the values within its own timesteps.