torch_geometric.nn.conv.EGConv

class EGConv(in_channels: int, out_channels: int, aggregators: List[str] = ['symnorm'], num_heads: int = 8, num_bases: int = 4, cached: bool = False, add_self_loops: bool = True, bias: bool = True, **kwargs)[source]

Bases: MessagePassing

来自“自适应滤波器和聚合器融合用于高效图卷积”论文的高效图卷积。

其节点式公式如下:

\[\mathbf{x}_i^{\prime} = {\LARGE ||}_{h=1}^H \sum_{\oplus \in \mathcal{A}} \sum_{b = 1}^B w_{i, h, \oplus, b} \; \underset{j \in \mathcal{N}(i) \cup \{i\}}{\bigoplus} \mathbf{W}_b \mathbf{x}_{j}\]

其中 \(\mathbf{W}_b\) 表示基础权重, \(\oplus\) 表示聚合器,\(w\) 表示每个顶点 在不同头、基础和聚合器之间的权重系数。

EGC 保留了 \(\mathcal{O}(|\mathcal{V}|)\) 的内存使用量,使其成为 GCNConvSAGEConvGINConv 的合理替代方案。

注意

有关使用EGConv的示例,请参见examples/egc.py

Parameters:
  • in_channels (int) – 每个输入样本的大小,或 -1 以从 forward 方法的第一个输入推导出大小。

  • out_channels (int) – Size of each output sample.

  • aggregators (List[str], optional) – 要使用的聚合器。 支持的聚合器有 "sum", "mean", "symnorm", "max", "min", "std", "var"。 可以使用多个聚合器来提高性能。 (默认: ["symnorm"])

  • num_heads (int, optional) – 使用的头数 \(H\)。必须满足 out_channels % num_heads == 0。建议设置 num_heads >= num_bases。(默认值:8

  • num_bases (int, optional) – 使用的基础权重数量 \(B\)。 (默认: 4)

  • cached (bool, optional) – 如果设置为 True,该层将在第一次执行时缓存添加自循环的边索引的计算,如果使用了 "symnorm" 聚合器,还会缓存对称归一化边权重的计算。此参数应仅在传导学习场景中设置为 True。(默认值:False

  • add_self_loops (bool, optional) – If set to False, will not add self-loops to the input graph. (default: True)

  • bias (bool, optional) – If set to False, the layer will not learn an additive bias. (default: True)

  • **kwargs (optional) – Additional arguments of torch_geometric.nn.conv.MessagePassing.

Shapes:
  • 输入: 节点特征 \((|\mathcal{V}|, F_{in})\), 边索引 \((2, |\mathcal{E}|)\)

  • 输出: 节点特征 \((|\mathcal{V}|, F_{out})\)

forward(x: Tensor, edge_index: Union[Tensor, SparseTensor]) Tensor[source]

运行模块的前向传播。

Return type:

Tensor

reset_parameters()[source]

重置模块的所有可学习参数。