close

[Solved] Tensorflow._api.v2.train has no attribute ‘AdamOptimizer’

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Tensorflow._api.v2.train has no attribute ‘AdamOptimizer’ in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Tensorflow._api.v2.train has no attribute ‘AdamOptimizer’ Error Occurs?

Today I get the following error Tensorflow._api.v2.train has no attribute ‘AdamOptimizer’ in python.

How To Solve Tensorflow._api.v2.train has no attribute ‘AdamOptimizer’ Error ?

  1. How To Solve Tensorflow._api.v2.train has no attribute 'AdamOptimizer' Error ?

    To Solve Tensorflow._api.v2.train has no attribute 'AdamOptimizer' ErrorIs the way to go. No reason to downgrade. There are lots of changes in tf 2.0 compared to 1.14.
    Note that the parameter-names of Adam have changed, too. e.g. beta1 is now beta_1, check the documentation in Meixu Songs link.

  2. Tensorflow._api.v2.train has no attribute 'AdamOptimizer'

    To Solve Tensorflow._api.v2.train has no attribute 'AdamOptimizer' ErrorIs the way to go. No reason to downgrade. There are lots of changes in tf 2.0 compared to 1.14.
    Note that the parameter-names of Adam have changed, too. e.g. beta1 is now beta_1, check the documentation in Meixu Songs link.

Solution 1

model.compile(optimizer = tf.keras.optimizers.Adam(),
              loss = 'sparse_categorical_crossentropy',
              metrics=['accuracy'])

Solution 2

tf.optimizers.Adam()

Is the way to go. No reason to downgrade.
There are lots of changes in tf 2.0 compared to 1.14.
Note that the parameter-names of Adam have changed, too. e.g. beta1 is now beta_1, check the documentation in Meixu Songs link.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read