megengine.functional.nn.layer_norm

layer_norm(inp, normalized_shape, affine, weight=None, bias=None, eps=1e-05)[源代码]

channel 方向做归一化,算 chw 的均值,细节请参考: https://arxiv.org/pdf/1803.08494.pdf

参数
  • inp (Tensor) – 输入张量。

  • normalized_shape (tuple) – 输入尺寸。

  • affine (bool) – 布尔值,当设为 True,给该层添加可学习的仿射变换参数。

  • weight (Optional[Tensor]) – weight 和 bias Tensor, 如果 affine 为 True, 则此 Tensor 不能为空。

  • bias (Optional[Tensor]) – weight 和 bias Tensor, 如果 affine 为 True, 则此 Tensor 不能为空。

  • eps (float) – 添加到分母的单个值,增加数值稳定性。默认:1e-5