Unverified Commit 09ef2c2c authored by Mufei Li's avatar Mufei Li Committed by GitHub
Browse files

[Doc] Add Pseudo Code for HeteroGraphConv (#2729)



* Update

* Update

* Update

* Update
Co-authored-by: default avatarUbuntu <ubuntu@ip-172-31-15-8.us-west-2.compute.internal>
parent b34a1e63
...@@ -11,9 +11,26 @@ class HeteroGraphConv(nn.Block): ...@@ -11,9 +11,26 @@ class HeteroGraphConv(nn.Block):
relation graphs, which reads the features from source nodes and writes the relation graphs, which reads the features from source nodes and writes the
updated ones to destination nodes. If multiple relations have the same updated ones to destination nodes. If multiple relations have the same
destination node types, their results are aggregated by the specified method. 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. 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 Examples
-------- --------
......
...@@ -11,9 +11,26 @@ class HeteroGraphConv(nn.Module): ...@@ -11,9 +11,26 @@ class HeteroGraphConv(nn.Module):
relation graphs, which reads the features from source nodes and writes the relation graphs, which reads the features from source nodes and writes the
updated ones to destination nodes. If multiple relations have the same updated ones to destination nodes. If multiple relations have the same
destination node types, their results are aggregated by the specified method. 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. 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 Examples
-------- --------
......
...@@ -11,9 +11,26 @@ class HeteroGraphConv(layers.Layer): ...@@ -11,9 +11,26 @@ class HeteroGraphConv(layers.Layer):
relation graphs, which reads the features from source nodes and writes the relation graphs, which reads the features from source nodes and writes the
updated ones to destination nodes. If multiple relations have the same updated ones to destination nodes. If multiple relations have the same
destination node types, their results are aggregated by the specified method. 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. 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 Examples
-------- --------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment