Currently in tensorflow 2.0, Keras
can be imported by both tensorflow.keras
and tensorflow.python.keras
. What's the difference and how should I choose from these two imports?
from tensorflow.keras import *
from tensorflow.python.keras import *
From my understanding, tensorflow.python.keras
is pretty much the same as the python package Keras, while tensorflow.keras
is implemented by TensorFlow which might be more compatible with TF, but do not have all packages as in Keras such as Layer, InputSpec, etc.
One other issue is that for some IDEs like PyCharm, they cannot find or auto-complete packages from tensorflow.keras
, and the temporary solution is to use tensorflow.python.keras
instead. (from tensorflow issue)