Skip to content

Commit

Permalink
update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yunzhoul committed Sep 26, 2023
1 parent 368e1a4 commit eb3c36a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions examples/pyg_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ class PyGSampler(dgl.dataloading.Sampler):
An example DGL sampler implementation that matches PyG/GLT sampler behavior.
The following differences need to be addressed:
1. PyG/GLT applies conv_i to edges in layer_i, and all subsequent layers, while DGL only applies conv_i to edges in layer_i.
For instance, consider a path a->b->c. At layer 0, DGL updates only node b's embedding with a->b, but PyG/GLT updates both node b and c's embeddings.
For instance, consider a path a->b->c. At layer 0,
DGL updates only node b's embedding with a->b, but
PyG/GLT updates both node b and c's embeddings.
Therefore, if we use h_i(x) to denote the hidden representation of node x at layer i, then the output h_2(c) is:
DGL: h_2(c) = conv_2(h_1(c), h_1(b)) = conv_2(h_0(c) + conv_1(h_0(b) + h_0(a)))
PyG/GLT: h_2(c) = conv_2(h_1(c), h_1(b)) = conv_2(conv_1(h_0(c) + h_0(b)) + conv_1(h_0(b) + h_0(a)))
2. When creating blocks for layer i-1, DGL not only uses the destination nodes from layer i, but also includes all subsequent i+1 ... n layers' destination nodes as seed nodes.
DGL: h_2(c) = conv_2(h_1(c), h_1(b)) = conv_2(h_0(c), conv_1(h_0(b), h_0(a)))
PyG/GLT: h_2(c) = conv_2(h_1(c), h_1(b)) = conv_2(conv_1(h_0(c), h_0(b)), conv_1(h_0(b), h_0(a)))
2. When creating blocks for layer i-1, DGL not only uses the destination nodes from layer i,
but also includes all subsequent i+1 ... n layers' destination nodes as seed nodes.
More discussions and examples can be found here: https://github.com/alibaba/graphlearn-for-pytorch/issues/79.
"""
def __init__(self, fanouts):
Expand Down

0 comments on commit eb3c36a

Please sign in to comment.