TensorFlow error: AttributeError: module ‘tensorflow_core._api.v2.train’ has no attribute ‘Optimizer‘

Tensorflow error:

AttributeError: module ‘tensorflow_core._api.v2.train’ has no attribute 'Optimizer‘ 

The solution:

tf.train.Optimizer

Change to:

tf.compat.v1.train.Optimizer 

success


Read More: