Tensorflow Backend Error. Attributeerror: Module 'tensorflow' Has No Attribute 'name_scope'
Solution 1:
I recommend that you switch to using the keras
module inside TensorFlow.
It is better maintained and you will not have incompatibility issues.
According to Francois Chollet:
Keras version 2.3.0 is here, and it is the last major multi-backend release. Going forward, users are recommended to switch their code over to tf.keras in TensorFlow 2.0. This release brings API changes and a few breaking changes. Have a look under the hood and see what it includes, as well as what the plans are going forward.
Switching all the imports instead of
from keras.modelsimportSequentialfrom keras.layersimportDense
to
from tensorflow.keras.modelsimportSequentialfrom tensorflow.keras.layersimportDense
will solve all your incompatibility issues.
You can uninstall Keras altogether as a separate package since it is already included by default in TensorFlow.
OBSERVATION: If PyCharm does not recognise tensorflow.keras
, you will need to update PyCharm to the latest version >=2019.3. Only starting with that version is TensorFlow 2.0 recognised accordingly in PyCharm. Please consult the answer below for more information:
Post a Comment for "Tensorflow Backend Error. Attributeerror: Module 'tensorflow' Has No Attribute 'name_scope'"