What's the param `conv1.weight_g` used in conv1d

Recently I want to know the exact param that stored in conv1d layer. But when I print them from a trained-model state_dict, i found that there are 3 tensor.
‘’’
network.0.conv1.bias | torch.Size([10])|
network.0.conv1.weight_g | torch.Size([10, 1, 1])|
network.0.conv1.weight_v | torch.Size([10, 4, 5])|
‘’’

  • My conv1d config is : nn.conv1d(4,20, kernel_size = 5, padding = 4, dilation = 1).
  • My pytorch is : 1.13.1
    What is conv1.weight_g means? I couldn’t find any docs about it.

These additional parameters are added if you use the deprecated torch.nn.utils.weight_norm:

conv = nn.Conv1d(3, 3, 3)
print(conv.weight)

conv = torch.nn.utils.weight_norm(conv)
print(conv.weight)
print(conv.weight_g)
print(conv.weight_v)

The recommendation is to use the supported torch.nn.utils.parametrizations.weight_norm API.

Oh! Now I see. Thank you.:slight_smile: