facebookresearch / open_lth

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

How not to update pruned weights? #6

Open rahimentezari opened 4 years ago

rahimentezari commented 4 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 4 years ago

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