torch_geometric.nn.norm.MeanSubtractionNorm

class MeanSubtractionNorm[source]

Bases: Module

Applies layer normalization by subtracting the mean from the inputs as described in the “Revisiting ‘Over-smoothing’ in Deep GCNs” paper.

\[\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]

Forward pass.

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) – The number of examples \(B\) in case batch is given. (default: None)