An encoder maps a data object, such as a node or graph, to a lower-dimensional embedding. It may be a learned network or a shallow method that assigns embeddings to known objects. That distinction matters when new data arrives: a shallow lookup cannot represent objects it never trained on, while an inductive model learns a mapping it can apply to new data. section 2.4.2
In an autoencoder, the encoder compresses an input into a latent representation; a decoder uses that representation to reconstruct something useful. For an image, that might be the image itself. For a graph autoencoder, the target can be its connections: encode node features and graph structure, then decode pairs of latent node representations to predict edges. section 5.5 section 5.2.2
A practical graph-autoencoder pipeline is:
- Prepare node features and an edge index. Pass both to a GNN encoder whose successive layers reduce the representation to the chosen latent dimension. section 5.2.2
- Score candidate edges with a decoder; an inner-product decoder compares the latent representations of each candidate pair. section 5.2.2
- Train against observed and sampled nonexistent edges, then evaluate predicted links on held-out data. The encoder produces representations; the decoder makes the edge predictions. section 5.2.3
Product-link prediction
For an Amazon product graph, a three-layer GCN encoder takes feature vectors and an edge index, reducing its hidden dimensions to a 16-dimensional latent output. An inner-product decoder scores product pairs. Training samples nonexistent edges alongside known ones so the model can learn to distinguish missing links from real connections. section 5.2.2 section 5.2.3
Listing 5.4 Graph encoder
from torch_geometric.nn import GCNConv #1
class GCNEncoder(torch.nn.Module): #2
def __init__(self, input_size, layers, latent_dim): #2
super().__init__() #2
self.conv0 = GCNConv(input_size, layers[0]) #3
self.conv1 = GCNConv(layers[0], layers[1]) #3
self.conv2 = GCNConv(layers[1], latent_dim) #3
def forward(self, x, edge_index): #4
x = self.conv0(x, edge_index).relu() #4
x = self.conv1(x, edge_index).relu() #4
return self.conv2(x, edge_index) #4
The GCN encoder implementation shows how node features and edge_index pass through progressively smaller convolutional layers to produce latent representations. section 5.2.2
An encoder need not compress only static node features. For temporal sensor data, a neural relational inference encoder passes information between nodes and edges and represents possible connections as latent edge-type probabilities. Its decoder uses those probabilities and earlier timesteps to predict trajectories. This makes the latent space a bottleneck for interaction information, rather than a direct prediction of the next pose. section 6.4.1 section 6.5.3




















