mlx.core.fast.layer_norm

目錄

mlx.core.fast.layer_norm#

layer_norm(x: array, weight: array | None, bias: array | None, eps: float, *, stream: None | Stream | Device = None) array#

Layer normalization.

The normalization is with respect to the last axis of the input x.

參數:
  • x (array) -- 輸入陣列。

  • weight (array, optional) -- A multiplicative weight to scale the result by. The weight should be one-dimensional with the same size as the last axis of x. If set to None then no scaling happens.

  • bias (array, optional) -- An additive offset to be added to the result. The bias should be one-dimensional with the same size as the last axis of x. If set to None then no translation happens.

  • eps (float) -- A small additive constant for numerical stability.

回傳值:

輸出陣列。

回傳值型別:

array