I am using python 3.6.9 , keras 2.3.1, and (tf 2.0.0 or tf 2.1.0).
Got the compatibility versions from this table.
When I import keras I get this error.
I am using python 3.6.9 , keras 2.3.1, and (tf 2.0.0 or tf 2.1.0).
Got the compatibility versions from this table.
When I import keras I get this error.
Error:
AttributeError: module 'tensorflow_core.compat.v2' has no attribute '__internal__'
Solution:
Install Libraries
!pip install tensorflow==2.1
!pip install keras==2.3.1
Import
from tensorflow import keras
I was able to replicate your issue with the below combination as shown below
!pip install tensorflow==2.1.0
!pip install keras==2.3.1
import keras
Output:
Using TensorFlow backend.
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-3-88d96843a926> in <module>()
----> 1 import keras
8 frames
/usr/local/lib/python3.7/dist-packages/keras/initializers/__init__.py in populate_deserializable_objects()
47
48 LOCAL.ALL_OBJECTS = {}
---> 49 LOCAL.GENERATED_WITH_V2 = tf.__internal__.tf2.enabled()
50
51 # Compatibility aliases (need to exist in both V1 and V2).
AttributeError: module 'tensorflow_core.compat.v2' has no attribute '__internal__'
Fixed code:
Here issue is due to incompatibility between TF2.1 and Keras 2.3.1. Your issue can be resolved in two ways
Keras2.5.0rc0 and import kerasfrom tensorflow import keras