megengine.functional.nn.layer_norm

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

对输入应用 layer normalization。

Refer to LayerNorm for more information.

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

  • normalized_shape (tuple) – the shape that you want to be normalizated See normalized_shape in LayerNorm.

  • affine (bool) – whether to use learnable affine parameters (weight, bias)

  • weight (Optional[Tensor]) – scaling tensor in the learnable affine parameters. See \(\gamma\) in LayerNorm.

  • bias (Optional[Tensor]) – bias tensor in the learnable affine parameters. See \(\beta\) in LayerNorm.

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