Skip to main content

Python class

LayerNorm

LayerNorm

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

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

forward()

forward(x)

Applies layer normalization to the input.

Parameters:

x (Tensor)

Return type:

Tensor

weight

weight: Tensor | None

Was this page helpful?