AttributeError: module 'keras_tuner.engine' has no attribute 'tuner'

517 views Asked by At

I am using google colab and i have been trying to import autokeras, however when i do so, I get this error below. I have tried !pip install autokeras. I have tried to updated tensorflow, autokeras, keras, and keras-tuner to fix it but this does not help. I am unsure how to solve this issue.

import autokeras as ak
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-85d187d68977> in <cell line: 1>()
----> 1 import autokeras as ak

4 frames
/usr/local/lib/python3.10/dist-packages/autokeras/__init__.py in <module>
     15 import keras_nlp
     16 
---> 17 from autokeras.auto_model import AutoModel
     18 from autokeras.blocks import BertBlock
     19 from autokeras.blocks import CategoricalToNumerical

/usr/local/lib/python3.10/dist-packages/autokeras/auto_model.py in <module>
     27 from autokeras import graph as graph_module
     28 from autokeras import pipeline
---> 29 from autokeras import tuners
     30 from autokeras.engine import head as head_module
     31 from autokeras.engine import node as node_module

/usr/local/lib/python3.10/dist-packages/autokeras/tuners/__init__.py in <module>
     13 # limitations under the License.
     14 
---> 15 from autokeras.tuners.bayesian_optimization import BayesianOptimization
     16 from autokeras.tuners.greedy import Greedy
     17 from autokeras.tuners.hyperband import Hyperband

/usr/local/lib/python3.10/dist-packages/autokeras/tuners/bayesian_optimization.py in <module>
     15 import keras_tuner
     16 
---> 17 from autokeras.engine import tuner as tuner_module
     18 
     19 

/usr/local/lib/python3.10/dist-packages/autokeras/engine/tuner.py in <module>
     28 
     29 
---> 30 class AutoTuner(keras_tuner.engine.tuner.Tuner):
     31     """A Tuner class based on KerasTuner for AutoKeras.
     32 

AttributeError: module 'keras_tuner.engine' has no attribute 'tuner'

I have tried to updated tensorflow, autokeras, keras, and keras-tuner to fix it but this does not help.

1

There are 1 answers

1
BenjaminM On

As keras_tuner was updated (https://github.com/keras-team/keras-tuner/blob/master/keras_tuner/engine/tuner.py line 35), you must edit your file /usr/local/lib/python3.10/dist-packages/autokeras/engine/tuner.py line 30 :

class AutoTuner(keras_tuner.Tuner):

Or simply :

pip install keras-tuner==1.3

pip install typing-extensions --upgrade