0

I'm trying to run this code in Google Colab :

from keras import optimizers from tensorflow.keras.optimizers import Adam

for i in range(5):

print(i)
model_mix = Model(inputs=[visible, visible1], outputs=x)
adam = optimizers.Adam(lr=0.01, beta_1=0.9, beta_2=0.999, epsilon=None, decay=0.0, amsgrad=False)
monitor = EarlyStopping(monitor='val_loss', min_delta=1e-3, patience=6, verbose=2, mode='auto') 
model_mix.compile(loss="mean_squared_error", optimizer=adam)
model_mix.fit(
    [x_text_train, x_img_train], y_text_train, callbacks=[checkpointer_cnn,monitor],**strong text**
    validation_data=([x_text_test, x_img_test], y_text_test),
    epochs=1000)

It worked fine before but now it is giving me an error. Can someone help me to fix it?

3 Answers3

0

Just remove optimizers., i.e. adam = Adam(lr=0.01, beta_1=0.9, beta_2=0.999, epsilon=None, decay=0.0, amsgrad=False) It should work like this.

elbe
  • 1,363
  • 1
  • 9
  • 13
  • It worked but i'm not getting good accuracy when I train my model. What parameters should I change to improve the accuracy of my model? – farheen fatima Oct 26 '21 at 20:40
  • It's hard to answer this question without seeing your code, especially the model. – elbe Oct 27 '21 at 10:58
0

Maybe it's because of diffenert editions of keras, on keras2.8.0 try:

 adam = optimizers.adam_v2.Adam(lr=0.01, ......)
ouflak
  • 2,458
  • 10
  • 44
  • 49
Yunfei
  • 1
  • 1
0

Use this

from tensorflow.keras.optimizers import Adam

Instead of

from keras import optimizers from tensorflow.keras.optimizers import Adam
Ayush Raj
  • 1
  • 2