Message Passing 01/27/2025 Message Passing Generalizing the convolution operator to irregular domains is typically expressed as a neighborhood aggregation or message passing scheme. With \(x^{(k-1)}_i \in \mathbb{R}^{F} \) denoting node features of node \(i\) in layer \( (k-1) \) and \(\mathbf{e}_{j,i} \in \mathbb{R}^{D} \) denoting (optional) edge features from node \(j\) to node \(i\), message passing graph neural networks can be described as \[ \,\\ x^{(k)}_i = \gamma^{(k)} \left( x^{(k-1)}_i, \bigoplus_{j \in \mathcal{N}(i)} \phi^{(k)} \left(x^{(k-1)}_i, x^{(k-1)}_j, \mathbf{e}_{ij}\right) \right) \,\\ \] where \( \bigoplus \) denotes a differentiable, permutation invariant function, e.g., sum, mean or max, and \(\gamma\) and \(\phi\) denoe differentiable functions such as MLPs. Pytorch Geometric MessagePassing Base Class MessagePassing(aggr="add", flow="source_to_target", node_dim=-2) defines the aggregation scheme to use ("add", "mean" or "max") and the flow direction of message passing (either "source_to_target" or "target_to_source"). The user has to define the functions \(\phi\), i.e. message(), and \(\gamma\), i.e. update(), as well as the aggregation scheme to use, i.e. aggr="add", aggr="mean" or aggr="max". MessagePassing.propagate() takes in the edge indices and all additional data which is needed to construct messages and to update node embeddings. MessagePassing.message() constructs messages to node \(i\) in analogy to \(\phi\) for each edge \((j, i) \in \mathcal{E} \) if flow="source_to_target" and \((i,j) \in \mathcal{E} \) if flow="target_to_source". In addition, tensors passed to propagate() can be mapped to the respective nodes \(i\) and \(j\) by appending _i or _j to the variable name, e.g. x_i and x_j.