gammagl.layers.conv.AGNNConv¶
- class AGNNConv(in_channels, require_grad=True)[source]¶
The graph attention operator from the “Attention-based Graph Neural Network for Semi-supervised Learning” paper
\[\mathbf{X}^{(i+1)} = \mathbf{P} \mathbf{X}^{(i)}\]where the propagation matrix \(\mathbf{P}\) is computed as
\[P_{i,j} = \frac{\exp( \beta \cdot \cos(\mathbf{x}_i, \mathbf{x}_j))} {\sum_{k \in \mathcal{N}(i)\cup \{ i \}} \exp( \beta \cdot \cos(\mathbf{x}_i, \mathbf{x}_k))}\]with trainable parameter \(\beta\).
- Parameters:
in_channels (int) – Size of each input sample.
out_channels (int) – Size of each output sample.
edge_index (2-D tensor) – Shape:(2, num_edges). A element(integer) of dim-1 expresses a node of graph and edge_index[0,i] points to edge_index[1,i].
num_nodes (int) – Number of nodes on the graph.
require_grad (bool, optional) – If set to
False, \(\beta\) will not be trainable. (default:True)
- message(x, edge_index, num_nodes, edge_weight=None)[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]
- forward(x, edge_index, num_nodes)[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.