Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spot bug in SGDW implementation (weight decay part) #454

Open
Leiay opened this issue Aug 8, 2022 · 0 comments
Open

spot bug in SGDW implementation (weight decay part) #454

Leiay opened this issue Aug 8, 2022 · 0 comments

Comments

@Leiay
Copy link

Leiay commented Aug 8, 2022

Hi,

I was using the SGDW implementation in this repo, and I wonder if anything is wrong with this line:

p.data.add_(weight_decay, alpha=-group['lr'])

Let weight decay be $\lambda$ and learning rate be $\mu_t$. If I understand it correctly, this line of code update weight decay with
$$\theta_t \leftarrow \tilde{\theta}_t - \lambda \mu_t$$
where (follow the notation in the paper)

$$\tilde{\theta}_t \leftarrow \theta_{t-1} - m_t$$

But it should be

$$ \begin{aligned} \theta_{t-1} &\leftarrow \theta_{t-1} \cdot (1 - \lambda \mu_t) \\ \theta_t &\leftarrow \theta_{t-1} - m_t \end{aligned} $$

as in the paper:
image

This result in poor performance of training compared to SGD with the same set of optimization hyper-parameter.

Thanks!

Regards, Liu

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

No branches or pull requests

1 participant