What is the difference between keras and tf.keras?

eugene picture eugene · Mar 15, 2019 · Viewed 8.6k times · Source

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.

Answer

nessuno picture nessuno · Mar 15, 2019

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