MCPcopy
hub / github.com/dmlc/dgl / multi_update_all

Method multi_update_all

python/dgl/heterograph.py:5161–5277  ·  view source on GitHub ↗

r"""Send messages along all the edges, reduce them by first type-wisely then across different types, and then update the node features of all the nodes. Parameters ---------- etype_dict : dict Arguments for edge-type-wise message passing. The keys

(self, etype_dict, cross_reducer, apply_node_func=None)

Source from the content-addressed store, hash-verified

5159 #################################################################
5160
5161 def multi_update_all(self, etype_dict, cross_reducer, apply_node_func=None):
5162 r"""Send messages along all the edges, reduce them by first type-wisely
5163 then across different types, and then update the node features of all
5164 the nodes.
5165
5166 Parameters
5167 ----------
5168 etype_dict : dict
5169 Arguments for edge-type-wise message passing. The keys are edge types
5170 while the values are message passing arguments.
5171
5172 The allowed key formats are:
5173
5174 * ``(str, str, str)`` for source node type, edge type and destination node type.
5175 * or one ``str`` edge type name if the name can uniquely identify a
5176 triplet format in the graph.
5177
5178 The value must be a tuple ``(message_func, reduce_func, [apply_node_func])``, where
5179
5180 * message_func : dgl.function.BuiltinFunction or callable
5181 The message function to generate messages along the edges.
5182 It must be either a :ref:`api-built-in` or a :ref:`apiudf`.
5183 * reduce_func : dgl.function.BuiltinFunction or callable
5184 The reduce function to aggregate the messages.
5185 It must be either a :ref:`api-built-in` or a :ref:`apiudf`.
5186 * apply_node_func : callable, optional
5187 An optional apply function to further update the node features
5188 after the message reduction. It must be a :ref:`apiudf`.
5189
5190 cross_reducer : str or callable function
5191 Cross type reducer. One of ``"sum"``, ``"min"``, ``"max"``, ``"mean"``, ``"stack"``
5192 or a callable function. If a callable function is provided, the input argument must be
5193 a single list of tensors containing aggregation results from each edge type, and the
5194 output of function must be a single tensor.
5195 apply_node_func : callable, optional
5196 An optional apply function after the messages are reduced both
5197 type-wisely and across different types.
5198 It must be a :ref:`apiudf`.
5199
5200 Notes
5201 -----
5202 DGL recommends using DGL's bulit-in function for the message_func
5203 and the reduce_func in the type-wise message passing arguments,
5204 because DGL will invoke efficient kernels that avoids copying node features to
5205 edge features in this case.
5206
5207
5208 Examples
5209 --------
5210 >>> import dgl
5211 >>> import dgl.function as fn
5212 >>> import torch
5213
5214 Instantiate a heterograph.
5215
5216 >>> g = dgl.heterograph({
5217 ... ('user', 'follows', 'user'): ([0, 1], [1, 1]),
5218 ... ('game', 'attracts', 'user'): ([0], [1])

Callers 13

_testFunction · 0.80
test_level2Function · 0.80
test_backwardFunction · 0.80
test_stack_reduceFunction · 0.80
forwardMethod · 0.80
forwardMethod · 0.80
forwardMethod · 0.80
forwardMethod · 0.80
forwardMethod · 0.80
forwardMethod · 0.80
track_timeFunction · 0.80

Calls 11

get_etype_idMethod · 0.95
apply_nodesMethod · 0.95
pad_tupleFunction · 0.85
DGLErrorClass · 0.85
reduce_dict_dataFunction · 0.85
find_edgeMethod · 0.80
formatMethod · 0.80
appendMethod · 0.80
itemsMethod · 0.45
keysMethod · 0.45
updateMethod · 0.45

Tested by 6

_testFunction · 0.64
test_level2Function · 0.64
test_backwardFunction · 0.64
test_stack_reduceFunction · 0.64
forwardMethod · 0.64