autokeras icon indicating copy to clipboard operation
autokeras copied to clipboard

Bug: import autokeras as ak --> ModuleNotFoundError: No module named 'tensorflow.keras.layers.experimental'

Open Aya121298 opened this issue 1 year ago • 10 comments

Bug Description

ModuleNotFoundError: No module named 'tensorflow.keras.layers.experimental'

ModuleNotFoundError Traceback (most recent call last) in <cell line: 8>() 6 from keras.utils import to_categorical 7 import numpy as np ----> 8 import autokeras as ak 9 import matplotlib.pyplot as plt 10 plt.style.use('fivethirtyeight')

7 frames /usr/local/lib/python3.10/dist-packages/autokeras/keras_layers.py in 18 from tensorflow import nest 19 from tensorflow.keras import layers ---> 20 from tensorflow.keras.layers.experimental import preprocessing 21 22 from autokeras.utils import data_utils

ModuleNotFoundError: No module named 'tensorflow.keras.layers.experimental'

Bug Reproduction

Code for reproducing the bug:

Data used by the code: !pip install autokeras import tensorflow as tf import numpy as np import autokeras as ak

Expected Behavior

The expected behavior is for the code to run as there are dependencies that depend on the library

Setup Details

Include the details about the versions of:

  • OS type and version: google colab
  • Python: Python 3
  • autokeras:
  • keras-tuner:
  • scikit-learn:
  • numpy:
  • pandas:
  • tensorflow:

Additional context

WARNING:tensorflow:From /usr/local/lib/python3.10/dist-packages/tensorflow/python/autograph/pyct/static_analysis/liveness.py:83: Analyzer.lamba_check (from tensorflow.python.autograph.pyct.static_analysis.liveness) is deprecated and will be removed after 2023-09-23. Instructions for updating: Lambda fuctions will be no more assumed to be used in the statement where they are used, or at least in the same block. https://github.com/tensorflow/tensorflow/issues/56089

Aya121298 avatar Mar 12 '24 20:03 Aya121298

I have the same problem.

Kinddor avatar Mar 13 '24 22:03 Kinddor

You can either downgrade the TensorFlow version to less than 2.16. Or Use 2.16 or above versions of TensorFlow and install the corresponding tf_keras, and then export the environment variable TF_USE_LEGACY_KERAS=1.

AutoKeras does not support Keras 3 yet.

haifeng-jin avatar Mar 13 '24 22:03 haifeng-jin

@haifeng-jin this works for me ty

diramazioni avatar Mar 13 '24 23:03 diramazioni

thank you


From: Haifeng Jin @.> Sent: Thursday, March 14, 2024 12:45 AM To: keras-team/autokeras @.> Cc: Aya121298 @.>; Author @.> Subject: Re: [keras-team/autokeras] Bug: import autokeras as ak --> ModuleNotFoundError: No module named 'tensorflow.keras.layers.experimental' (Issue #1906)

You can either downgrade the TensorFlow version to less than 2.16. Or Use 2.16 or above versions of TensorFlow and install the corresponding tf_keras, and then export the environment variable TF_USE_LEGACY_KERAS=1.

AutoKeras does not support Keras 3 yet.

— Reply to this email directly, view it on GitHubhttps://github.com/keras-team/autokeras/issues/1906#issuecomment-1996016885, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BEY2HW247ELFKCCDXCEATL3YYDJIRAVCNFSM6AAAAABES534RWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJWGAYTMOBYGU. You are receiving this because you authored the thread.Message ID: @.***>

Aya121298 avatar Mar 14 '24 00:03 Aya121298

Do you know when this might be fixed for keras 3 to be supported? Regards Aya


From: Haifeng Jin @.> Sent: Thursday, March 14, 2024 12:45 AM To: keras-team/autokeras @.> Cc: Aya121298 @.>; Author @.> Subject: Re: [keras-team/autokeras] Bug: import autokeras as ak --> ModuleNotFoundError: No module named 'tensorflow.keras.layers.experimental' (Issue #1906)

You can either downgrade the TensorFlow version to less than 2.16. Or Use 2.16 or above versions of TensorFlow and install the corresponding tf_keras, and then export the environment variable TF_USE_LEGACY_KERAS=1.

AutoKeras does not support Keras 3 yet.

— Reply to this email directly, view it on GitHubhttps://github.com/keras-team/autokeras/issues/1906#issuecomment-1996016885, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BEY2HW247ELFKCCDXCEATL3YYDJIRAVCNFSM6AAAAABES534RWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJWGAYTMOBYGU. You are receiving this because you authored the thread.Message ID: @.***>

Aya121298 avatar Mar 14 '24 00:03 Aya121298

@haifeng-jin this works for me ty

does the execution go all the way?

Aya121298 avatar Mar 14 '24 00:03 Aya121298

I tried using the tensorflow==2.15.0 and restarted the kernel, imported os and the tensorflow amc it worked. Thank you

Aya121298 avatar Mar 14 '24 01:03 Aya121298

Installing tensorflow==2.15.0 worked for me too.

keesh0 avatar Jun 06 '24 19:06 keesh0

AutoKeras does not support Keras 3 yet.

Is there any update or estimation on this? We switched to TensorFlow 2.16 some weeks ago and it would be really nice to keep using AutoKeras with it.

GuidoBartoli avatar Jun 20 '24 13:06 GuidoBartoli