IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).

Python class

LayerNorm

LayerNorm​

class max.experimental.nn.norm.LayerNorm(dim, eps=1e-05, *, keep_dtype=True, elementwise_affine=True, use_bias=True)

source

Bases: Module

Layer normalization over the last dimension.

Initialize LayerNorm.

Parameters:

  • dim (int) – Size of the last dimension to normalize.
  • eps (float) – Numerical stability constant.
  • keep_dtype (bool) – Whether to preserve input dtype in computation.
  • elementwise_affine (bool) – Whether to apply learned scale.
  • use_bias (bool) – Whether to apply a bias. It’s only effective if elementwise_affine is True.

bias​

bias: Tensor | None

source

forward()​

forward(x)

source

Applies layer normalization to the input.

Parameters:

x (Tensor)

Return type:

Tensor

weight​

weight: Tensor | None

source