[Solved] AttributeError: module ‘tensorflow._api.v2.train‘ has no attribute ‘AdampOptimizer‘

Error Message: AttributeError: module ‘tensorflow._api.v2.train’ has no attribute ‘AdampOptimizer’
Tensorflow 2.6.0:

>>> import tensorflow as tf
>>> tf.__version__
'2.6.0'

Error code snippet:

model.compile(optimizer=tf.train.AdampOptimizer(0.001),
              loss='mse',
              metrics=['accuracy'])

Replace with:

from tensorflow.keras.optimizers import Adam
model.compile(optimizer=Adam(learning_rate=0.001), loss='mse', metrics=['accuracy'])

It can also be changed as follows:

model.compile(optimizer='adam',
              loss='mse',
              metrics=['accuracy'])

Both are operational.

Read More: