TL;DR
Many useful datasets are graphs: people linked by friendship, papers linked by citation, atoms linked by bonds. A common task is link prediction, guessing which missing edges should exist. The variational graph auto-encoder (VGAE) learns a short vector for every node by passing the graph and its node features through a graph convolutional network, then scores a possible edge by the dot product of its two endpoint vectors. Each node gets a distribution rather than a single point, and the whole model is trained with the variational auto-encoder objective.
Builds on: Variational Autoencoder, Graph Convolutional Network · Leads to: Node Embedding
Why it mattered
Link prediction and node embedding are everyday jobs on graph data, and before this paper the standard unsupervised tools were spectral clustering and random-walk embeddings such as DeepWalk. Neither used node features. Kipf and Welling showed that a small probabilistic model could use both the graph structure and the features, and beat both baselines on three citation networks: Cora, Citeseer and Pubmed. The paper has since been cited more than 5,000 times according to OpenAlex.
The problem
Take a graph with N nodes. Each node may carry a feature vector, such as the words in a paper. Some edges are hidden. The task is to rank pairs of nodes so that real but hidden edges score higher than pairs with no edge.
A direct approach would learn one vector per node with no regard for the graph, so two nodes that are linked but have different features would not be pulled together. Spectral methods use the eigenvectors of a matrix built from the graph, such as the graph Laplacian, which captures structure but ignores features. Random-walk methods such as DeepWalk learn from which nodes appear near each other on walks, again without features. A plain graph autoencoder would need to read the whole adjacency matrix and would not be able to say anything about uncertainty in each node's position. The VGAE tries to keep the good parts of each: a graph-aware encoder that reads features, and a latent space that is smooth because it is pulled toward a simple prior.
How it works
Take a tiny graph: three nodes in a line, 1 linked to 2 and 2 linked to 3. There are no features, so we use the identity matrix as the input, which means each node starts with only its own identity.
- Input. Write the adjacency matrix with a 1 on the diagonal, so every node is linked to itself. Row 1 is (1, 1, 0), row 2 is (1, 1, 1) and row 3 is (0, 1, 1). Check: the matrix is symmetric, as it must be for an undirected graph.
- Normalise. Count each node's links including its self-link. Node 1 has 2, node 2 has 3, node 3 has 2. Scale each entry by one over the square root of the two degrees it joins. The entry for 1 and 2 becomes 1 divided by the square root of 6, about 0.408. Check: the entry for 2 with itself is 1 divided by 3, about 0.333.
- Encode. A two-layer GCN takes the normalised matrix and the inputs and outputs two numbers per node: a mean and a spread. Suppose node 1 comes out with mean (1, 0) and spread (1, 1). Check: the spread is kept positive by taking an exponential, so it cannot be negative.
- Sample. Draw a point for node 1 from the Gaussian with that mean and spread. The sample is a noisy position near (1, 0). Check: running the step again gives a different point, which is why training uses an average over samples.
- Decode. Score each pair of nodes by the dot product of their sampled points, then squash the result to a probability with the sigmoid function. Suppose after training the points are z1 = (1, 0), z2 = (1, 0.5) and z3 = (-1, 0). The pair 1 and 2 has dot product 1, and the sigmoid of 1 is about 0.731. The pair 1 and 3 has dot product -1, and the sigmoid of -1 is about 0.269.
- Compare with the graph. The pair 1 and 2 is linked and scores 0.731; the pair 1 and 3 is not linked and scores 0.269. The model has put the linked pair closer together, which is what training aims for. Check: a pair that scored 0.5 would be a coin flip, so the gap here is what matters.
flowchart LR A[Adjacency matrix A] --> N[Normalise to A tilde] X[Node features X] --> G[Two-layer GCN] N --> G G --> M[Means mu_i] G --> S[Spreads sigma_i] M --> Z[Sample z_i] S --> Z Z --> D[Dot product z_i . z_j, then sigmoid] D --> P[Probability of an edge i to j]
The math
Given an undirected graph with N nodes, an adjacency matrix with ones on the diagonal, and node features , a variational graph auto-encoder is a latent variable model. Each node has a latent vector , the matrix of all of them is , and the model is trained by maximising a lower bound on the likelihood of the graph.
Normalising the graph (walkthrough steps 1 and 2)
Let be the diagonal degree matrix, with . The normalised adjacency is
Entry of is divided by , which is the step-2 scaling in the walkthrough.
The encoder (walkthrough steps 3 and 4)
The encoder is a two-layer GCN. It is defined by
where is applied entry by entry. Two GCNs share the first weight matrix : one gives the means and one gives the log spreads,
Each node then has a diagonal Gaussian,
Working with keeps the spread positive, which is the point the walkthrough made in step 3.
The decoder (walkthrough step 5)
The decoder scores each pair with an inner product passed through the logistic sigmoid :
The full likelihood multiplies this over all pairs.
The objective (walkthrough step 6)
Training maximises the variational lower bound on the likelihood of the graph,
The first term rewards the decoder for reconstructing the graph. The second term, a KL divergence, pulls each node's distribution toward the prior . The expectation is estimated by sampling, and gradients pass through the sample by the reparameterisation trick. For a diagonal Gaussian against the standard normal, the KL term has a standard closed form, , which is what implementations use.
The non-probabilistic variant
Dropping the noise gives the graph auto-encoder, with and reconstruction . The paper uses it as a point of comparison.
Worked examples
The graph has edges 1 to 2 and 2 to 3, with self-loops, so has rows (1, 1, 0), (1, 1, 1), (0, 1, 1).
- Degrees: , , .
- Entry of is .
- Entry is , about .
- Entry is , about .
- Entry is , because nodes 1 and 3 are not linked, so it is .
Interpretation: the normalised matrix gives the two endpoints of an edge a larger weight when they have few links, and it keeps the self-link. Check: the entries for the linked pairs (1, 2) and (2, 3) are equal, as they must be for a symmetric matrix.
Take the decoder points from the walkthrough, , , .
- Inner product for pair 1 and 2: .
- Sigmoid of 1: .
- Inner product for pair 1 and 3: .
- Sigmoid of : .
- Now take one node with mean and spread in one dimension. The KL term is .
Interpretation: the linked pair scores higher than the unlinked pair, so the decoder agrees with the graph. The KL term is small here because the node's distribution is close to the prior.
Here the input is a citation network with node features. The paper hides 10 percent of the citation links as a test set and 5 percent as a validation set, and adds the same number of random non-linked pairs to each. It then asks each model to rank the true hidden links above the random pairs. Accuracy is summarised by the area under the ROC curve (AUC) and by average precision (AP).
- Train the VGAE on the links left after removing the 15 percent for validation and test, with 32 hidden units and a 16-dimensional latent space.
- Score every test pair with the sigmoid of the dot product of the two node means.
- On Cora the paper reports an AUC of 91.4 and an AP of 92.6 for VGAE, against 84.6 and 88.5 for spectral clustering.
- The gap is about 6.8 points of AUC, which is what the paper compares when it says VGAE beats its baselines.
- Interpret the gap as the value of the features and the graph encoder together: the featureless VGAE* reaches 84.0 AUC on Cora, close to spectral clustering, so most of the gain comes from using the node features.
- Try it: the featureless VGAE* gets 84.0 AUC on Cora and the full VGAE gets 91.4. Compute the gain from adding the features. Answer: 91.4 minus 84.0 is 7.4 points of AUC.
Common mistakes and tradeoffs
It is tempting to think the variational part is what makes the model work. In fact the paper's table shows that the non-variational GAE is close to VGAE on Cora and Citeseer and beats VGAE on Pubmed, because the GCN encoder and the features do most of the work. The variational part gives a distribution and a smooth latent space, which matters when you need uncertainty or sampling, not just the best link score.
It is also tempting to think that a higher AUC always means a better model for your problem. The paper's test set is 10 percent of the citation links, paired with the same number of random unlinked pairs. A different split or a different kind of graph can change the ranking of the methods.
Use a VGAE when the graph has useful node features, when you want an unsupervised embedding, and when a link score is the output you need. Do not use it when the graph is very large, since the paper uses full-batch gradient descent over the whole graph, or when the nodes have no features and the structure is the only signal, because the featureless variant is weaker than the full model on Cora and Pubmed. Alternatives include DeepWalk for featureless embeddings and spectral methods when the graph is small and a closed-form answer is preferred.
Results
The paper evaluates link prediction on three citation networks. The table below copies the paper's test results, reported as mean over 10 random initialisations on fixed splits, with the AUC and average precision (AP) as percentages.
| Method | Cora AUC | Cora AP | Citeseer AUC | Citeseer AP | Pubmed AUC | Pubmed AP |
|---|---|---|---|---|---|---|
| Spectral clustering | 84.6 | 88.5 | 80.5 | 85.0 | 84.2 | 87.8 |
| DeepWalk | 83.1 | 85.0 | 80.5 | 83.6 | 84.4 | 84.1 |
| GAE, with features | 91.0 | 92.0 | 89.5 | 89.9 | 96.4 | 96.5 |
| VGAE, with features | 91.4 | 92.6 | 90.8 | 92.0 | 94.4 | 94.7 |
Without features, the paper reports GAE* at 84.3 AUC on Cora and VGAE* at 84.0, and on Pubmed 82.2 and 82.7. The featureless models are close to each other and to spectral clustering on Cora.
What these numbers mean: with features, VGAE beats both baselines on all three datasets. The clearest win is on Citeseer, where it gains about 10 AUC points over DeepWalk. The paper says VGAE is higher than GAE on Cora and Citeseer. On Pubmed the plain GAE is higher, 96.4 against 94.4 AUC.
The limits: the experiments are one task, link prediction, on three datasets, and the results are averages over 10 runs. The paper's discussion says that a Gaussian prior may be a poor match for an inner product decoder, because the decoder pushes embeddings away from the centre of the prior. It also names better priors, more flexible generative models and stochastic gradient training as future work. The paper trains with full-batch gradient descent, so scale is not tested.
Reading guide
Read the paper in this order, with the lessons it leans on.
- Abstract and Section 1, the latent variable model. Needs Variational Autoencoder for the overall setup, Latent Variable Model for the idea of hidden variables, and Adjacency Matrix for the graph input.
- Definitions and the inference model. Needs Graph Convolutional Network for the two-layer GCN and Multivariate Gaussian for the diagonal Gaussian over each node.
- The generative model. Needs Dot Product and Sigmoid Function for the decoder.
- Learning. Needs Variational Lower Bound (ELBO), Kullback–Leibler Divergence and Reparameterization Trick for the objective and its gradients, and Prior Distribution for the standard normal prior.
- The non-probabilistic GAE. Only needs the decoder idea above.
- Section 2, experiments. Needs Area Under the ROC Curve for AUC, Node Embedding for what the baselines produce, DeepWalk: Online Learning of Social Representations for the random-walk baseline, and Graph Laplacian for the matrix behind spectral clustering. Training uses Adam Optimizer and the initialisation from Xavier (Glorot) Initialization, with Stochastic Gradient Descent for the family of methods.
- Results and Discussion. Read the table, then the discussion of the prior. The paper cites Semi-Supervised Classification with Graph Convolutional Networks for the layer it uses.
Check yourself
QuestionWhy does the model divide each adjacency entry by the square roots of the two degrees?Show answer
Dividing by the degrees stops nodes with many links from dominating the sum that the GCN takes over neighbours. Each entry becomes the link weight scaled by how connected both ends are, so that a link between two low-degree nodes counts for more than the same link between two hubs. This is what the normalisation in step 2 of the walkthrough does.
QuestionA node has mean 0 and spread 1 in every dimension. What is its [[kl-divergence|KL term]] against the standard normal?Show answer
Zero. With and the formula gives in every dimension, so the sum is zero. The node already matches the prior, so the penalty has nothing to pull back.
QuestionTwo nodes are linked, and their sampled points have [[dot-product|dot product]] 0. What probability does the decoder give that they are linked, and why is that a weak result?Show answer
The sigmoid of 0 is 0.5, so the decoder gives a coin flip. That is weak because the training objective rewards placing linked pairs with high dot products, so a score of 0.5 for a true edge means the embedding has not yet separated the pair from the non-links it was trained against.
QuestionOn Pubmed the plain GAE beats the VGAE in the paper's table. Give one reason this does not contradict the claim that the variational version is useful.Show answer
The paper's claim is that VGAE beats the baselines and gives a distribution over each node, and the table supports that: VGAE is far above spectral clustering and DeepWalk on Pubmed too. The variational version is a choice that adds a probabilistic latent space and a prior. The comparison with GAE is a fair test of whether that extra structure helps, and on Pubmed it does not, so the honest reading is that the benefit depends on the dataset.
Sources
- Kipf and Welling, Variational Graph Auto-Encoders (2016).
- Kingma and Welling, Auto-Encoding Variational Bayes (2013).
- Kipf and Welling, Semi-Supervised Classification with Graph Convolutional Networks (2016).