Alexander
Alexander

Reputation: 533

What's the difference between tensorflow.python.keras and tensorflow.keras?

As the title says, Are they the same api? When I print the layers module in keras, the result are shown as follow:

from tensorflow.keras import layers
print(layers)
from tensorflow.python.keras import layers
print(layers)

result

<module 'tensorflow.python.keras.api._v1.keras.layers' from '/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/api/_v1/keras/layers/__init__.py'>
<module 'tensorflow.python.keras.layers' from '/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/layers/__init__.py'>

We can see that two modules come from different source.

And I find the api module from source code, there is only a BUILD file.

Is there a relation between two modules, what is the mechanism of the api generator?

Upvotes: 6

Views: 1799

Answers (1)

user11530462
user11530462

Reputation:

Anything under tf.python.* is private, intended for development only, rather than for public use.

Importing from tensorflow.python or any other modules (including import tensorflow_core...) is not supported, and can break unannounced.

So, it is suggested not to use anything with tf.python.*.

Upvotes: 4

Related Questions