dgl.random_walk_pe
- dgl.random_walk_pe(g, k, eweight_name=None)[source]
Random Walk Positional Encoding, as introduced in Graph Neural Networks with Learnable Structural and Positional Representations
此函数计算从每个节点到自身的1步到k步的随机游走位置编码作为着陆概率。
- Parameters:
- Returns:
形状为 \((N, k)\) 的随机游走位置编码,其中 \(N\) 是输入图中的节点数量。
- Return type:
张量
示例
>>> import dgl >>> g = dgl.graph(([0,1,1], [1,1,0])) >>> dgl.random_walk_pe(g, 2) tensor([[0.0000, 0.5000], [0.5000, 0.7500]])