What is the difference between keras and tf.keras?

后端 未结 3 1188
后悔当初
后悔当初 2020-12-09 13:43

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.

<
3条回答
  •  萌比男神i
    2020-12-09 13:59

    The history of Keras Vs tf.keras is long and twisted.

    Keras: Keras is a high-level (easy to use) API, built by Google AI Developer/Researcher, Francois Chollet. Written in Python and capable of running on top of backend engines like TensorFlow, CNTK, or Theano.

    TensorFlow: A library, also developed by Google, for the Deep Learning developer Community, for making deep learning applications accessible and usable to public. Open Sourced and available on GitHub.

    With the release of Keras v1.1.0, Tensorflow was made default backend engine. That meant: if you installed Keras on your system, you were also installing TensorFlow.

    Later, with TensorFlow v1.10.0, for the first time tf.keras submodule was introduced in Tensorflow. The first step in integrating Keras within TensorFlow

    With the release of Keras 2.3.0,

    • first release of Keras in sync with tf.keras
    • Last major release to support other multi-backend engines
    • And most importantly, going forward, recommend switching the code from keras to Tensorflow2.0 and tf.keras packages.

    Refer this tweet from François Chollet to use tf.keras.

    That means, Change Everywhere

    From

    from keras.models import Sequential
    from keras.models import load_model
    

    To

    from tensorflow.keras.models import Sequential
    from tensorflow.keras.models import load_model
    

    And In requirements.txt,

    tensorflow==2.3.0
    

    *Disclaimer: it might give conflicts if you were using an older version of Keras. Do pip uninstall keras in that case.

提交回复
热议问题