torch_geometric.nn.norm.InstanceNorm
- class InstanceNorm(in_channels: int, eps: float = 1e-05, momentum: float = 0.1, affine: bool = False, track_running_stats: bool = False)[source]
基础类:
_InstanceNorm对一批节点特征中的每个单独示例应用实例归一化,如“实例归一化:快速风格化的缺失成分”论文中所述。
\[\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)momentum (float, optional) – The value used for the running mean and running variance computation. (default:
0.1)affine (bool, 可选) – 如果设置为
True,此模块具有可学习的仿射参数 \(\gamma\) 和 \(\beta\)。 (默认:False)track_running_stats (bool, 可选) – 如果设置为
True,此模块会跟踪运行中的均值和方差,当设置为False时,此模块不会跟踪这些统计信息,并且在训练和评估模式下始终使用实例统计信息。(默认值:False)
- forward(x: Tensor, batch: Optional[Tensor] = None, batch_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)batch_size (int, optional) – The number of examples \(B\). Automatically calculated if not given. (default:
None)
- Return type: