I'm learning TensorFlow and Keras. I'd like to try https://www.amazon.com/Deep-Learning-Python-Francois-Chollet/dp/1617294438/, and it seems to be written in Keras.
Would it be fairly straightforward to convert code to tf.keras
?
I'm not more interested in the portability of the code, rather than the true difference between the two.
Now that TensorFlow 2.0 is released both keras and tf. keras are in sync, implying that keras and tf. keras are still separate projects; however, developers should start using tf.
Keras focuses on being easy to read and write and concise in its simplicity based on the architecture. In comparison, TensorFlow is very powerful but not nearly as easy to understand. When viewing the difference, TensorFlow is much more difficult to learn and understand. In datasets, Keras is better for smaller sets.
User should always use from tensorflow import keras which will give them the public API. import keras will directly access the keras PIP package, which is not 100% same as the public API namespace. It will probably give you keras. Model/layers.
You can use TensorFlow without Keras and you can use Keras with CNTK, Theano, or other machine learning libraries. While you can use Keras without TensorFlow, Keras is always going to need a backend; it's simply an interface rather than a major processing utility.
The difference between tf.keras and keras is the Tensorflow specific enhancement to the framework.
keras
is an API specification that describes how a Deep Learning framework should implement certain part, related to the model definition and training.
Is framework agnostic and supports different backends (Theano, Tensorflow, ...)
tf.keras
is the Tensorflow specific implementation of the Keras API specification. It adds the framework the support for many Tensorflow specific features like: perfect support for tf.data.Dataset
as input objects, support for eager execution, ...
In Tensorflow 2.0 tf.keras
will be the default and I highly recommend to start working using tf.keras
At this point tensorflow has pretty much entirely adopted the keras API and for a good reason - it's simple, easy to use and easy to learn, whereas "pure" tensorflow comes with a lot of boilerplate code. And yes, you can use tf.keras without any issues, though you might have to re-work your imports in the code. For instance
from keras.layers.pooling import MaxPooling2D
Would turn into:
from tensorflow.keras.layers import MaxPooling2D
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With