torch_geometric.nn.norm.MeanSubtractionNorm

class MeanSubtractionNorm[source]

Bases: Module

应用层归一化,通过从输入中减去均值,如“Revisiting ‘Over-smoothing’ in Deep GCNs”论文中所述。

\[\mathbf{x}_i = \mathbf{x}_i - \frac{1}{|\mathcal{V}|} \sum_{j \in \mathcal{V}} \mathbf{x}_j\]
forward(x: Tensor, batch: Optional[Tensor] = None, dim_size: Optional[int] = None) Tensor[source]

前向传播。

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

  • batch (torch.Tensor, optional) – The batch vector \(\mathbf{b} \in {\{ 0, \ldots, B-1\}}^N\), which assigns each element to a specific example. (default: None)

  • dim_size (int, optional) – 在给定batch的情况下,示例的数量 \(B\)。(默认值:None

Return type:

Tensor