Issue Type

Bug

Have you reproduced the bug with TF nightly?

Yes

Source

source

Tensorflow Version

'2.6.0'

Custom Code

Yes

OS Platform and Distribution

windows10

Mobile device

No response

Python version

3.9.12

Bazel version

No response

GCC/Compiler version

No response

CUDA/cuDNN version

No response

GPU model and memory

No response

Current Behaviour?

A bug happened!
AttributeError: module 'keras.api._v2.keras.optimizers' has no attribute 'experimental'

Standalone code to reproduce the issue

AttributeError                            Traceback (most recent call last)
Cell In [34], line 1
----> 1 trained_model = run_experiment()

Cell In [33], 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 [32], 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'

Relevant log output

No response

0

Hi, can I work on this issue, can anyone help me out with this

0

I am new to Open source

0

please help me out in this error as i am not getting why this error came?

0

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.

0

@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.

Thank you!

0

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.

0

Closing as stale. Please reopen if you'd like to work on this further.

0

Are you satisfied with the resolution of your issue? Yes No

0
© 2022 pullanswer.com - All rights reserved.