remove_weight_norm

paddle.nn.utils.remove_weight_norm ( layer, name=’weight’ ) [源代码]

移除传入 layer 中的权重归一化。

参数:

  • layer (paddle.nn.Layer) - 要添加权重归一化的层。

  • name (str, 可选) - 权重参数的名字。默认:’weight’.

返回:

Layer , 移除权重归一化hook之后的层

代码示例

  1. import paddle
  2. from paddle.nn import Conv2D
  3. from paddle.nn.utils import weight_norm, remove_weight_norm
  4. conv = Conv2D(3, 5, 3)
  5. wn = weight_norm(conv)
  6. remove_weight_norm(conv)
  7. # print(conv.weight_g)
  8. # AttributeError: 'Conv2D' object has no attribute 'weight_g'