fn

remove_spectral_norm

Module
remove_spectral_norm(module: Module, name: str = 'weight')
source

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

moduleModule
Module previously passed through spectral_norm.
namestr= 'weight'
Attribute name of the parameter to restore. Default "weight".

Returns

Module

The same module, with <name> as a plain lucid.nn.parameter.Parameter carrying the unnormalised weight that was being trained behind the parametrisation.

Raises

ValueError
If no spectral-norm registration exists on <name>.

Notes

The restored parameter is Worig\mathbf{W}_{\text{orig}}not the rescaled Worig/σ\mathbf{W}_{\text{orig}} / \sigma that was visible during training. If you want the normalised matrix in the final checkpoint, copy it out before calling this function.

Examples

>>> remove_spectral_norm(disc)