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

optimizers.MovingAverage not working with tf2.11 #2797

Open
Ianni opened this issue Jan 9, 2023 · 4 comments
Open

optimizers.MovingAverage not working with tf2.11 #2797

Ianni opened this issue Jan 9, 2023 · 4 comments

Comments

@Ianni
Copy link

Ianni commented Jan 9, 2023

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu 22.04
  • TensorFlow version and how it was installed (source or binary): 2.11 pip wheel
  • TensorFlow-Addons version and how it was installed (source or binary): 0.19 pip
  • Python version: 3.9
  • Is GPU used? (yes/no): yes

Describe the bug

Using moving average of optimizers is no longer working and results in

TypeError: optimizer is not an object of tf.keras.optimizers.Optimizer or tf.keras.optimizers.legacy.Optimizer (if you have tf version >= 2.11.0).

Code to reproduce the issue

Compare e.g. the example notebook from the documentation:
https://www.tensorflow.org/addons/tutorials/average_optimizers_callback

Note: if you try it in collab, you have to install tf2.11 first.

Other info / logs

See also https://www.tensorflow.org/addons/api_docs/python/tfa/optimizers/MovingAverage

@bhack
Copy link
Contributor

bhack commented Jan 9, 2023

/cc @chenmoneygithub

1 similar comment
@bhack
Copy link
Contributor

bhack commented Jan 9, 2023

/cc @chenmoneygithub

@bobertlo
Copy link

I got this also. I encountered the same error on SWA, then found a collar notebook using MovingAverage before SWA and that has the same error in the collar runtime as I was getting on my laptop.

@bertsky
Copy link

bertsky commented Sep 28, 2024

As the error message already states: with TF >= 2.11, you have to wrap an tf.keras.optimizers.legacy.Optimizer rather than tf.keras.optimizers.Optimizer (because the latter is now what used to be tf.keras.optimizers.experimental.Optimizer).

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

4 participants