This is need for some reparametrization code.
Weight norm code uses del module._parameters[name] for that.
Also requested on forum: https://discuss.pytorch.org/t/how-to-unregister-a-parameter-from-a-module/36424 and many other: https://discuss.pytorch.org/t/exclude-parameters-from-model/77238/6 https://discuss.pytorch.org/t/how-to-exclude-parameters-from-model/6151 https://discuss.pytorch.org/t/delete-unregister-a-parameter-in-a-module/66302. Maybe it is a duplicate issue as well? I may have missed it
I used module.register_parameter('weight', None) for that goal (to overwrite an existing parameter with a None one)
Having an explicit/documented method may be useful
cc @albanD @mruberry
This is need for some reparametrization code.
Weight norm code uses
del module._parameters[name]for that.Also requested on forum: https://discuss.pytorch.org/t/how-to-unregister-a-parameter-from-a-module/36424 and many other: https://discuss.pytorch.org/t/exclude-parameters-from-model/77238/6 https://discuss.pytorch.org/t/how-to-exclude-parameters-from-model/6151 https://discuss.pytorch.org/t/delete-unregister-a-parameter-in-a-module/66302. Maybe it is a duplicate issue as well? I may have missed it
I used
module.register_parameter('weight', None)for that goal (to overwrite an existing parameter with a None one)Having an explicit/documented method may be useful
cc @albanD @mruberry