Skip to content

Fix: PriorWD inadvertently sets the weight_decay coefficient for all groups to 0.0 when use_prior_wd flag is False - #5

Open
ykumards wants to merge 2 commits into
asappresearch:masterfrom
ykumards:master
Open

Fix: PriorWD inadvertently sets the weight_decay coefficient for all groups to 0.0 when use_prior_wd flag is False#5
ykumards wants to merge 2 commits into
asappresearch:masterfrom
ykumards:master

Conversation

@ykumards

Copy link
Copy Markdown

Probably don't need to merge this, but can serve as a reference for people who fork the repo.

Problem

The PriorWD is wrapper around any optimizer which can be used to perform weight decay by suppressing ||w - w_0||^2 instead of ||w - 0||^2 during training.

optimizer = optim.AdamW(self.parameters(), lr=1e-3, weight_decay=0.01)
optimizer = PriorWD(optimizer, use_prior_wd=True)

When use_prior_wd is set to True, the class behaves as expected. When it is set to False, the wrapper needs to function as an Identity mapping on the optimizer, but it inadvertently sets the weight decay to 0.0.

This was fixed by simply adding a conditional statement with use_prior_wd flag during initialization.

add an if-flag to class init, this avoids inadvertently setting the group wd coefficient to 0.0 when `use_prior_wd` is set to False
Fix: PriorWD inadvertently sets the weight_decay coefficient for all groups to 0.0 when `use_prior_wd` flag is False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant