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
-1to 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 (str 或 Aggregation, 可选) – 使用的聚合方案。 可以使用
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)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