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
RMSNorm
RMSNormβ
class max.experimental.nn.norm.RMSNorm(dim, eps=1e-06)
Bases: Module
Root mean square normalization over the last dimension of the input.
Unlike LayerNorm, the mean is not subtracted; only the
root-mean-square is used to rescale. See Root Mean Square Layer
Normalization for the formulation.
For the Gemma variant that uses 1 + weight and multiplies before
casting back, see GemmaRMSNorm.
from max.driver import Accelerator
from max.dtype import DType
from max.experimental.nn.norm import RMSNorm
from max.experimental.tensor import Tensor
device = Accelerator()
norm = RMSNorm(2048, eps=1e-6).to(device)
x = Tensor.ones([2, 4, 2048], dtype=DType.float32, device=device)
y = norm(x)-
Parameters:
dimβ
property dim: Dim
The size of the last dimension over which normalization runs.
epsβ
eps: float
The variance epsilon used for numerical stability.
forward()β
forward(x)
Returns x normalized by its root-mean-square over the last axis.
weightβ
weight: Tensor
The learned per-element scale of shape [dim].
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!