Reputation: 412
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)
Upvotes: 0
Views: 141
Reputation: 412
In TensorFlow 2.0, tf.keras is recommended. This version is stable now.
Upvotes: 1
Reputation: 23
As of the latest version of Tensorflow, it is recommended to use tensorflow.keras This is likely due to depreciation since TF is evolving rapidly.
Upvotes: 0
Reputation: 56407
tensorflow.keras
and tensorflow.python.keras
are exactly the same package, what tells you that they are different?
You are not supposed to use tensorflow.python
imports directly, as per this answer: https://stackoverflow.com/a/47306203/6108843
Upvotes: 0