gammagl.layers.conv.GINConv¶
- class GINConv(nn, eps=0.0, train_eps: bool = False, **kwargs)[source]¶
The graph isomorphism operator from the “How Powerful are Graph Neural Networks?” paper
\[\mathbf{x}^{\prime}_i = h_{\mathbf{\Theta}} \left( (1 + \epsilon) \cdot \mathbf{x}_i + \sum_{j \in \mathcal{N}(i)} \mathbf{x}_j \right)\]or
\[\mathbf{X}^{\prime} = h_{\mathbf{\Theta}} \left( \left( \mathbf{A} + (1 + \epsilon) \cdot \mathbf{I} \right) \cdot \mathbf{X} \right),\]here \(h_{\mathbf{\Theta}}\) denotes a neural network, .i.e. an MLP.
- Parameters:
nn (tlx.nn.Module) – A neural network \(h_{\mathbf{\Theta}}\) that maps node features
xof shape[-1, in_channels]to shape[-1, out_channels], e.g., defined bytorch.nn.Sequential.eps (float, optional) – (Initial) \(\epsilon\)-value. (default:
0.)train_eps (bool, optional) – If set to
True, \(\epsilon\) will be a trainable parameter. (default:False)**kwargs (optional) – Additional arguments of
gammagl.layers.conv.MessagePassing.
- forward(x, edge_index, size=None)[source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- message(x, edge_index)[source]¶
Function that construct message from source nodes to destination nodes.
- Parameters:
x (tensor) – input node feature.
edge_index (tensor) – edges from src to dst.
edge_weight (tensor, optional) – weight of each edge.
- Returns:
tensor – output message
Returns – the message matrix, and the shape is [num_edges, message_dim]