Skip to content

Commit

Permalink
TF AdamWeightDecay fix for 2.11 (huggingface#20848)
Browse files Browse the repository at this point in the history
* Fix incorrect import for the base optimizer for AdamWeightDecay

* Fix incorrect import for the base optimizer for AdamWeightDecay
  • Loading branch information
Rocketknight1 authored and silverriver committed Jan 6, 2023
1 parent 1678c53 commit 9ede8c6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/transformers/optimization_tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import tensorflow as tf


if hasattr(tf.keras, "optimizer") and hasattr(tf.keras.optimizer, "legacy"):
Adam = tf.keras.optimizer.legacy.Adam
else:
Adam = tf.keras.optimizers.Adam
try:
from tensorflow.keras.optimizers.legacy import Adam
except ImportError:
from tensorflow.keras.optimizers import Adam


class WarmUp(tf.keras.optimizers.schedules.LearningRateSchedule):
Expand Down

0 comments on commit 9ede8c6

Please sign in to comment.