Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

When using

model.compile(optimizer = tf.train.AdamOptimizer(),               loss = 'sparse_categorical_crossentropy',               metrics=['accuracy']) 

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?

like image 743
MatlabNewb Avatar asked Mar 23 '19 20:03

MatlabNewb


People also ask

Which module has no attribute “adamoptiimizer”?

AttributeError: module 'tensorflow._api.v2.train' has no attribute 'AdamOptiimizer' ! LaTeX Error: File `pgf {-}pie.sty' not found. "detail": "Method "POST" not allowed."

How to get the version of TensorFlow?

You can also obtain the TensorFlow version with: 1. TF 1.0: python -c "import tensorflow as tf; print (tf.GIT_VERSION, tf.VERSION)" 2.

How do I import TensorFlow in Python?

TF 2.0: python -c "import tensorflow as tf; print (tf.version.GIT_VERSION, tf.version.VERSION)" Provide a reproducible test case that is the bare minimum necessary to generate the problem.

Which version of TensorFlow should I replace with RMSProp?

The correct name is RMSprop and its located under tf.keras.optimizers. Therefore, please replace TensorFlow version: v2.5.0 Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question. Provide details and share your research! But avoid …


Video Answer


1 Answers

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

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

like image 167
Meixu Song Avatar answered Sep 16 '22 14:09

Meixu Song