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

tf.keras.optimizers.experimental.AdamW only support constant weight_decay #55824

Closed
x10000year opened this issue May 2, 2022 · 5 comments
Closed
Assignees
Labels
comp:keras Keras related issues stale This label marks the issue/pr stale - to be closed automatically if no activity stat:awaiting response Status - Awaiting response from author TF 2.8 type:feature Feature requests

Comments

@x10000year
Copy link

x10000year commented May 2, 2022

Click to expand!

Issue Type

Feature Request

Source

source

Tensorflow Version

2.8

Custom Code

No

OS Platform and Distribution

No response

Mobile device

No response

Python version

No response

Bazel version

No response

GCC/Compiler version

No response

CUDA/cuDNN version

No response

GPU model and memory

No response

Current Behaviour?

tf.keras.optimizers.experimental.AdamW only supports constant weight decay. But usually we want the weight_decay value to decay with learning rate schedule.

Standalone code to reproduce the issue

The legacy tfa.optimizers.AdamW supports callable weight_decay, which is much better.

Relevant log output

No response

@google-ml-butler google-ml-butler bot added the type:feature Feature requests label May 2, 2022
@mohantym mohantym assigned sushreebarsa and unassigned mohantym May 2, 2022
@sushreebarsa sushreebarsa added the comp:ops OPs related issues label May 4, 2022
@gadagashwini gadagashwini added comp:keras Keras related issues TF 2.8 and removed comp:ops OPs related issues labels May 4, 2022
@gadagashwini
Copy link
Contributor

@x10000year, Thanks for proposing new feature request in TF.
Could you elaborate the feature with code snippet for better understanding. Thanks!

@gadagashwini gadagashwini added the stat:awaiting response Status - Awaiting response from author label May 4, 2022
@x10000year
Copy link
Author

x10000year commented May 8, 2022

model = MyModel()
schedule = tf.keras.optimizers.schedules.PolynomialDecay(
    1.0,
    decay_steps=10000)
learning_rate_fn = lambda: learning_rate * schedule(model.iterations.read_value())
weight_decay_fn = lambda: weight_decay * schedule(model.iterations.read_value())
optimizer = tfa.optimizers.AdamW(weight_decay=weight_decay_fn,
                                 learning_rate=learning_rate_fn)

As above code shows, tfa.optimizers.AdamW allows us to specify the schedule of weight decay, which should be in proportional with learning rate schedule. However, I cannot do the same thing with tf.keras.optimizers.experimental.AdamW.

@gadagashwini

@gadagashwini gadagashwini removed the stat:awaiting response Status - Awaiting response from author label May 9, 2022
@sachinprasadhs
Copy link
Contributor

Thanks for opening this issue. Development of keras moved to separate repository https://github.com/keras-team/keras/issues

Please post this issue on keras-team/keras repo.
To know more see;
https://discuss.tensorflow.org/t/keras-project-moved-to-new-repository-in-https-github-com-keras-team-keras/1999
Thank you!

@sachinprasadhs sachinprasadhs added the stat:awaiting response Status - Awaiting response from author label May 9, 2022
@google-ml-butler
Copy link

This issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Thank you.

@google-ml-butler google-ml-butler bot added the stale This label marks the issue/pr stale - to be closed automatically if no activity label May 16, 2022
@google-ml-butler
Copy link

Closing as stale. Please reopen if you'd like to work on this further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:keras Keras related issues stale This label marks the issue/pr stale - to be closed automatically if no activity stat:awaiting response Status - Awaiting response from author TF 2.8 type:feature Feature requests
Projects
None yet
Development

No branches or pull requests

5 participants