dmlc--dgl
b0a9d16f25
* [Feature] Add full graph training with dgl built-in dataset. * [Feature] Add full graph training with dgl built-in dataset. * [Feature] Add full graph training with dgl built-in dataset. * [Bug] fix model to cuda. * [Bug] fix model to cuda. * [Bug] fix model to cuda. * [Bug] fix model to cuda. * [Bug] fix model to cuda. * [Bug] fix model to cuda. * [Bug] fix model to cuda. * [Bug] fix model to cuda. * [Bug] fix model to cuda. * [Bug] fix model to cuda. * [Bug] fix model to cuda. * [Bug] fix model to cuda. * [Bug] fix model to cuda. * [Bug] fix model to cuda. * [Bug] fix model to cuda. * [Bug] fix model to cuda. * [Bug] fix model to cuda. * [Bug] fix model to cuda. * [Bug] fix model to cuda. * [Bug] fix model to cuda. * [Bug] fix model to cuda. * [Feature] Add test loss and accuracy * [Feature] Add test loss and accuracy * [Feature] Add test loss and accuracy * [Feature] Add test loss and accuracy * [Feature] Add test loss and accuracy * [Feature] Add test loss and accuracy * [Fix] Add random * [Bug] Fix batch norm error * [Doc] Test with CN in Sphinx * [Doc] Test with CN in Sphinx * [Doc] Remove the test CN docs. * [Feature] Add input embedding layer * [Feature] Add input embedding layer * [Feature] Add input embedding layer * [Feature] Add input embedding layer * [Feature] Add input embedding layer * [Feature] Add input embedding layer * [Feature] Add input embedding layer * [Feature] Add input embedding layer * [Feature] Add input embedding layer * [Doc] fill readme with new performance results * [Doc] Add Chinese User Guide, graph and 1.5 * [Doc] Add Chinese User Guide, graph and 1.5 * Update README.md * [Fix] Temporary remove compgcn * [Doc] Add CN user guide chapter2 * [Test] Tunning format * [Test] Tunning format * [Test] Tunning format * [Test] Tunning format * [Test] Tunning format * [Test] Section headers * [Fix] Fix format errors * [Fix] Fix format errors * [Fix] Fix format errors * [Doc] Add CN-EN EN-CN links * [Doc] Add CN-EN EN-CN links * [Doc] Copyedit chapter2 * [Doc] Copyedit chapter2 * [Doc] Remove EN in 2.1 * [Doc] Remove EN in chapter 2 * [Doc] Copyedit first 2 sections * [Doc] Copyedit first 2 sections * [Doc] copyedited chapter 2 CN * [Doc] Add chapter 3 raw texts * [Doc] Add chapter 3 preface and 3.1 * [Doc] Add chapter 3.2 and 3.3 * [Doc] Add chapter 3.2 and 3.3 * [Doc] Add chapter 3.2 and 3.3 * [Doc] Remove EN parts * [Doc] Copyediting 3.1 * [Doc] Copyediting 3.2 and 3.3 * [Doc] Proofreading 3.1 and 3.2 * [Doc] Proofreading 3.2 and 3.3 * [Doc] Add chapter 4 CN raw text. * [Clean] Remove codes in other branches * [Doc] Start to copyedit chapter 4 preface * [Doc] copyedit CN section 4.1 * [Doc] Remove EN in User Guide Chapter 4 * [Doc] Copyedit chapter 4.1 * [Doc] copyedit cn chapter 4.2, 4.3, 4.4, and 4.5. * [Doc] Fix errors in EN user guide graph feature and heterograph * [Doc] 2nd round copyediting with Murph's comments * [Doc] 3rd round copyediting with Murph's comments * [Doc] 3rd round copyediting with Murph's comments * [Doc] 3rd round copyediting with Murph's comments * [Sync] syncronize with the dgl master * [Doc] edited after Minjie's comments, 1st round * update cub Co-authored-by: Minjie Wang <wmjlyjemaine@gmail.com>
47 行
2.0 KiB
ReStructuredText
47 行
2.0 KiB
ReStructuredText
.. _guide-message-passing-heterograph:
|
|
|
|
2.5 Message Passing on Heterogeneous Graph
|
|
------------------------------------------
|
|
|
|
:ref:`(中文版) <guide_cn-message-passing-heterograph>`
|
|
|
|
Heterogeneous graphs (:ref:`guide-graph-heterogeneous`), or
|
|
heterographs for short, are graphs that contain different types of nodes
|
|
and edges. The different types of nodes and edges tend to have different
|
|
types of attributes that are designed to capture the characteristics of
|
|
each node and edge type. Within the context of graph neural networks,
|
|
depending on their complexity, certain node and edge types might need to
|
|
be modeled with representations that have a different number of
|
|
dimensions.
|
|
|
|
The message passing on heterographs can be split into two parts:
|
|
|
|
1. Message computation and aggregation for each relation r.
|
|
2. Reduction that merges the aggregation results from all relations for each node type.
|
|
|
|
DGL’s interface to call message passing on heterographs is
|
|
:meth:`~dgl.DGLGraph.multi_update_all`.
|
|
:meth:`~dgl.DGLGraph.multi_update_all` takes a dictionary containing
|
|
the parameters for :meth:`~dgl.DGLGraph.update_all` within each relation
|
|
using relation as the key, and a string representing the cross type reducer.
|
|
The reducer can be one of ``sum``, ``min``, ``max``, ``mean``, ``stack``.
|
|
Here’s an example:
|
|
|
|
.. code::
|
|
|
|
import dgl.function as fn
|
|
|
|
for c_etype in G.canonical_etypes:
|
|
srctype, etype, dsttype = c_etype
|
|
Wh = self.weight[etype](feat_dict[srctype])
|
|
# Save it in graph for message passing
|
|
G.nodes[srctype].data['Wh_%s' % etype] = Wh
|
|
# Specify per-relation message passing functions: (message_func, reduce_func).
|
|
# Note that the results are saved to the same destination feature 'h', which
|
|
# hints the type wise reducer for aggregation.
|
|
funcs[etype] = (fn.copy_u('Wh_%s' % etype, 'm'), fn.mean('m', 'h'))
|
|
# Trigger message passing of multiple types.
|
|
G.multi_update_all(funcs, 'sum')
|
|
# return the updated node feature dictionary
|
|
return {ntype : G.nodes[ntype].data['h'] for ntype in G.ntypes}
|