## 3 Methodology
### Long Short-Term Memory Model  
For the intent prediction module, we use RNN-LSTM units [25]. RNNs (Recurrent Neural Networks) are based on processing sequential data, especially temporal data as they have an internal memory. In fact, they are useful for making predictions using time-series data [23]. RNNs can be improved by using what are called LSTM units in order to solve the vanishing gradient problem (i.e., gradients tend to disappear in RNNs when backpropagating errors in too long sequences). In fact, each LSTM unit has a special structure composed by 3 gates to control what information to keep and what to forget so that more stable errors are backpropagated (see Figure 5):  
1. An input gate (i).
2. An output gate (o).
3. A forget gate (f).  
As a result, RNNs with LSTM units are able to learn long-term dependencies within data sequences that were not possible only with RNNs. Given an input sequence \(\bar{x}_{1},\bar{x}_{2},...,\bar{x}_{t}\) the LSTM unit maps the input sequence to a sequence of hidden states \(h_{1},h_{2},...,h_{t}\) (which are also the outputs) by passing information through a combination of gates (see Figure 6):  
The Input gate (for updating the cell) is:  
\[i_{t}=\sigma_{g}(W_{i}\bar{x}_{t}+R_{i}h_{t-1}+b_{i}) \tag{9}\]  
The Forget gate (for reseting the cell/forgetting) is:  
\[f_{t}=\sigma_{g}(W_{f}\bar{x}_{t}+R_{f}h_{t-1}+b_{f}) \tag{10}\]  
Figure 4: Torque-based impedance control.  
Figure 3: Admittance control (position-based impedance control).  
The Cell candidate (for adding information to the cell) is:  
\[g_{t}=\sigma_{c}(W_{g}g_{t}+R_{g}h_{t-1}+b_{g}) \tag{11}\]  
where \(\sigma_{c}\) is the state activation function (here it is the hyperbolic tangent function: \(\sigma_{c}=tanh(\bar{x})\)).  
The Output gate is:  
\[o_{t}=\sigma_{g}(W_{o}\bar{x}_{t}+R_{o}h_{t-1}+b_{o}) \tag{12}\]  
where \(\sigma_{g}\) is the gate activation (here it is the sigmoid function: \(\sigma(x)=(1+e^{-\pi})^{-1}\))  
The Memory Cell state at timestep \(t\) is:  
\[c_{t}=f_{t}\odot\sigma_{t-1}+i_{t}\odot g_{t} \tag{13}\]  
Here \(\odot\) is the Hadamard product (element-wise multiplication of vectors). The memory cell selectively retains information from previous timesteps by controlling what to remember via the forget gate \(f_{t}\).  
The Hidden state (also called Output state) at time step \(t\) is :  
\[h_{t}=o_{t}\odot\sigma_{c}(c_{t}) \tag{14}\]  
The hidden state is passed as input to the next timestep and thus, it is possible to stack numerous LSTM units (see Figure 6). \(W_{i},W_{f},W_{g}\) are the learnable input weights; \(R_{i},R_{f},R_{g}\) are the learnable recurrent weights and \(b_{i},b_{f},b_{g}\) are the learnable bias. By using memory cells and hidden states, LSTM units are able to retain information. The sigmoid function is a good activation function for the 3 gates (In, Out and Forget) since it outputs a value between 0 and 1. However for the memory cell, the values should be able to increase or decrease (which is not possible with the sigmoid activation function whose output is  
Figure 5: A single LSTM unit.  
Figure 6: An unrolled Recurrent Neural Network with LSTM units.  
always non-negative). Therefore, the hyperbolic tangent function (_tanh_) is used as the activation function for the memory cell.