torch_geometric.nn.norm.BatchNorm
- class BatchNorm(in_channels: int, eps: float = 1e-05, momentum: Optional[float] = 0.1, affine: bool = True, track_running_stats: bool = True, allow_single_element: bool = False)[source]
Bases:
Module对一批特征应用批量归一化,如“批量归一化:通过减少内部协变量偏移加速深度网络训练”论文中所述。
\[\mathbf{x}^{\prime}_i = \frac{\mathbf{x} - \textrm{E}[\mathbf{x}]}{\sqrt{\textrm{Var}[\mathbf{x}] + \epsilon}} \odot \gamma + \beta\]均值和标准差是在小批量中的所有节点上按维度计算的。
- Parameters:
in_channels (int) – Size of each input sample.
eps (float, optional) – A value added to the denominator for numerical stability. (default:
1e-5)动量 (float, 可选) – 用于计算运行平均值和运行方差的值。(默认值:
0.1)affine (bool, optional) – If set to
True, this module has learnable affine parameters \(\gamma\) and \(\beta\). (default:True)track_running_stats (bool, optional) – 如果设置为
True,此模块会跟踪运行中的均值和方差,当设置为False时,此模块不会跟踪这些统计信息,并且在训练和评估模式下始终使用批量统计信息。(默认值:True)allow_single_element (bool, 可选) – 如果设置为
True,则只有单个元素的批次将在评估期间工作。 即使用运行均值和方差。 需要track_running_stats=True。(默认值:False)