torch_geometric.nn.conv.GENConv

class GENConv(in_channels: Union[int, Tuple[int, int]], out_channels: int, aggr: Optional[Union[str, List[str], Aggregation]] = 'softmax', t: float = 1.0, learn_t: bool = False, p: float = 1.0, learn_p: bool = False, msg_norm: bool = False, learn_msg_scale: bool = False, norm: str = 'batch', num_layers: int = 2, expansion: int = 2, eps: float = 1e-07, bias: bool = False, edge_dim: Optional[int] = None, **kwargs)[source]

Bases: MessagePassing

来自“DeeperGCN: All You Need to Train Deeper GCNs”论文的广义图卷积(GENConv)。

GENConv 支持 \(\textrm{softmax}\)(参见 SoftmaxAggregation)和 \(\textrm{powermean}\)(参见 PowerMeanAggregation)聚合。 它的消息构建如下:

\[\mathbf{x}_i^{\prime} = \mathrm{MLP} \left( \mathbf{x}_i + \mathrm{AGG} \left( \left\{ \mathrm{ReLU} \left( \mathbf{x}_j + \mathbf{e_{ji}} \right) +\epsilon : j \in \mathcal{N}(i) \right\} \right) \right)\]

注意

有关使用 GENConv 的示例,请参见 examples/ogbn_proteins_deepgcn.py

Parameters:
  • in_channels (int or tuple) – Size of each input sample, or -1 to derive the size from the first input(s) to the forward method. A tuple corresponds to the sizes of source and target dimensionalities.

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

  • aggr (strAggregation, 可选) – 使用的聚合方案。 可以使用 torch_geometric.nn.aggr 中的任何聚合方式, ("softmax", "powermean", "add", "mean", max)。(默认: "softmax")

  • t (float, optional) – Initial inverse temperature for softmax aggregation. (default: 1.0)

  • learn_t (bool, 可选) – 如果设置为 True,将动态学习用于 softmax 聚合的值 t。 (默认: False)

  • p (float, 可选) – 用于幂均值聚合的初始幂值。 (默认: 1.0)

  • learn_p (bool, 可选) – 如果设置为 True,将动态学习用于幂均值聚合的 p 值。 (默认: False)

  • msg_norm (bool, 可选) – 如果设置为 True,将使用消息 归一化。(默认值:False

  • learn_msg_scale (bool, optional) – 如果设置为 True,将学习消息归一化的缩放因子。(默认值:False

  • norm (str, 可选) – MLP层的归一化层 ("batch", "layer", "instance") (默认: batch)

  • num_layers (int, optional) – MLP的层数。 (默认值: 2)

  • expansion (int, optional) – MLP层中隐藏通道的扩展因子。(默认值: 2)

  • eps (float, optional) – 消息构建函数的epsilon值。(默认值:1e-7

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

  • edge_dim (int, 可选) – 边特征的维度。如果设置为 None,则期望边特征的维度与 out_channels 匹配。否则,边特征将被线性变换以匹配节点特征的 out_channels 维度。 (默认值: None)

  • **kwargs (可选) – torch_geometric.nn.conv.GenMessagePassing 的额外参数。

Shapes:
  • 输入: 节点特征 \((|\mathcal{V}|, F_{in})\)\(((|\mathcal{V_s}|, F_{s}), (|\mathcal{V_t}|, F_{t}))\) 如果是二分图, 边索引 \((2, |\mathcal{E}|)\), 边属性 \((|\mathcal{E}|, D)\) (可选)

  • output: node features \((|\mathcal{V}|, F_{out})\) or \((|\mathcal{V}_t|, F_{out})\) if bipartite

forward(x: Union[Tensor, Tuple[Tensor, Optional[Tensor]]], edge_index: Union[Tensor, SparseTensor], edge_attr: Optional[Tensor] = None, size: Optional[Tuple[int, int]] = None) Tensor[source]

运行模块的前向传播。

Return type:

Tensor

reset_parameters()[source]

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