torch_geometric.nn.conv.PNAConv
- class PNAConv(in_channels: int, out_channels: int, aggregators: List[str], scalers: List[str], deg: Tensor, edge_dim: Optional[int] = None, towers: int = 1, pre_layers: int = 1, post_layers: int = 1, divide_input: bool = False, act: Optional[Union[str, Callable]] = 'relu', act_kwargs: Optional[Dict[str, Any]] = None, train_norm: bool = False, **kwargs)[source]
Bases:
MessagePassing来自“Principal Neighbourhood Aggregation for Graph Nets”论文的主邻域聚合图卷积算子。
\[\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)\]使用
\[\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}\]其中 \(\gamma_{\mathbf{\Theta}}\) 和 \(h_{\mathbf{\Theta}}\) 表示多层感知机。
注意
有关使用
PNAConv的示例,请参见 examples/pna.py。- 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]) – 聚合函数标识符的集合, 即
"sum","mean","min","max","var"和"std"。scalers (List[str]) – 一组缩放函数标识符,即
"identity","amplification","attenuation","linear"和"inverse_linear"。deg (torch.Tensor) – 训练集中节点的入度直方图,用于缩放器进行归一化。
towers (int, optional) – 塔的数量(默认值:
1)。pre_layers (int, optional) – 聚合前的转换层数(默认值:
1)。post_layers (int, optional) – 聚合后的转换层数(默认:
1)。act (str 或 callable, 可选) – 用于层前后的激活函数。(默认:
"relu")act_kwargs (Dict[str, Any], optional) – Arguments passed to the respective activation function defined by
act. (default:None)train_norm (bool, optional) – Whether normalization parameters are trainable. (default:
False)**kwargs (optional) – Additional arguments of
torch_geometric.nn.conv.MessagePassing.
- 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})\)