Xavier initialization gives a GNN informative random starting features when the graph has no predefined or useful node attributes. Its distribution is chosen to keep activation variety consistent across layers, helping avoid vanishing or exploding gradients while embeddings learn. section 2.2.1
Apply it to PyTorch Geometric node features as follows:
- Create a floating-point feature matrix with one row per node and the desired feature width. section 2.2.1
- Initialize that matrix with nn.init.xavier_uniform_. section 2.2.1
- Pass the initialized data.x through the GNN; training adjusts these starting values toward the task objective. section 2.2.1
data.x = torch.randn((data.num_nodes, 64), dtype=torch.float) 'nn.init.xavier_uniform_(data.x) '
The listing shows the PyTorch construction of random node features followed by Xavier uniform initialization. section 2.2.1
