## 3 Problem Definition and Methods
### Social Attention with Motion Features as the Query  
This paper models social interactions among pedestrians using an attention mechanism. The construction of a query is a crucial aspect that involves identifying the influential features of pedestrian social interactions. Prior research has mostly relied on the relative positions between pedestrians as the sole feature to model social interaction. To improve the model's ability to accurately capture social interactions, this paper comprehensively extracts the motion features of pedestrians. For instance, considering target pedestrian \(i\), the impact of pedestrian \(j\) is greater when the distance between them is shorter. Additionally, the speed of pedestrian \(j\) also has a significant impact, with running having a greater impact than walking. Moreover, the direction of pedestrian \(j\) is another key feature, with an approaching head-on motion having a greater impact than moving in the same direction. As a result, as shown in Figure 3, this paper chooses the distance between pedestrians, the speed of surrounding pedestrians, and the velocity angle as motion features to construct a query.  
The relative position vector and pedestrian velocity vector are calculated as  
\[L_{ij}^{t}=\left(x_{j}^{t}-x_{i}^{t},y_{j}^{t}-y_{i}^{t}\right) \tag{2}\] \[V_{i}^{t}=\left(x_{i}^{t}-x_{i}^{t-1},y_{i}^{t}-y_{i}^{t-1}\right)\] \[V_{j}^{t}=\left(x_{j}^{t}-x_{j}^{t-1},y_{j}^{t}-y_{i}^{t-1}\right)\]  
Figure 2: The overall architecture of the proposed Social and Spatial Attentive Generative Adversarial Network (SSA-GAN), which is an Long Short-Term Memory (LSTM) based GAN. The generator’s decoder receives historical trajectory encodings from the encoder, features from the social attention and spatial attention modules, and randomly sampled noise to generate sequence predictions of pedestrian trajectories. Different colors represent the trajectories of different pedestrians and their LSTM flows.  
and the distance, speed, and velocity angle are derived as  
\[\begin{split}\left\|L_{ij}^{t}\right\|=\sqrt{\left(x_{j}^{t}-x_{i}^{ t}\right)^{2}+\left(y_{j}^{t}-y_{i}^{t}\right)^{2}}\\ \left\|V_{i}^{t}\right\|=\sqrt{\left(x_{i}^{t}-x_{i}^{t-1}\right)^ {2}+\left(y_{i}^{t}-y_{i}^{t-1}\right)^{2}}\\ \left\|V_{j}^{t}\right\|=\sqrt{\left(x_{j}^{t}-x_{j}^{t-1}\right)^ {2}+\left(y_{j}^{t}-y_{j}^{t-1}\right)^{2}}\\ \cos\!\left(V_{i}^{t},V_{j}^{t}\right)=V_{i}^{t}\times V_{j}^{t} \Bigg{/}\left\|V_{i}^{t}\right\|\cdot\left\|V_{j}^{t}\right\|\end{split} \tag{3}\]  
The pedestrian's motion feature is constructed and then concatenated as  
\[\theta_{ij}^{t}=\begin{bmatrix}\left\|L_{ij}^{t}\right\|,\left\|V_{i}^{t} \right\|,\left\|V_{j}^{t}\right\|\cos\!\left(V_{i}^{t},V_{j}^{t}\right)\right] \\ \theta_{i}^{t}=\begin{bmatrix}\theta_{11}^{t},\theta_{22}^{t},\cdots, \theta_{in}^{t}\end{bmatrix}\end{split} \tag{4}\]  
Then, the motion feature \(\theta_{i}^{t}\) is embedded via an MLP with a Rectified Linear Unit (ReLU)-type nonlinearity to obtain the motion vector as  
\[P_{i}^{t}=\varphi\big{(}\theta_{i}^{t};W_{P}\big{)} \tag{5}\]  
The social attention module employs \"Scaled Dot-Product Attention\", as presented in [34]. This module takes the pedestrian's motion vector \(P_{i}^{t}\) and the hidden states collection \(H_{i}^{t}=\left\{h_{1}^{t},\cdots,h_{N}^{t}\right\}\) of every LSTM decoder and outputs the social interaction vector as follows  
\[\begin{split} Q_{i}^{t}&=\varphi\big{(}P_{i}^{t};W_{QS }\big{)}\\ K_{i}^{t}&=\varphi\big{(}H_{i}^{t};W_{KS}\big{)}\\ V_{i}^{t}&=\varphi\big{(}H_{i}^{t};W_{VS}\big{)}\\ A_{\text{so}}^{t}(i)&=\text{Softmax}\bigg{(}\frac{Q_{i}^{ \left(K_{i}^{t}\right)}}{\sqrt{d_{k}}}\bigg{)}V_{i}^{t}\end{split} \tag{6}\]