torch_geometric.nn.norm.MessageNorm

class MessageNorm(learn_scale: bool = False)[source]

Bases: Module

应用消息归一化于聚合消息,如“DeeperGCNs: All You Need to Train Deeper GCNs”论文中所述。

\[\mathbf{x}_i^{\prime} = \mathrm{MLP} \left( \mathbf{x}_{i} + s \cdot {\| \mathbf{x}_i \|}_2 \cdot \frac{\mathbf{m}_{i}}{{\|\mathbf{m}_i\|}_2} \right)\]
Parameters:

learn_scale (bool, 可选) – 如果设置为 True,将学习消息归一化的缩放因子 \(s\)。 (默认: False)

reset_parameters()[source]

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

forward(x: Tensor, msg: Tensor, p: float = 2.0) Tensor[source]

前向传播。

Parameters:
  • x (torch.Tensor) – The source tensor.

  • msg (torch.Tensor) – 消息张量 \(\mathbf{M}\).

  • p (float, optional) – 用于归一化的范数 \(p\)。 (默认值: 2.0)

Return type:

Tensor