Skip to content

Commit

Permalink
[Doc] Add Pseudo Code for HeteroGraphConv (dmlc#2729)
Browse files Browse the repository at this point in the history
* Update

* Update

* Update

* Update

Co-authored-by: Ubuntu <[email protected]>
  • Loading branch information
mufeili and Ubuntu authored Mar 17, 2021
1 parent b34a1e6 commit 09ef2c2
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
19 changes: 18 additions & 1 deletion python/dgl/nn/mxnet/hetero.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,26 @@ class HeteroGraphConv(nn.Block):
relation graphs, which reads the features from source nodes and writes the
updated ones to destination nodes. If multiple relations have the same
destination node types, their results are aggregated by the specified method.
If the relation graph has no edge, the corresponding module will not be called.
Pseudo-code:
.. code::
outputs = {nty : [] for nty in g.dsttypes}
# Apply sub-modules on their associating relation graphs in parallel
for relation in g.canonical_etypes:
stype, etype, dtype = relation
dstdata = relation_submodule(g[relation], ...)
outputs[dtype].append(dstdata)
# Aggregate the results for each destination node type
rsts = {}
for ntype, ntype_outputs in outputs.items():
if len(ntype_outputs) != 0:
rsts[ntype] = aggregate(ntype_outputs)
return rsts
Examples
--------
Expand Down
19 changes: 18 additions & 1 deletion python/dgl/nn/pytorch/hetero.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,26 @@ class HeteroGraphConv(nn.Module):
relation graphs, which reads the features from source nodes and writes the
updated ones to destination nodes. If multiple relations have the same
destination node types, their results are aggregated by the specified method.
If the relation graph has no edge, the corresponding module will not be called.
Pseudo-code:
.. code::
outputs = {nty : [] for nty in g.dsttypes}
# Apply sub-modules on their associating relation graphs in parallel
for relation in g.canonical_etypes:
stype, etype, dtype = relation
dstdata = relation_submodule(g[relation], ...)
outputs[dtype].append(dstdata)
# Aggregate the results for each destination node type
rsts = {}
for ntype, ntype_outputs in outputs.items():
if len(ntype_outputs) != 0:
rsts[ntype] = aggregate(ntype_outputs)
return rsts
Examples
--------
Expand Down
19 changes: 18 additions & 1 deletion python/dgl/nn/tensorflow/hetero.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,26 @@ class HeteroGraphConv(layers.Layer):
relation graphs, which reads the features from source nodes and writes the
updated ones to destination nodes. If multiple relations have the same
destination node types, their results are aggregated by the specified method.
If the relation graph has no edge, the corresponding module will not be called.
Pseudo-code:
.. code::
outputs = {nty : [] for nty in g.dsttypes}
# Apply sub-modules on their associating relation graphs in parallel
for relation in g.canonical_etypes:
stype, etype, dtype = relation
dstdata = relation_submodule(g[relation], ...)
outputs[dtype].append(dstdata)
# Aggregate the results for each destination node type
rsts = {}
for ntype, ntype_outputs in outputs.items():
if len(ntype_outputs) != 0:
rsts[ntype] = aggregate(ntype_outputs)
return rsts
Examples
--------
Expand Down

0 comments on commit 09ef2c2

Please sign in to comment.