torch_geometric.nn.models.JumpingKnowledge

class JumpingKnowledge(mode: str, channels: Optional[int] = None, num_layers: Optional[int] = None)[source]

Bases: Module

跳跃知识层聚合模块来自 “Representation Learning on Graphs with Jumping Knowledge Networks” 论文。

跳跃知识是基于连接 ("cat")执行的

\[\mathbf{x}_v^{(1)} \, \Vert \, \ldots \, \Vert \, \mathbf{x}_v^{(T)},\]

最大池化 ("max")

\[\max \left( \mathbf{x}_v^{(1)}, \ldots, \mathbf{x}_v^{(T)} \right),\]

加权求和

\[\sum_{t=1}^T \alpha_v^{(t)} \mathbf{x}_v^{(t)}\]

使用从双向LSTM("lstm")获得的注意力分数\(\alpha_v^{(t)}\)

Parameters:
  • mode (str) – 使用的聚合方案 ("cat", "max""lstm").

  • channels (int, optional) – 每个表示的通道数。 仅在使用LSTM风格的聚合时需要设置。 (默认值: None)

  • num_layers (int, optional) – 要聚合的层数。仅在LSTM风格的聚合时需要设置。(默认值:None

forward(xs: List[Tensor]) Tensor[source]

前向传播。

Parameters:

xs (List[torch.Tensor]) – 包含逐层表示的列表。

Return type:

Tensor

reset_parameters() None[source]

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

Return type:

None