fn
remove_weight_norm
→Moduleremove_weight_norm(module: Module, name: str = 'weight')Reverse weight_norm and restore a plain leaf parameter.
Materialises
one last time, writes the result back as a single leaf parameter
module.<name>, drops <name>_g / <name>_v, and detaches
the forward pre-hook. Typical use is right before exporting a model
for inference where the reparametrised form is not needed.
Parameters
moduleModuleModule previously passed through
weight_norm.namestr= 'weight'Attribute name of the parameter to un-normalise. Must match the
name used at registration. Default "weight".Returns
ModuleThe same module, with <name> restored as a plain
lucid.nn.parameter.Parameter and the g/v
helpers removed.
Raises
ValueErrorIf no weight-norm registration exists on
<name>.Notes
The materialised parameter is detached from the autograd graph — any
history accumulated through the reparametrisation is discarded. If
you need the original v direction back, copy it out before
calling this.
Examples
>>> remove_weight_norm(layer)
>>> "weight_g" in dict(layer.named_parameters())
False