Here, a more detailed answer.
I have a tutorial which shows accessing specific elements in detail. It doesn’t set the weight to zero and requires grad to False, but shows how to access the parameters. Here’s the github repo for the tutorial - https://github.com/Spandan-Madan/A-Collection-of-important-tasks-in-pytorch 117
In the tutorial go to cell 22 and modify the lines to be.
for child in model.children():
for param in child.parameters():
param =  torch.zeros(param.size())
param.requires_grad = False
This will basically prune all nodes of the model. To specify which nodes are to be pruned just add if statements in the above code to prune only the required nodes! Just add another for loop to loop over the elements within child.parameters().
Hope this helps!