# Trajectory Planning for a Mobile Robot in a Dynamic Environment Using an LSTM Neural Network
## 2 Materials and Methods
### LSTM Neural Network  
LSTM is a notable variant of an RNN that has been employed in many applications of sequence data. An LSTM has the advantage of having a continuous space memory which allows it to use the arbitrary length of past observations for sequence predictions [20].  
Recently, the LSTM model has been applied to analyze vehicle trajectory sequences, as it effectively overcomes the vanishing gradient issue in naively designed RNNs [18]. A deep neural network (DNN) is an ANN with multiple layers between the input and output layers. In some cases, the neurons in the lower layers of a multi-layered network can hardly be updated or they even die, which blocks the DNNs from going deeper between the layers [21]. This is known as vanishing gradients, and they occur when the learning signals tend to zero with an increase in the number of layers in the DNN [22].  
The LSTM network model consists of the cell memory that stores the summary of the past input sequence, and the gating mechanism by which the information flow between the input, output, and cell memory are controlled [23].  
The following recursive equations describe how the LSTM works [18]:  
\[f_{t}=\sigma(W_{uf}u_{t}+W_{hf}h_{t-1}+b_{f}). \tag{2}\]  
\[i_{t}=\sigma(W_{ui}u_{t}+W_{hi}h_{t-1}+b_{i}) \tag{3}\]  
\[o_{t}=\sigma(W_{uo}u_{t}+W_{ho}h_{t-1}+b_{o}). \tag{4}\]  
\[c_{t}=f_{t}\;\odot\;c_{t-1}+i_{t}\;\odot\tan h(W_{uc}u_{t}+W_{hc}h_{t-1}+b_{c}). \tag{5}\]  
\[h_{t}=o_{t}\;\tan h\odot(c_{t}). \tag{6}\]  
where \(\sigma(x)\triangleq\frac{1}{1+\exp(-x)}\) represents the sigmoid function (element wise), which is used as a powerful tool in the LSTM Model [23; 24]; \(x\odot y\) is the element wise product; \(u_{t}\) the input vector at current timestamp \(t\); \(h_{t-1}\) is the output of the previous LSTM block (timestamp \(t-1\)); \(W_{ui}\), \(W_{hi}\), \(W_{uf}\), \(W_{hf}\), \(W_{uo}\), \(W_{ho}\), \(W_{uc}\), and \(W_{hc}\) correspond to the linear transformation with weight matrices; \(b_{t}\), \(b_{f}\), \(b_{o}\), and \(b_{c}\) are the bias vectors; \(i_{t}\), \(f_{t}\), and \(o_{t}\) are the gating vectors; \(c_{t}\) is the cell memory state vector; and \(h_{t}\) is the state output vector. The gating vectors (2), (3), and (4) determine the amount of information for the cell memory to update, forget, and output its state. Then, the cell state and output are updated according to (5) and (6). The cell state can be reset or restored depending on the state of the forget gating vector. The two gating vectors \(i_{t}\) and \(o_{t}\) work in a similar way to regulate the input and output [18].  
To sum up, the LSTM model is an ANN architecture that has managed to prove to overcome the vanishing gradient issue. It consists of three gates: the input, forget and output gates. These gates are the sigmoid activation function, meaning that they output a value between 0 and 1. The sigmoid function is used to obtain only positive output values  
Figure 2: Recurrent neural network.  
if certain features are needed to be kept or not, meaning that a value of 0 is going to be obtained if the gate blocks everything and a value of 1 is going to be obtained if the gate allows everything to pass through it. The forget gate (2) indicates which information will be thrown away, while (3) designates what new information is going to be stored in the cell state for the input gate. The output gate (4) provides the activation for the final output of the LSTM block at timestamp \(t\) (Figure 3) [25].  
Lastly, the cell state is filtered and passed through the activation function which predicts what portion appears as the output of the current LSTM unit at timestamp \(t\). The state output vector \(h_{t}\) passes from the current block through the SoftMax layer to get the predicted output \(y_{t}\) (Figure 4) [25].  
It is common to append a SoftMax function as the final layer of a neural network as it converts the output real-valued scores to a normalized probability distribution that can be displayed to a user or used as input for other systems [26].