gammagl.layers.conv.SAGEConv

class SAGEConv(in_channels, out_channels, activation=None, aggr='mean', add_bias=True)[source]

The GraphSAGE operator from the “Inductive Representation Learning on Large Graphs” paper

\[\mathbf{x}^{\prime}_i = \mathbf{W}_1 \mathbf{x}_i + \mathbf{W}_2 \cdot \ \mathrm{mean}_{j \in \mathcal{N(i)}} \mathbf{x}_j\]
Parameters:
  • in_channels (int, tuple) – Size of each input sample, or -1 to derive the size from the first input(s) to the forward method. A tuple corresponds to the sizes of source and target dimensionalities.

  • out_channels (int) – Size of each output sample.

  • norm (callable, None, optional) – If not None, applies normalization to the updated node features.

  • aggr (str, optional) – Aggregator type to use (mean).

  • add_bias (bool, optional) – If set to False, the layer will not learn an additive bias. (default: True)

forward(feat, edge)[source]

Compute GraphSAGE layer.

Parameters:

feat (Pair of Tensor) – The pair must contain two tensors of shape \((N_{in}, D_{in_{src}})\) and \((N_{out}, D_{in_{dst}})\).

Returns:

The output feature of shape \((N_{dst}, D_{out})\) where \(N_{dst}\) is the number of destination nodes in the input graph, math:D_{out} is size of output feature.

Return type:

Tensor