I am trying to optimize a CNN made with KERAS. For that I wanted to use the KERAS TUNER module. However, when importing the module i get the error message: “AttributeError: module ‘tensorflow.keras.layers’ has no attribute ‘RandomRotation’ “. This is shown in line 29 in the augment.py
file of KERAS’ src/applications, which can be found in the TUNER GitHub Repo.
As in this file, i tried to import also from keras_tuner.backend.keras import layers
which changed nothing.
I have installed KERAS Version 2.4.3 (Tensorflow version is the same) as well as TUNER Version 1.4.7 wit PYTHON Version 3.9.7. My suggestion is, that these versions are not compatible. However it is written in the same Repo that for Tuner the requirements are Python 3.8+ and Tensorflow 2.0+.
The minimal working example is just consisting of
from keras.models import Sequential, load_model
from keras.layers import Dense, Dropout, Conv2D, MaxPool2D, Flatten, Conv3D, MaxPooling3D, BatchNormalization
from keras.utils import np_utils
import keras_tuner
hp = keras_tuner.HyperParameters()
which will not execute the last line as the error occurs when importing keras_tuner
. I also tried different phrases to import tuner, like ìmport tensorflow.keras.tuner
and this with from ... import HyperParameters
or from keras_tuner import HyperParameters
(and similars) which lead either to the same error or to errors saying there is a collision between tensorflow and keras when importing.
Hope someone can spot my mistake here. Thanks for the help!
P.S. I have to use those versions as the CNN was created a while ago with an virtual environment giving me these packages. I just have to optimize it.