Skip to content

Commit

Permalink
fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangxjohn committed Dec 12, 2023
1 parent 323df6f commit 2cf3a77
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 4 additions & 3 deletions hyperts/framework/dl/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,9 +695,10 @@ def _compile_model(self, model, optimizer, learning_rate=0.001):
logger.info(f'metrics is `{metrics[0].name}`.')

if optimizer.lower() in ['auto', consts.OptimizerADAM]:
try:
optimizer = optimizers.AdamW(lr=learning_rate, weight_decay=0.01, epsilon=1e-6, global_clipnorm=1.0)
except:
if int(str(tf.__version__).split(".")[1]) >= 14:
from tensorflow.keras.optimizers import AdamW
optimizer = AdamW(lr=learning_rate, weight_decay=0.01, epsilon=1e-6, global_clipnorm=1.0)
else:
optimizer = optimizers.Adam(lr=learning_rate, decay=1e-8, clipnorm=10.)
elif optimizer.lower() == consts.OptimizerADAMP:
optimizer = optimizers.AdamP(lr=learning_rate, weight_decay=0.025)
Expand Down
5 changes: 1 addition & 4 deletions hyperts/framework/dl/optimizers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
if int(tf_version.split(".")[1]) < 11:
from tensorflow.keras.optimizers import *
else:
try:
from tensorflow.keras.optimizers import *
except:
from tensorflow.keras.optimizers.legacy import *
from tensorflow.keras.optimizers.legacy import *

from ._optimizers import AdamP
from ._optimizers import Lion
Expand Down

0 comments on commit 2cf3a77

Please sign in to comment.