# Self-Supervised Spatio-Temporal Graph Learning for Point-of-Interest Recommendation
## 3 Methodology
### Problem Definition and GNN Backbone  
In this paper, we modeled the POI recommendation as a link prediction problem on a bi-partite graph \(\mathcal{G}=(\mathcal{V},\mathcal{E})\), where users \(\mathcal{U}\), POIs \(\mathcal{P}\), nodes \(\mathcal{V}\), and historical interactions \(\mathbf{R}\) are between them as edges \(\mathcal{E}\). Our goal was to find potential edges based on the observed edges and spatio-temporal information.  
The GNN backbone module aims to generate the nodes' embeddings \(\mathbf{Z}_{U}\) and \(\mathbf{Z}_{P}\) by training a GNN function \(f(\cdot|X_{U},X_{P})\) in a point-wise or pair-wise loss \(\mathcal{L}_{main}\), where \(X_{U}\) and \(X_{P}\) are the nodes' features. Then, this module calculates the similarity score \(\tilde{Y}_{UIP}\) between their embeddings and uses the top-K POIs with the highest similarity scores as the recommendation list \(\hat{P}_{U}\).  
In detail, graph neural networks usually use the message-passing mechanism to generate node representations. It consists of two specific steps. Firstly, given the bi-partite graph \(\mathcal{G}\), the \((l+1)\)-th layer representations of the nodes are updated by aggregating the \(l\)-th layer representations of their neighbor nodes:  
\[\mathbf{Z}^{(l+1)}=f_{aggregate}(\cdot|\mathbf{Z}^{(l)},\mathcal{G}), \tag{1}\]  
where \(\mathbf{Z}^{(0)}=X\) is a parameterized ID embedding lookup table.  
Then, the representations of all the \(L\) layers are fused to generate the final representations:  
\[\mathbf{Z}=f_{readout}(\cdot|\mathbf{Z}^{(l)},l=[0,\cdots,L]). \tag{2}\]  
Although any \(f_{aggregate}\) and \(f_{readout}\) can be used as a GNN backbone, for the sake of fair comparison in subsequent experiments, SSTGL uses the same functions \(f_{aggregate}(\cdot|z_{1}\to z_{2})\)  
Figure 1: The proposed model SSTGL, which contains three main components. (**a**) Graph neural network backbone. (**b**) Spatial-temporal-aware data augmentation. (**c**) Spatial-temporal-aware pre-text task.  
and \(f_{readout}(\cdot|z_{1}\to z_{2})\) as the self-supervised learning baselines [12; 13] of the backbone, which can be defined as follows:  
\[f_{aggregate}(\cdot|z_{1}\to z_{2})=\left\{\begin{array}{c}\sum_{p\in N_{u}} \frac{1}{\sqrt{|N_{u}||N_{p}}}z_{1}\,,\,z_{1}=\mathbf{z}_{p}^{(l)}\text{and}\,z_ {2}=\mathbf{z}_{u}^{(l+1)},\\ \sum_{u\in N_{p}}\frac{1}{\sqrt{|N_{p}||N_{u}}}z_{1}\,,\,z_{1}=\mathbf{z}_{u}^{ (l)}\text{and}\,z_{2}=\mathbf{z}_{p}^{(l+1)},\end{array}\right. \tag{3}\]  
\[f_{readout}(\cdot|z_{1}\to z_{2})=\left\{\begin{array}{c}\frac{1}{L+1}\sum_{ l=0}^{L}z_{1}\,,\,z_{1}=\mathbf{z}_{u}^{(l)}\text{and}\,z_{2}=\mathbf{z}_{u},\\ \frac{1}{L+1}\sum_{l=0}^{L}z_{1}\,,\,z_{1}=\mathbf{z}_{p}^{(l)}\text{and}\,z_ {2}=\mathbf{z}_{p},\end{array}\right. \tag{4}\]  
Finally, the similarity scores \(\hat{Y}_{UP}\) of the representations of users and POIs are calculated using the inner product and are used to calculate the supervision loss \(\mathcal{L}_{main}\):  
\[\hat{Y}_{UP}=\mathbf{Z}_{U}^{\top}\mathbf{Z}_{P}, \tag{5}\]  
\[\mathcal{L}_{main}=\sum_{(i,j,k)\in\mathcal{O}}-\text{log}\,\sigma(\hat{y}_{ ij}-\hat{y}_{ik}), \tag{6}\]  
where \(\sigma(\cdot)\) is the sigmoid function, \(\mathcal{O}=\{(i,j,k)|(i,j)\in\mathcal{O}^{+},(i,k)\in\mathcal{O}^{-}\}\) is the training data, \(\mathcal{O}^{+}\) is positive pairs with interaction, and \(\mathcal{O}^{-}\) is negative pairs without interaction.