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


When using

model.compile(optimizer = tf.train.AdamOptimizer(),
              loss = 'sparse_categorical_crossentropy',

in my Jupyter Notebook the following Error pops up:

module ‘tensorflow._api.v2.train’ has no attribute ‘AdamOptimizer’

Tensorflow Version: 2.0.0-alpha0

Do you think the only possibility is to downgrade the TF version?


tf.train.AdamOptimizer() => tf.optimizers.Adam()

From https://www.tensorflow.org/versions/r2.0/api_docs/python/tf/optimizers

Answered By – Meixu Song

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published