# An Inference Framework of Markov Logic Network for Link Prediction in Heterogeneous Networks
## 4 Proposed Method
### VEM-Based Inference
#### 4.2.2 Argumentation of VEM  
**Variational E-step. ** According to the mean-field theory [32], the variational distribution \(Q(V_{u})\) of all unobserved fact nodes is formed by the independent fact node \(n(n\in V_{u})\):  
\[Q(V_{u})=\prod_{n\in V_{u}}q(n). \tag{6}\]  
To calculate \(q(n)\) in Equation (6), we adopt the GCN-based representation with Softmax function as the distribution of \(n\). For this purpose, we take the labels of neighbors of as the feature vector \(\mathcal{U}_{q}^{n}\). The labels of the observed and unobserved fact nodes are 1 and 0, respectively. As shown in Figure 3, the labels of the fact nodes surrounding \(n\) form its feature vector. Thus, the feature matrix \(\mathbb{F}_{Q}=[\mathcal{U}_{q}^{n}]\) could be constructed, and the distribution of \(n\) is  
\[q(n)=\text{Cat}(y_{n}|Softmax(\mathbb{AF}_{Q}\mathbb{W}_{Q})), \tag{7}\]  
where Cat denotes the categorical distribution, \(\mathbb{A}\) is the adjacency matrix corresponding to the graph structure, and \(\mathbb{W}_{Q}\) is the weight matrix. Since \(\mathbb{W}_{Q}\) could be optimized by observed nodes, we divide the optimization of \(\mathbb{W}_{Q}\) into the following two parts:  
* For unobserved fact nodes \(V_{u}\), we update \(\mathbb{W}_{Q}\) by maximizing \[\mathcal{L}_{u}=-\sum_{n\in V_{u}}KL(Q^{\prime}(V_{u})\parallel Q(V_{u})),\] (8) where \(Q^{\prime}(V_{u})\) is the distribution of unobserved fact nodes in the previous iteration round. Since both unobserved and observed fact nodes follow the same distribution, we initialize \(P(V_{o})\) to \(Q^{\prime}(V_{u})\) in the first round of iteration. * For the observed fact nodes \(V_{o}\), we use the cross-entropy loss to make the GCN fit the true labels: \[\mathcal{L}_{o}=-\sum_{n\in V_{o}}y_{n}\log p_{c}(y_{n}),\] (9) where \(y_{n}\) is the label of \(n\) in \(V_{o}\), and \(p_{c}(y_{n})\) is the probability that \(n\) is predicted as true. Thus, we sum Equations (8) and (9) as the following training loss of GCN to obtain the variational distribution \(Q(V_{u})\): \[\mathcal{L}_{Q}=\mathcal{L}_{u}+\mathcal{L}_{o}.\] (10)  
**M-step. ** To maximize the expectation of \(\log P(V_{u},\,V_{o})\), we use a similar method as Equation (6) to formulate \(P(V_{u})=\prod_{n\in V_{u}}p(v)\). Then, we leverage another GCN to obtain the node representations for categorical distribution:  
\[p(n)=\text{Cat}(y_{n}|Softmax(\mathbb{AF}_{p}\mathbb{W}_{P})). \tag{11}\]  
Due to the same structure of these two GCNs in the same iteration round, the adjacency matrix \(\mathbb{A}\) in Equation (11) is the same with that in Equation (7). An element in \(\mathbb{F}_{P}\) represents the feature vector \(\mathcal{U}_{p}^{n}\) of \(n\) in \(V_{u}\) and the value of \(\mathcal{U}_{p}^{n}\) is determined by the \(m\) formulas and corresponding weights \(\mathbf{w}\). Let \(\mathfrak{n}_{n}\) denote the number of truth-value nodes linked with each formula \(f_{j}\), respectively. Let \(w_{j}\) be the weight of \(f_{j}\). Then, we multiply the weight and number of truth-value nodes to achieve the feature \(\mathcal{U}_{p}^{n}=[w_{j}*\mathfrak{n}_{n}]\). As shown in Figure 3, we construct the feature matrix \(\mathbb{F}_{p}\) in the M-step by the numbers of nodes in grounding formulas of \(f_{1}\) and \(f_{2}\), as well as their weights \(w_{1}\) and \(w_{2}\). Let \(\mathfrak{n}(o)\) and \(\mathfrak{n}(Q(V_{u}))\) be the real and expected numbers of true groundings of formulas, respectively. We use their difference as the gradient of \(\mathbf{w}\) with the previous iteration round:  
\[\
abla_{\mathbf{w}}\mathbb{E}_{Q}[\log P(V_{u})]=\mathfrak{n}(o)-\mathfrak{n }(Q(V_{u})), \tag{12}\]  
where \(Q(V_{u})\) is the joint distribution of \(V_{u}\) calculated by the E-step in the previous iteration round. Additionally, if the fact node is not grounded from any predicate in the \(j\)-th formula (i.e., the node is not linked to this formula), we set the corresponding weight \(w_{j}\) to 0.