-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: ModuleNotFoundError: No module named 'tensorflow.keras.layers.experimental' #1923
Comments
The error you're encountering (ModuleNotFoundError: No module named 'tensorflow.keras.layers.experimental') suggests that the version of TensorFlow you are using doesn't have the tensorflow.keras.layers.experimental module. This module has been deprecated in the latest versions of TensorFlow. To resolve this, you can try this: Check TensorFlow and AutoKeras CompatibilityFirst, ensure that your versions of TensorFlow and AutoKeras are compatible. AutoKeras 1.0.20 might not be fully compatible with TensorFlow 2.17.0rc0. You can check the compatibility matrix on the AutoKeras documentation or GitHub repository. Update or Downgrade TensorFlowYou may need to downgrade TensorFlow to a version compatible with AutoKeras 1.0.20. For example, TensorFlow 2.4.1 is known to be compatible with AutoKeras 1.0.20. You can downgrade TensorFlow using pip: pip install tensorflow==2.4.1 Install the Latest AutoKerasIf downgrading TensorFlow is not an option, you may need to upgrade AutoKeras. However, since you mentioned an error while upgrading AutoKeras, we'll address that next. Resolve AutoKeras Upgrade IssueTry upgrading AutoKeras to the latest version using pip: pip install --upgrade autokeras If you encounter errors during the upgrade, you can try uninstalling and then reinstalling it: pip uninstall autokeras
pip install autokeras |
I can't get autokeras 2.0 because of this: |
We also received the conflict errors with tensorflow-text. It looks like tensorflow-text is not currently available in pip for Python 3.12. We resolved this by using Python 3.10. The package info also states it has support for 3.9 or 3.11, so those should work as well. After we were able to install and use Autokeras 2.0.0 with Tensorflow 2.17 |
Bug Description
I am getting this error: File "C:\Users\jorda\Documents\PhD\Project\NLP_algorithms\CNN_AM.py", line 3, inFile "C:\Users\jorda\Documents\PhD\Project\venv\Lib\site-packages\autokeras_init_.py", line 15, in
from autokeras.auto_model import AutoModel
File "C:\Users\jorda\Documents\PhD\Project\venv\Lib\site-packages\autokeras\auto_model.py", line 26, in
from autokeras import blocks
File "C:\Users\jorda\Documents\PhD\Project\venv\Lib\site-packages\autokeras\blocks_init_.py", line 18, in
from autokeras.blocks.basic import BertBlock
File "C:\Users\jorda\Documents\PhD\Project\venv\Lib\site-packages\autokeras\blocks\basic.py", line 25, in
from autokeras import keras_layers
File "C:\Users\jorda\Documents\PhD\Project\venv\Lib\site-packages\autokeras\keras_layers.py", line 27, in
from tensorflow.keras.layers.experimental import preprocessing
ModuleNotFoundError: No module named 'tensorflow.keras.layers.experimental'
Bug Reproduction
Code for reproducing the bug:
`import os
import autokeras as ak
import numpy as np
from pandas import read_csv
from sklearn.model_selection import train_test_split
os.environ["TF_ENABLE_ONEDNN_OPTS"] = "0"
dataframe = read_csv("ML_Prompts.csv", skiprows=0)
dataset = dataframe.values
x = dataset[:, 0:1744]
y = dataset[:, 1744]
x_train, x_temp, y_train, y_temp = train_test_split(x, y, test_size=0.2)
x_val, x_test, y_val, y_test = train_test_split(x_temp, y_temp, test_size=0.5)
x_train = np.expand_dims(x_train, axis=2)
input_node = ak.Input()
output_node = ak.ConvBlock()(input_node)
output_node = ak.SpatialReduction()(input_node) # optional
output_node = ak.ConvBlock()(input_node)
output_node = ak.SpatialReduction()(output_node) # optional
output_node = ak.ClassificationHead(num_classes=8, multi_label=False)(output_node)
model = ak.AutoModel(
inputs=input_node,
outputs=output_node,
overwrite=True,
max_trials=20,
objective='val_accuracy',
tuner='bayesian'
)
model.fit(x_train, y_train, epochs=50, batch_size=4, verbose=1)
eval_result = model.evaluate(x_test, y_test, verbose=1)
print("Test loss:", eval_result[0])
print("Test accuracy:", eval_result[1])
modelv = model.export_model()
print(type(model.summary()))
try:
modelv.save("CNN_ML_Classifier.keras")
except Exception:
modelv.save("CNN_ML_Classifier.keraas")
`
Data used by the code:
Expected Behavior
Setup Details
Include the details about the versions of:
Additional context
The text was updated successfully, but these errors were encountered: