torch_geometric.nn.conv.ResGatedGraphConv

class ResGatedGraphConv(in_channels: Union[int, Tuple[int, int]], out_channels: int, act: Optional[Callable] = Sigmoid(), edge_dim: Optional[int] = None, root_weight: bool = True, bias: bool = True, **kwargs)[source]

Bases: MessagePassing

来自“Residual Gated Graph ConvNets”论文的残差门控图卷积操作符。

\[\mathbf{x}^{\prime}_i = \mathbf{W}_1 \mathbf{x}_i + \sum_{j \in \mathcal{N}(i)} \eta_{i,j} \odot \mathbf{W}_2 \mathbf{x}_j\]

其中门 \(\eta_{i,j}\) 被定义为

\[\eta_{i,j} = \sigma(\mathbf{W}_3 \mathbf{x}_i + \mathbf{W}_4 \mathbf{x}_j)\]

其中 \(\sigma\) 表示 sigmoid 函数。

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.

  • act (可调用的, 可选的) – 门控函数 \(\sigma\). (默认: torch.nn.Sigmoid())

  • edge_dim (int, optional) – 边的特征维度(如果有的话)。(默认值: None)

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

  • root_weight (bool, optional) – If set to False, the layer will not add transformed root node features to the output. (default: True)

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

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

  • 输出: 节点特征 \((|\mathcal{V}|, F_{out})\)\((|\mathcal{V_t}|, F_{out})\) 如果是二分图

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

运行模块的前向传播。

Return type:

Tensor

reset_parameters()[source]

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