Skip to content

Question about the decoupled weight decay in Adam #152

@milancurcic

Description

@milancurcic

Currently, we wrote:

param = param &
- self % learning_rate * m_hat / (sqrt(v_hat) + self % epsilon) &
- self % weight_decay_decoupled * param

However, I'm looking at the paper and PyTorch docs again.

In the paper, in Algorithm 2, line 12, we have $\lambda \theta_{t-1}$ (in our code, self % weight_decay_decoupled * param) multiplied by the schedule multiplier $\eta_t$, but not the learning rate $\alpha$.

In the PyTorch docs for AdamW, $\lambda \theta_{t-1}$ is multiplied by the learning rate. I can also see that from the source code. I'm not familiar with PyTorch design, but it's possible that the schedule multiplier is already accounted for in the learning rate.

I looked at Keras source and I don't even see where and if the weight decay is even used (??).

@Spnetic-5 do you also see the same discrepancy between the paper and the PyTorch docs like I do?

If yes, I suggest that we multiply it with the learning rate in our code as well. I trust more that the PyTorch implements it correctly than that we are correctly interpreting the paper (and papers have typos, of course).

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions