# Using Graph Neural Networks for Social Recommendations
## 3 Methodology
### RelationalNet Algorithm Architecture
#### 3.2.4 Node Attention Layer  
In GNNs, each node receives and combines features from its neighboring nodes to capture the local structure of the graph. Different types of GNN layers use various aggregation techniques for the message-passing process.  
Each of our graphs employs attention from neighboring nodes to enhance each user's training. This attention can be computed in various ways, such as taking the mean, concatenating it into vectors, or selecting the maximum value from neighboring values. By repeatedly diffusing users' preferences through propagation in the graph, their preferences are effectively spread out as shown in Figure 5.  
* Let each user \(a\) have \(h_{a}^{k}\) as the latent embedding at the \(k^{th}\) layer, then the user \(a\) latent embeddings for the neighboring nodes in \(G_{S}\) at layer \(k+1\) is \[h_{Sa}^{k+1}=g(h_{b}^{k}|b\in S_{a})\] (4) where \(g(x)\) is an attention function, and \(Sa\) is the neighborhood of a. The user's \(a\) latent embedding can be trained for layer \(k+1\) with the combination of its own \(h_{a}^{k}\) and of the neighboring latent embeddings \(h_{Sa}^{k+1}\): \[h_{a}^{k+1}=\alpha(W^{k}\times[h_{Sa}^{k+1},h_{a}^{k}])\] (5) where \(\alpha(x)\) is a non-linear transformation function similar to DiffNet++.
* Let each item \(i\) have \(l_{i}^{k}\) as the latent embedding at the \(k^{th}\) layer, then the item \(i\) latent embeddings for the neighboring nodes in \(G_{T}\) at layer \(k+1\) is \[l_{Ti}^{k+1}=g^{\prime}(l_{b}^{k}|b\in T_{i})\] (6) where \(g^{\prime}(x)\) is an attention function and \(T_{i}\) is the neighborhood of i. The item \(i\) latent embeddings can be trained for layer \(k+1\) with the combination of \(l_{i}^{k}\) and \(l_{Ti}^{k+1}\) neighboring latent embeddings: \[l_{i}^{k+1}=\alpha^{\prime}(W^{k}\times[l_{Ti}^{k+1},l_{i}^{k}])\] (7) where \(\alpha^{\prime}(x)\) is a non-linear transformation function similar to DiffNet++.  
Figure 5: Diffusion at Node attention layer, i.e., Layer 1 is from 1-hop neighbors, Layer 2 is from 2-hop neighbors, and Layer 3 is from 3-hop neighbors.  
Similarly, the consumed items by each user and those consumed for each item are trained for \(k\) layers using attention.
* Let each user \(a\) have \(\tilde{h}_{a}^{k}\) as latent embedding at the \(k^{th}\) layer, then the user \(a\) latent embeddings for the consumed item nodes in \(G_{R}\) at layer \(k+1\) are \[\tilde{h}_{Va}^{k+1}=g(\tilde{h}_{b}^{k}|b\in V_{a})\] (8) where \(V_{a}\) represents the items consumed by user \(a\), and \(g(x)\) is a transformation function. The user \(a\) latent embeddings can be trained for layer \(k+1\) with a combination of \(\tilde{h}_{a}^{k}\) and \(\tilde{h}_{Va}^{k+1}\) consumed item latent embeddings: \[\tilde{h}_{a}^{k+1}=\beta(\tilde{W}^{k}\times[\tilde{h}_{Va}^{k+1},\tilde{h}_{ a}^{k}])\] (9) where \(\beta(x)\) is a non-linear transformation function.
* Let each item \(i\) have \(\tilde{l}_{i}^{k}\) as the latent embedding at the \(k^{th}\) layer, then the item \(i\) latent embeddings for the consumed user nodes in \(G_{R}^{\prime}\) at layer \(k+1\) are \[\tilde{l}_{Si}^{k+1}=g(\tilde{l}_{b}^{k}|b\in S_{i})\] (10) where \(S_{i}\) represents users who consumed item \(i\) and \(g(x)\) is an attention function. The item \(i\) latent embeddings can be trained for layer \(k+1\) with a combination of \(\tilde{l}_{i}^{k}\) and \(\tilde{l}_{S_{i}}^{k+1}\) consumed users' latent embeddings: \[\tilde{l}_{i}^{k+1}=\beta(\tilde{W}^{k}\times[\tilde{l}_{Si}^{k+1},\tilde{l}_{ i}^{k}])\] (11) where \(\beta(x)\) is a non-linear transformation function. Figure 1 shows that step with the use of yellow boxes labeled Node ATT.