A bug happened! AttributeError: module 'keras.api._v2.keras.optimizers' has no attribute 'experimental'
AttributeError Traceback (most recent call last) Cell In , line 1 ----> 1 trained_model = run_experiment() Cell In , line 8, in run_experiment() 3 filepath = "C:/Users/HP/video_classifier" 4 checkpoint = keras.callbacks.ModelCheckpoint( 5 filepath, save_weights_only=True, save_best_only=True, verbose=1 6 ) ----> 8 model = get_compiled_model() 9 history = model.fit( 10 X_train, 11 y_train, (...) 14 callbacks=[checkpoint], 15 ) 17 model.load_weights(filepath) Cell In , line 21, in get_compiled_model() 16 model = keras.Model(inputs, outputs) 17 lr_schedule = keras.optimizers.schedules.ExponentialDecay( 18 initial_learning_rate=1e-3, 19 decay_steps=10000, 20 decay_rate=0.9) ---> 21 opt = tf.keras.optimizers.experimental.AdamW( 22 learning_rate=lr_schedule, 23 beta_1=0.9, 24 beta_2=0.999, 25 epsilon=1e-08, 26 weight_decay = 1e-04 27 ) 28 model.compile( 29 optimizer= opt, loss="sparse_categorical_crossentropy", metrics=["accuracy"] 30 ) 31 return model AttributeError: module 'keras.api._v2.keras.optimizers' has no attribute 'experimental'
Hi, can I work on this issue, can anyone help me out with this
I am new to Open source
please help me out in this error as i am not getting why this error came?
It seems that you are trying to use the experimental module from keras.optimizers which is not available in this version of Tensorflow. This module was introduced in Tensorflow 2.4 and it is not available in 2.6.0. As the error message suggests, you might want to use the optimizers that are available in the tf.keras.optimizers module or you can upgrade your Tensorflow version to the latest version.
@diksha7869 Could you please provide the complete code or Colab gist to replicate the issue reported here. Please try with the latest Tensorflow version which is 2.11 and let us know if the issue still persists.
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.
Closing as stale. Please reopen if you'd like to work on this further.
Are you satisfied with the resolution of your issue? Yes No