Reverse spectral_norm and restore a plain leaf parameter.
Copies module.<name>_orig back into a fresh leaf parameter
module.<name>, removes the <name>_u / <name>_v power-
iteration buffers, and detaches the forward pre-hook. Used before
exporting for inference when the normalisation overhead is no
longer wanted, or before fine-tuning without the spectral cap.
Parameters
moduleModuleModule previously passed through
spectral_norm.namestr= 'weight'Attribute name of the parameter to restore. Default
"weight".Returns
ModuleThe same module, with <name> as a plain
lucid.nn.parameter.Parameter carrying the unnormalised
weight that was being trained behind the parametrisation.
Raises
ValueErrorIf no spectral-norm registration exists on
<name>.Notes
The restored parameter is — not the rescaled that was visible during training. If you want the normalised matrix in the final checkpoint, copy it out before calling this function.
Examples
>>> import lucid.nn as nn
>>> from lucid.nn.utils import spectral_norm, remove_spectral_norm
>>> disc = spectral_norm(nn.Linear(16, 1))
>>> _ = remove_spectral_norm(disc)
>>> sorted(name for name, _ in disc.named_parameters())
['bias', 'weight']