I've been having lots of imports issues when it comes to TensorFlow and Keras and now I stumbled upon this error:
TypeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_17880/703187089.py in <module>
75 #model.compile(loss="categorical_crossentropy",optimizers.rmsprop(lr=0.0001),metrics=["accuracy"])
76
---> 77 model.compile(optimizers.rmsprop_v2(lr=0.0001, decay=1e-6),loss="categorical_crossentropy",metrics=["accuracy"])
78
79 STEP_SIZE_TRAIN=train_generator.n//train_generator.batch_size
TypeError: 'module' object is not callable
These are the imports:
from tensorflow import keras
from keras_preprocessing.image import ImageDataGenerator
from keras.layers import Dense, Activation, Flatten, Dropout, BatchNormalization
from keras.layers import Conv2D, MaxPooling2D
from keras import regularizers, optimizers
from keras.models import Sequential
from keras import optimizers
from keras.optimizers import rmsprop_v2, adadelta_v2
CodePudding user response:
kerns.optimizers.rmsprop_v2
and kerns.optimizers.adadelta_v2
are the modules. You want:
from keras.optimizers import RMSprop, Adadelta
And:
optimizers.RMSprop(lr=0.0001, decay=1e-6)
(or just RMSprop(lr=0.0001, decay=1e-6)
) instead of optimizers.rmsprop_v2(lr=0.0001, decay=1e-6)