L2Norm#
- class L2Norm(dim=-1, eps=1e-12)#
Bases:
ModuleL2 normalisation layer — learnable-parameter-free,
LazyConfig-friendly.Wraps
F.normalize(x, p=2, dim=self.dim)as annn.Moduleso it can be used as anorm_cfgtarget ininstantiate()wherever a plain normalisation module is expected (e.g. as the QK-norm inViT5Attention).Duck-typing
The
channels_firstproperty returnsTruewhendim == 1, matching the convention used byRMSNormChannelFirstso callers can detect the memory layout without anisinstancecheck.- Parameters:
- __init__(dim=-1, eps=1e-12)#
Initialise L2Norm.