# Course Recommendation Based on Enhancement of Meta-Path Embedding in Heterogeneous Graph
## 4 Proposed Approach for Course Recommendation
### Embedding Weight Aggregation Layer
#### 4.2.2 Fusion of Meta-Path Embedding  
Next, we use nonlinear depth fusion method to fuse all of the different kinds of embedded information of the meta-path into the embedded information targeted at a single node. This embedding fusion transformation can transform the embedding into a more appropriate form, improving the recommendation performance.  
With a node \(v\in V\), we can find the embedded representation set of \(v\) nodes \(\{e_{v}^{(l)}\}_{l=1}^{|\Gamma|}\), where \(\Gamma\) is a set of meta-paths that include the original meta-paths and the simulated meta-paths, and \(e_{v}^{(l)}\) represents the embedded information of node \(v\) under meta-path \(l\). Taking the user node as an example, the nonlinear depth fusion function \(\mathcal{M}(\cdot)\) provided  
Figure 4: Framework of GAT Embedding.  
below can be used to fuse the embedded information of each user node \(u\), as shown in Equation (8):  
\[\mathcal{M}(\{e_{u}^{(l)}\})=\sigma(\sum_{l=1}^{|\Gamma|}W_{u}^{(l)} \sigma(M^{(l)}e_{u}^{(l)}+b^{(l)})), \tag{8}\]  
where \(M^{(l)}\in R^{D\times d}\) is the conversion matrix under path \(l\), \(b^{(l)}\in R^{D}\) is the offset vector under path \(l\), and \(W_{u}^{(l)}\) is the preference weight of user \(v\) under meta-path \(l\). The function \(\sigma(\cdot)\) is a nonlinear function. Here, the _sigmoid_ function is used. For the fusion of embedded information of project nodes, a fusion method consistent with the embedded information of the user nodes is adopted. The algorithm for enhancing meta-path embedding is shown in Algorithm 1.  
**Input:** the heterogeneous graph \(G\); the adjacency matrix \(M^{a}\); the meta-path sets \(P^{(U)}\) for users and \(P^{(I)}\) for items.  
**Output:** the enhanced meta-path embedding set of users and items: \(\{e_{u}^{(l)}\}_{l}^{|\Gamma^{(U)}|}\),\(\{e_{i}^{(l)}\}_{l}^{|\Gamma^{(l)}|}\).  
```
1: Get original meta-path embedding sets \(\{e_{i}^{(l)}\}_{l}^{|P^{(I)}|}\) and \(\{e_{u}^{(l)}\}_{l}^{|P^{(U)}|}\) of \(G\) by using skip-gram
2:for\(e_{i}^{(l)}\) in \(\{e_{i}^{(l)}\}_{l}^{|P^{(I)}|}\)do
3:\(\hat{e}_{i}^{(l)}\gets GCN(e_{i}^{(l)},M^{a})\). [Equation (3)]
4:\(\Gamma^{(l)}\leftarrow\{e_{i}^{(l)},e_{i}^{(l)}\}\). [Get a set including two types meta-path embedding.]
5:endfor
6:for\(\vec{e}_{i}^{(l)}\) in \(\Gamma^{(I)}\)do
7:\(t_{i,j}^{(l)}\gets GAT(\vec{e}_{i}^{(l)},\vec{e}_{j}^{(l)})\). [\(\vec{e}_{j}^{(l)}\) is the embedding of the neighbor node \(j\). Equation (4)]
8:\(a_{i,j}^{(l)}\gets normalize(t_{i,j}^{(l)})\). [Equation (5)]
9:\(\hat{e}_{i}^{(l)}\gets F(a_{i,j}^{(l)},e_{j}^{(l)})\). [Equation (6), Equation (7)]
10:\(e_{i}^{(l)}\gets Con(e_{i}^{(l)},\hat{e}_{i}^{(l)})\). Update \(e_{i}^{(l)}\) by connecting \(\hat{e}_{i}^{(l)}\).
11:endfor
12:for\(e_{u}^{(l)}\) in \(\{e_{u}^{(l)}\}_{l}^{|P^{(U)}|}\)do
13:\(\tilde{e}_{u}^{(l)}\gets GCN(e_{u}^{(l)},M^{a})\). [Equation (3)]
14:\(\Gamma^{(I)}\leftarrow\{e_{u}^{(l)},\hat{e}_{u}^{(l)}\}\). [Get a set including two types meta-path embedding.]
15:endfor
16:for\(\tilde{e}_{u}^{(l)}\) in \(\Gamma^{(I)}\)do
17:\(t_{u,j}^{(l)}\gets GAT(\tilde{e}_{u}^{(l)},\tilde{e}_{j}^{(l)})\). [\(\tilde{e}_{j}^{(l)}\) is the embedding of the neighbor node \(j\). Equation (4)]
18:\(a_{u,j}^{(l)}\gets normalize(t_{u,j}^{(l)})\). [Equation (5)]
19:\(\hat{e}_{u}^{(l)}\gets F(a_{u,j}^{(l)},e_{j}^{(l)})\). [Equation (6), Equation (7)]
20:\(e_{u}^{(l)}\gets Con(e_{i}^{(l)},\hat{e}_{u}^{(l)})\). Update \(e_{u}^{(l)}\) by connecting \(\hat{e}_{u}^{(l)}\).
21:endfor
22:return\(\{e_{u}^{(l)}\}_{l}^{|\Gamma^{(U)}|}\),\(\{e_{i}^{(l)}\}_{l}^{|\Gamma^{(l)}|}\).
```  
**Algorithm 1**Algorithm for enhancing meta-path embedding