gammagl.layers.conv.PNAConv¶
- class PNAConv(in_channels, out_channels, aggregators, scalers, deg, edge_dim, towers=1, pre_layers=1, post_layers=1, divide_input=False)[source]¶
The Principal Neighbourhood Aggregation graph convolution operator from the “Principal Neighbourhood Aggregation for Graph Nets” paper
\[\mathbf{x}_i^{\prime} = \gamma_{\mathbf{\Theta}} \left( \mathbf{x}_i, \underset{j \in \mathcal{N}(i)}{\bigoplus} h_{\mathbf{\Theta}} \left( \mathbf{x}_i, \mathbf{x}_j \right) \right)\]with
\[\begin{split}\bigoplus = \underbrace{\begin{bmatrix} 1 \\ S(\mathbf{D}, \alpha=1) \\ S(\mathbf{D}, \alpha=-1) \end{bmatrix} }_{\text{scalers}} \otimes \underbrace{\begin{bmatrix} \mu \\ \sigma \\ \max \\ \min \end{bmatrix}}_{\text{aggregators}},\end{split}\]where \(\gamma_{\mathbf{\Theta}}\) and \(h_{\mathbf{\Theta}}\) denote MLPs.
- Parameters:
in_channels (int) – Size of each input sample, or
-1to derive the size from the first input(s) to the forward method.out_channels (int) – Size of each output sample.
aggregators (list[str]) – Set of aggregation function identifiers, namely
"sum","mean","min","max","var"and"std".scalers (list[str]) – Set of scaling function identifiers, namely
"identity","amplification","attenuation","linear"and"inverse_linear".deg (tensor) – Histogram of in-degrees of nodes in the training set, used by scalers to normalize.
edge_dim (int, optional) – Edge feature dimensionality (in case there are any). (default
None)towers (int, optional) – Number of towers (default:
1).pre_layers (int, optional) – Number of transformation layers before aggregation (default:
1).post_layers (int, optional) – Number of transformation layers after aggregation (default:
1).divide_input (bool, optional) – Whether the input features should be split between towers or not (default:
False).Shapes –
input: node features \((|\mathcal{V}|, F_{in})\), edge indices \((2, |\mathcal{E}|)\), edge features \((|\mathcal{E}|, D)\) (optional)
output: node features \((|\mathcal{V}|, F_{out})\)
- forward(x, edge_index, edge_attr=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, edge_attr=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]