remove_weight_norm

paddle.nn.utils. remove_weight_norm ( layer, name='weight' ) [source]

remove weight normalization from layer.

Parameters
  • layer (Layer) – Layer of paddle, which has weight.

  • name (str, optional) – Name of the weight parameter. Default: ‘weight’.

Returns

Layer, the origin layer without weight norm

Examples

import paddle
from paddle.nn import Conv2D
from paddle.nn.utils import weight_norm, remove_weight_norm

conv = Conv2D(3, 5, 3)
wn = weight_norm(conv)
print(conv.weight_g)
# Parameter containing:
# Tensor(shape=[5], dtype=float32, place=Place(gpu:0), stop_gradient=False,
#        [0., 0., 0., 0., 0.])
# Conv2D(3, 5, kernel_size=[3, 3], data_format=NCHW)

remove_weight_norm(conv)
# The following is the effect after removing the weight norm:
# print(conv.weight_g)
# AttributeError: 'Conv2D' object has no attribute 'weight_g'