facebookresearch / open_lth

A repository in preparation for open-sourcing lottery ticket hypothesis code.
MIT License
622 stars 113 forks source link

How not to update pruned weights? #6

Open rahimentezari opened 3 years ago

rahimentezari commented 3 years ago

Thanks again for your great work and code. I tried different ways to take care of pruned weights, i.e. keep them zero, for example running the following line for each batch: output.register_hook(lambda grad: grad * mask.float())

But this is very slow. I looked for your solution as yours is much faster but could not find the specific lines. Can you please elaborate on what you do to prevent pruned weights from updating (gradients backprop)?

jfrankle commented 3 years ago

Look here: https://github.com/facebookresearch/open_lth/blob/master/pruning/pruned_model.py