torch_geometric.nn.pool.PANPooling
- class PANPooling(in_channels: int, ratio: float = 0.5, min_score: Optional[float] = None, multiplier: float = 1.0, nonlinearity: Union[str, Callable] = 'tanh')[source]
Bases:
Module基于路径积分的池化操作符来自 “Path Integral Based Convolution and Pooling for Graph Neural Networks” 论文。
PAN池化执行顶部\(k\)池化,其中全局节点重要性基于节点特征和MET矩阵进行测量:
\[{\rm score} = \beta_1 \mathbf{X} \cdot \mathbf{p} + \beta_2 {\rm deg}(\mathbf{M})\]- Parameters:
in_channels (int) – Size of each input sample.
ratio (float) – 图池化比例,用于计算 \(k = \lceil \mathrm{ratio} \cdot N \rceil\). 如果 min_score 不为 None,则忽略此值。 (默认值:
0.5)min_score (float, optional) – Minimal node score \(\tilde{\alpha}\) which is used to compute indices of pooled nodes \(\mathbf{i} = \mathbf{y}_i > \tilde{\alpha}\). When this value is not
None, theratioargument is ignored. (default:None)multiplier (float, optional) – 池化后特征乘以的系数。这对于大型图和当使用
min_score时非常有用。(默认值:1.0)nonlinearity (str or callable, optional) – The non-linearity to use. (default:
"tanh")
- forward(x: Tensor, M: SparseTensor, batch: Optional[Tensor] = None) Tuple[Tensor, Tensor, Tensor, Optional[Tensor], Tensor, Tensor][source]
前向传播。
- Parameters:
x (torch.Tensor) – The node feature matrix.
M (SparseTensor) – MET矩阵 \(\mathbf{M}\).
batch (torch.Tensor, optional) – The batch vector \(\mathbf{b} \in {\{ 0, \ldots, B-1\}}^N\), which assigns each node to a specific example. (default:
None)
- Return type:
Tuple[Tensor,Tensor,Tensor,Optional[Tensor],Tensor,Tensor]