# torch_geometric.nn.norm.PairNorm

class PairNorm(scale: float = 1.0, scale_individually: bool = False, eps: float = 1e-05)[source]

Bases: Module

Applies pair normalization over node features as described in the “PairNorm: Tackling Oversmoothing in GNNs” paper

\begin{align}\begin{aligned}\begin{split}\mathbf{x}_i^c &= \mathbf{x}_i - \frac{1}{n} \sum_{i=1}^n \mathbf{x}_i \\\end{split}\\\mathbf{x}_i^{\prime} &= s \cdot \frac{\mathbf{x}_i^c}{\sqrt{\frac{1}{n} \sum_{i=1}^n {\| \mathbf{x}_i^c \|}^2_2}}\end{aligned}\end{align}
Parameters
• scale (float, optional) – Scaling factor $$s$$ of normalization. (default, 1.)

• scale_individually (bool, optional) – If set to True, will compute the scaling step as $$\mathbf{x}^{\prime}_i = s \cdot \frac{\mathbf{x}_i^c}{{\| \mathbf{x}_i^c \|}_2}$$. (default: False)

• eps (float, optional) – A value added to the denominator for numerical stability. (default: 1e-5)

forward(x: Tensor, batch: = None) [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)