torch.nn.utils.remove_weight_norm
function remove_weight_norm<T extends Module>(module: T, options?: RemoveWeightNormOptions): Tfunction remove_weight_norm<T extends Module>(module: T, name: string, options?: RemoveWeightNormOptions): TRemove the weight normalization reparameterization from a module.
This removes the weight_v and weight_g parameters and replaces them with a single weight parameter containing the current normalized weight values.
Parameters
moduleT- Module with weight normalization applied
optionsRemoveWeightNormOptionsoptional- Optional settings for removing weight normalization
Returns
T– The module with weight normalization removedExamples
// Apply weight norm
torch.nn.utils.weight_norm(linear, 'weight');
// Later, remove it (e.g., before saving)
torch.nn.utils.remove_weight_norm(linear, { name: 'weight' });