AttributeError: module 'tensorflow' has no attribute 'name_scope' with Keras

I was unable to reproduce with the same versions of the keras and tensorflow, reinstalling keras and tensorflow, may solve the issue, please use commands below:

pip install --upgrade pip setuptools wheel
pip install -I tensorflow
pip install -I keras

NOTE: The -I parameter stands for ignore installed package.


For everyone who use Tensorflow 2.0 and stumble upon this question with the same error, like I did: I solved it by changing the imports from keras.xxx to tensorflow.keras.xxx