megengine.functional.nn.layer_norm#

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

Applies layer normalization to the input. Support tensor of any shape as input. Reference: https://arxiv.org/pdf/1803.08494.pdf.

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

  • normalized_shape (tuple) – the shape that you want to be normalizated

  • affine (bool) – whether to use weight and bias

  • weight (Optional[Tensor]) – must not be None when the affine is true

  • bias (Optional[Tensor]) – must not be None when the affine is true

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