Global structure pruning in pytorch

Hi, I have a question about structure pruning. I used pytorch structure pruning for global pruning. I could find 0 in weight_mask, before prune.remove(module, ‘weight’)
My code is like this:
`
for name, module in model.model.named_modules():

if isinstance(module, nn.Conv2d):
    if 0 in module.weight_mask:
        print(module.weight)
prune.remove(module, 'weight')

`
print(module.weight) can show 0 weights, but after prune.remove, it still shows that the weight as original. Do you know what problem is there? Thank you so much

This gist should answer this question!

Thank you. yes it doesn’t remove the 0 parameters, so I think in order to do it, a new model have to be created, but in yolov8n model, there’s no architecture code.

Is this not what you’re looking for?

Thank you so much. I think the whole structure is written by yaml file. What I want is a python code architecture. This allows me to do some changes like pruning, but yaml file doesn’t allow me to do changes.

Sorry, should’ve made myself clear (and the late reply!) → You should look into the trainer.py

This is what is inherited overall.