tensorflow / addons

Useful extra functionality for TensorFlow 2.x maintained by SIG-addons
Apache License 2.0
1.69k stars 610 forks source link

optimizers.MovingAverage not working with tf2.11 #2797

Open Ianni opened 1 year ago

Ianni commented 1 year ago

System information

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 commented 1 year ago

/cc @chenmoneygithub

bhack commented 1 year ago

/cc @chenmoneygithub

bobertlo commented 1 year ago

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.