1

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
2
  • Please add the full traceback to your question. Commented May 10, 2022 at 12:20
  • Traceback has been added. Commented May 10, 2022 at 12:24

1 Answer 1

1

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)

Sign up to request clarification or add additional context in comments.

1 Comment

This fixed it for me. Thanks so much!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.