## 4 The Vehicle Trajectory Prediction Model
### Vehicle Historical Trajectory Encoder  
In addition to the vehicle-vehicle motion interaction, the vehicle historical trajectory is also very important and should not be ignored. Particularly when there are only a few traffic participants around, its historical trajectory can reflect the drivers' behavioral characteristics to a certain extent, which can provide a valuable reference for future trajectory prediction. Therefore, the historical trajectories of the target vehicle and the surrounding vehicles are encoded here first. Considering its spatio-temporal coupling properties, we used the BiLSTM network to process the vehicle historical trajectory information. Different from the general LSTM network stated as Equation (3), the BiLSTM network contains two layers of LSTM networks. By adding an inverse LSTM layer to the LSTM network, BiLSTM can further deal with the information from the future. The bi-directional characteristic of BiLSTM cannot only better tackle the long-term dependency problem but also improves the prediction accuracy due to the increased number of networks. As shown in Figure 4, BiLSTM can be formulated as  
\[ \begin{split}\Big{(}h_{fi}^{t},c_{f}^{t}\Big{)}=\text{LSTM} \Big{(}h_{fi}^{t-1},\tau_{i}^{t};c_{f}^{t-1}\Big{)}\\ \Big{(}h_{bi}^{t-t_{obs}},c_{b}^{t-t_{obs}}\Big{)}=\text{LSTM} \Big{(}h_{bi}^{t-t_{obs}+1},\tau_{i}^{t-t_{obs}};c_{b}^{t-t_{obs}+1}\Big{)} \end{split}  \tag{12}\]  
where \(c_{f}\) and \(c_{b}\) denote the feedforward and backward network parameters. Considering that the deep BiLSTM architecture is prone to lead optimization bottleneck and gradient disappearance, a deep residual network is used to connect the inputs and outputs of the BiLSTM layers. We sum the hidden variable with the input sequence and concatenate them for forward and backward networks. We can then obtain the output of the BiLSTM network:  
\[h_{pi}^{t}=\Big{(}h_{fi}^{t}+\tau_{i}^{t}\Big{\|}h_{bi}^{t-t_{obs}}+\tau_{i}^{t -t_{obs}}\Big{)} \tag{13}\]  
After encoding the trajectory sequence, a large number of historical trajectory feature vectors can be obtained. Subsequently, based on Equations (11) and (13), we carry out  
Figure 4: The diagram of BiLSTM. weighted aggregation of the trajectory feature with the vehicle-vehicle interaction feature to generate a new feature vector \(r_{i}^{t}\) as  
\[r_{i}^{t}=\tan h\Big{(}W_{p}h_{pi}^{t}+W_{v}\overline{p}_{i}^{t}\Big{)} \tag{14}\]  
where \(W_{p}\) and \(W_{v}\) are weight matrixes. Then, the dual-attention mechanism is adopted here for key information extraction. The spatial attention mechanism is mainly used to handle the influences of different surrounding vehicles on the target vehicle. For the vehicles' trajectories, the interaction is closely related to the relative distance. The closer obstacles always have more significant influences on the target vehicle. Therefore, the cosine distance is used here to calculate the correlation coefficients of encoded vectors between vehicles. \[f(r_{o},r_{i})=1-\frac{r_{0}\cdot r_{i}}{\left\|r_{o}\right\|_{2}\cdot\left\|r _{i}\right\|_{2}} \tag{15}\]  
To ensure that the weight scales are the same, we normalize \(f(r_{o},r_{i})\) to obtain the spatial attention coefficients. \[s_{i}=\frac{f(r_{o},r_{i})}{\sum\limits_{i\in\mathcal{N}(V_{o})}f(r_{o},r_{i})} \tag{16}\]  
By multiplying the hidden feature vectors and attention coefficients, the context vectors including spatial correlation can be obtained as  
\[\overline{r}_{so}=\sum\limits_{i\in\mathcal{N}(V_{o})}s_{i}r_{i} \tag{17}\]  
To determine the importance of the historical information at each sampling time, the temporal attention mechanism is applied here. Due to the nonlinearity of the vehicle model and the unpredictability of the driver behavioral characteristics, the relevance of the temporal features cannot be characterized using quantitative measurements such as the spatial attention mechanism.