Weight in a module not showing up in named_parameters?

I pruned a simple model and when I try to show all the named_parameters, “weight” and “weight_mask” don’t doesn’t appear despite them existing (as you can see from the last two print statements). Why is this?

import torch.nn as nn
import torch.nn.functional as F
import torch
import torch.nn.utils.prune as prune

class Net(nn.Module):
    def __init__(self):
        self.fc1 = nn.Linear(2,5)
        self.fc3 = nn.Linear(5, 2)

    def forward(self, x):
        x = F.relu(self.fc1(x))
        x = self.fc3(x)
        return x
net = Net()

prune.l1_unstructured(net.fc3, name="weight", amount = 1)
for name, param in net.fc3.named_parameters():
# The above only prints weight_orig. It should also print "weight" and "weight_mask"


Hey @Goldname, looking at the documentation for torch.nn.utils.prune.l1_unstructured weight_mask should be stored in named_buffers.

With respect to missing weight that seems inconsistent with the documentation. It might be a bug perhaps you should file an issue.